keystone-engine / keystone

Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings
http://www.keystone-engine.org
GNU General Public License v2.0
2.31k stars 459 forks source link

Fix directive address update for non target-specific directives #576

Open Ninja3047 opened 9 months ago

Ninja3047 commented 9 months ago

The previous fix https://github.com/keystone-engine/keystone/pull/274 only updated the address for target specific directives. There are a number of generic directives that also emit bytes so the address needs to be updated.

The ppc regression test should have caught this but the expected value was incorrect. The expected branch target for the PPC test is off by 8 and has been updated from

0x00000000   4                 38800001  li r4, 1
0x00000004   4                 38840001  addi r4, r4, 1
0x00000008   4                 4800bff9  bl 0xc000
0x0000000c   4                 38800001  li r4, 1
0x00000010   4                 38a50001  addi r5, r5, 1
0x00000014   4                 4800bff9  bl 0xc00c

to

0x00000000   4                 38800001  li r4, 1
0x00000004   4                 38840001  addi r4, r4, 1
0x00000008   4                 4800bff9  bl 0xc000
0x0000000c   4                 38800001  li r4, 1
0x00000010   4                 38a50001  addi r5, r5, 1
0x00000014   4                 4800bff5  bl 0xc008