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

Update Jaguar GPU to Rizin #3

Merged
merged 5 commits into from
Apr 19, 2021
Merged

Conversation

officialcjunior
Copy link
Member

Update Jaguar GPU to Rizin.
Just renamed the r2 data structures to its Rizin equivalent, preserving the logic, in an effort to learn about plugins.

It builds and gets installed. Haven't really tested it, yet.

$ make
cc -g -fPIC -I/usr/local/include/librz -I/usr/local/include/librz/sdb    -c -o jaguar-gpu.o jaguar-gpu.c
cc -g -fPIC -I/usr/local/include/librz -I/usr/local/include/librz/sdb  -shared -L/usr/local/lib -lrz_asm -lrz_parse -lrz_cons -lrz_reg -lrz_flag -lrz_bin -lrz_magic -lrz_io -lrz_syscall -lrz_socket -lrz_util  jaguar-gpu.o -o jaguar-gpu.so

$ rz-asm -L | grep -i jag
_d__  32         jaguar-gpu  LGPL3   Disassembler for the Jaguar GPU (by Sebastien Alaiwan)

@@ -1,9 +1,9 @@
NAME=jaguar-gpu
R2_PLUGIN_PATH=$(shell r2 -hh|grep R2_LIBR_PLUGINS|awk '{print $$2}')
Copy link
Member

Choose a reason for hiding this comment

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

I recommend to just remove the Makefile and use Meson build, like keystone plugin: https://github.com/rizinorg/rizin-extras/blob/master/keystone/meson.build

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added the meson.build, which works, but I had put the plugin path manually, which is a bit clumsy. Let me know if that needs to/can be changed.

Copy link
Member

Choose a reason for hiding this comment

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

I think @ret2libc is more qualified for this question.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is something we need to figure out... I think probably all plugins should have a meson_options.txt which allows to specify the plugins_directory, but for now I think you can use ~/.local/share/rizin/plugins.

I'll try to think about these problems soon as i switch back to rz-pm.

jaguar-gpu/jaguar-gpu.c Outdated Show resolved Hide resolved
jaguar-gpu/jaguar-gpu.c Outdated Show resolved Hide resolved
@@ -1,9 +1,9 @@
NAME=jaguar-gpu
R2_PLUGIN_PATH=$(shell r2 -hh|grep R2_LIBR_PLUGINS|awk '{print $$2}')
Copy link
Member

Choose a reason for hiding this comment

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

I think @ret2libc is more qualified for this question.

Update plugin path to ~/.local/share/rizin/plugins
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.

You can probably fold these functions in some kind of macros to reduce the same pattern again and again.

#include <rz_asm.h>
#include <rz_lib.h>

static int read16_BE(const ut8 **b) {
Copy link
Member

Choose a reason for hiding this comment

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

Please use endian functions from RzUtil.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you be a bit more specific on where to look for them?

Copy link
Member

Choose a reason for hiding this comment

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

rz_endian.h

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding that, I tried using rz_read_be16() but doesn't seem to work.
I think, it's maybe because there's a (*b) += 2; over here on this one.

Do you have a pointer to get around this problem?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@officialcjunior officialcjunior Apr 2, 2021

Choose a reason for hiding this comment

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

Thank you!
Please take a look now. Worked fine with my test file locally.

Also, I was first motivated to do the same increment on case 38 where read16BE was used, I didn't catch any difference in the disassembly after adding that.
Now, I am slightly confused why.

@officialcjunior
Copy link
Member Author

Managed to find a bin to test it. I think it's working as it should.

$ rizin  Arkanna\ Demo\ \(PD\).bin 
[0x00000000]> e asm.arch=jaguar-gpu
[0x00000000]> pd 10
            0x00000000      neg       r28
            0x00000002      add       r0, r7
            0x00000004      add       r0, r7
            0x00000006      add       r7, r16
            0x00000008      neg       r12
            0x0000000a      not       r28
            0x0000000c      invalid
            0x0000000e      add       r7, r16
            0x00000010      add       r2, r14
            0x00000012      resmac  r25

@XVilka XVilka merged commit 85010a4 into rizinorg:master Apr 19, 2021
@officialcjunior officialcjunior deleted the jaguar branch April 19, 2021 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants