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

macaw-riscv: Add PLTStubInfo for RISC-V programs #414

Closed
RyanGlScott opened this issue Jul 26, 2024 · 0 comments · Fixed by #417
Closed

macaw-riscv: Add PLTStubInfo for RISC-V programs #414

RyanGlScott opened this issue Jul 26, 2024 · 0 comments · Fixed by #417
Labels

Comments

@RyanGlScott
Copy link
Contributor

Currently, we do not provide a PLTStubInfo value for RISC-V in macaw-riscv. I think it would be relatively straightforward to define one, however. Using binaries produced by riscv{32,64}-linux-musl-gcc as a baseline, here is a first attempt:

riscvPLTStubInfo = PLTStubInfo
  { pltFunSize     = 32
  , pltStubSize    = 16
  , pltGotStubSize = error "Unexpected .plt.got section in RISC-V binary"
  }

This is probably best done in conjunction with GaloisInc/elf-edit#36.

After we add riscvPLTStubInfo, make sure to use it here (and add a test case demonstrating that it works):

binfo <- MST.runDiscovery ehi exePath MST.toAddrSymMap archInfo
-- Test cases involving shared libraries are not
-- yet supported on the RISC-V backend. At a
-- minimum, this is blocked on
-- https://github.com/GaloisInc/elf-edit/issues/36.
(MMELP.noPLTStubInfo "RISC-V")

RyanGlScott added a commit that referenced this issue Jul 30, 2024
This builds on top of the work in GaloisInc/elf-edit#45. For now, I only add
support for a select few relocation types, leaving the rest as future work.

This paves a way for an eventual fix for #414.
RyanGlScott added a commit that referenced this issue Jul 30, 2024
Now that we can load RISC-V relocations in `macaw` (building on top of the work
in GaloisInc/elf-edit#45), this patch adds PLT stub heuristics for RISC-V
binaries. I have added some test cases in `macaw-riscv-symbolic` which
demonstrate that the basic idea works.

Note that due to #416, these test cases will print warnings when loaded into
`macaw`. These warnings are ultimately harmless, however, as the same
relocations are loaded at the same addresses multiple times, which causes no
change in behavior.

Fixes #414.
RyanGlScott added a commit that referenced this issue Jul 31, 2024
This builds on top of the work in GaloisInc/elf-edit#45. For now, I only add
support for a select few relocation types, leaving the rest as future work.

This paves a way for an eventual fix for #414.
RyanGlScott added a commit that referenced this issue Jul 31, 2024
Now that we can load RISC-V relocations in `macaw` (building on top of the work
in GaloisInc/elf-edit#45), this patch adds PLT stub heuristics for RISC-V
binaries. I have added some test cases in `macaw-riscv-symbolic` which
demonstrate that the basic idea works.

Note that due to #416, these test cases will print warnings when loaded into
`macaw`. These warnings are ultimately harmless, however, as the same
relocations are loaded at the same addresses multiple times, which causes no
change in behavior.

Fixes #414.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant