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

Fix: Hexagon relocations #2612

Merged
merged 10 commits into from
May 13, 2022
Merged

Fix: Hexagon relocations #2612

merged 10 commits into from
May 13, 2022

Conversation

Rot127
Copy link
Member

@Rot127 Rot127 commented May 13, 2022

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

The Hexagon ELF relocations were completely broken and not tested at all.
This PR fixes this.

  • Fix: The patching function is now equivalent to lld.
  • Adds more relocations.
  • Introduces more bitmasks for the new relocations.
  • Separates functionality into functions.

Test plan
Added.
See: rizinorg/rizin-testbins#78

Closing issues

Ticks a box in rizinorg/rz-hexagon#27

@XVilka
Copy link
Member

XVilka commented May 13, 2022

I wonder why AppVeyor can't find the file:

[XX] C:\projects\rizin\test\db\analysis\hexagon hexagon relocation tests I
ANSICON=1 RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'pi 30
s loc.r_hex_32
px 16~[1-8]
' bins/elf/hexagon/relocs
-- stdout
--- expected
+++ actual
@@ -1,32 +1,0 @@
-?   nop
-[   nop
-[   nop
-[   nop
-[   jump 0x8000038
-[   if (P0) jump:nt loc.test_sym
-[   loop1(loc.test_sym,#0x0)
-[   R0.l = #0x34
-[   R0.h = #0x800
-[   if (R0!=#0) jump:nt loc.test_sym
-[   R0 = #0x0 ; jump loc.test_sym
-/   immext(##0xffffffc0)
-\   jump loc.test_sym
-/   immext(##0x8000000)
-\   R0 = ##0x8000034
-/   immext(##0xffffffc0)
-\   jump loc.test_sym
-/   immext(##0xffffff80)
-\   if (P0) jump:nt loc.test_sym
-/   immext(##0xffffff80)
-\   loop1(loc.test_sym,#0x0)
-[   jump loc.test_sym
-/   immext(##0xffffff80)
-\   R0 = ##0xffffffa8 ; R1 = R1
-/   immext(##0x8000000)
-\   R0 = ##0x8000034
-/   immext(##0x8000000)
-\   R0 = ##0x8000034
-/   immext(##0x8000000)
-\   R0 = memw(R0+##0x8000034)
-offset - 0 1 2 3 4 5
-3400 0008 3400 0000 3400 0000 7cff ffff
-- stderr
ERROR: [r] Cannot open 'bins/elf/hexagon/relocs'
-- exit status: 1

@wargio
Copy link
Member

wargio commented May 13, 2022

I wonder why AppVeyor can't find the file:

because the bin was not in the repo when this PR was created. just restart the CI

@XVilka XVilka merged commit fb66527 into rizinorg:dev May 13, 2022
wingdeans pushed a commit to wingdeans/rizin that referenced this pull request May 13, 2022
* Add more relocation types.
* Replace flawed patching algorithm with the `llvm-llds` algorithm.
* Add macros for bitmasks.
* Remove code duplicates.
* Add relocation tests.
wingdeans pushed a commit to wingdeans/rizin that referenced this pull request May 13, 2022
* Add more relocation types.
* Replace flawed patching algorithm with the `llvm-llds` algorithm.
* Add macros for bitmasks.
* Remove code duplicates.
* Add relocation tests.
@Rot127 Rot127 deleted the Hexagon-reloc branch May 14, 2022 08:07
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.

3 participants