Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge asm/ and analysis/ into arch/ but keep plugin formats. #4332

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

wargio
Copy link
Member

@wargio wargio commented Mar 5, 2024

DO NOT SQUASH

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

This is the first step against rz_arch. this merges still the librz/asm/ and librz/analysis/ into the same folder structure but keeps the same formats.

One change that can be noticed is that now we do have a list of all deactivated plugins.

Another big change is also related how we generate the plugins headers, which before needed to be included by the developer each time you add an arch, but now is automatically generated by meson.

After merging this pr, it will be still possible to load external asm and analysis plugins as standalone libraries.

Also I have merged TMS320C64x into TMS320 because it was a duplicated architecture which was available in both tms320 and tms320c64x with code that was duplicated between the two plugins.

Old PR #4120

@ret2libc
Copy link
Member

ret2libc commented Mar 5, 2024

Why removing the common logic in librz/meson.build? Is it possible to just declare the plugins in each librz/*/meson.build and then construct the header files in librz/meson.build so we avoid duplicated meson code?

@wargio
Copy link
Member Author

wargio commented Mar 5, 2024

t possible to just declare the plugin

because now it's built as a library, so if we split stuff is easier to handle. also bin plugins has RzBinPlugin and RzBinXtrPlugin so that common logic cannot be easily kept.

@wargio
Copy link
Member Author

wargio commented Mar 5, 2024

It also broke TMS320C64x analysis

yeah. that piece of code was made of #include "file.c"

@Rot127 Rot127 mentioned this pull request Mar 5, 2024
73 tasks
@XVilka XVilka requested a review from imbillow March 6, 2024 00:56
@wargio wargio force-pushed the dist-arch-merge branch from c1efe88 to f4901eb Compare March 6, 2024 05:22
@wargio
Copy link
Member Author

wargio commented Mar 6, 2024

It also broke TMS320C64x analysis:

I merged TMS320C64x into TMS320 because it was a dup.

@wargio wargio force-pushed the dist-arch-merge branch from 1dd5cd1 to d89bed2 Compare March 6, 2024 06:25
@wargio wargio requested a review from XVilka March 6, 2024 06:28
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we can't use the approach that was used before to avoid the duplicated meson code. We were already handling RzBinXtr and RzBin plugins. Also, we can probably also just have a single rz_plugins.h.in for all the various modules since it is the same.

Comment on lines +159 to +151
# this was never built.
# 'p/bin_xtr_pemixed.c',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean that it was never built? if it was here it should have been built. I don't get it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code was there, but it was never enabled as plugin. that is why when i added it back we had "test failing" but just because now was showing up.

Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as is. Windows builds and rz-bindgen could be fixed separately after this jumbo PR is merged.

@wargio
Copy link
Member Author

wargio commented Mar 6, 2024

I don't see why we can't use the approach that was used before to avoid the duplicated meson code. We were already handling RzBinXtr and RzBin plugins. Also, we can probably also just have a single rz_plugins.h.in for all the various modules since it is the same.

You were not handling plugins, but just creating a list of plugins which is easier to do.

@ret2libc

This comment was marked as resolved.

@wargio
Copy link
Member Author

wargio commented Mar 6, 2024

What's the difference?

The first one creates ad-hoc file per lib. within the header i have a #define and the export definition for each plugin.
The second one creates only one header file for all the libs which has only some #define in it.

The huge difference (and why this is needed) is that if i follow the old way to generate those, i would need to add the headers of all the libs into the config.h just to declare the export definitions. in the old code, since it was just a macro, the compiler ignores it unless is used.

So to avoid to have such horrendous config.h it is better and cleaner to have one specific header file generated by each library (subfolder) and included only by that library.

@ret2libc

This comment was marked as resolved.

@ret2libc

This comment was marked as resolved.

@ret2libc

This comment was marked as resolved.

@ret2libc
Copy link
Member

ret2libc commented Mar 6, 2024

export_plugins += ['extern RzLangPlugin ' + plugin.get('base_cname') + p + ';']

Whoops, this of course needs to be fixed. it should be enough to add a plugin_type field to the various *_plugins dictionary in librz/*/meson.build files.

@XVilka XVilka added this to the 0.8.0 milestone Mar 6, 2024
@wargio wargio force-pushed the dist-arch-merge branch 2 times, most recently from 1a3f58e to 99cc534 Compare March 7, 2024 06:56
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better now! Thanks 👍

meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
wargio added 5 commits March 7, 2024 16:54
This ignores warning 'yield from' directly instead of yielding
each element one by one (use-yield-from)
@wargio wargio force-pushed the dist-arch-merge branch from 99cc534 to e55caaf Compare March 7, 2024 08:55
@wargio wargio merged commit 0de960d into dev Mar 7, 2024
53 of 55 checks passed
@wargio wargio deleted the dist-arch-merge branch March 7, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants