This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][RISCV] Support GOT/PLT relocations
ClosedPublic

Authored by StephenFan on Aug 6 2021, 10:54 PM.

Details

Summary

This patch add the R_RISCV_GOT_HI20 and R_RISCV_CALL_PLT relocation support. And the basic got/plt was implemented. Because of riscv32 and riscv64 has different pointer size, the got entry size and instructions of plt entry is different. This patch is the basic support, the optimization pass at preFixup stage has not been implemented.

Diff Detail

Event Timeline

StephenFan created this revision.Aug 6 2021, 10:54 PM
StephenFan requested review of this revision.Aug 6 2021, 10:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2021, 10:54 PM
lhames accepted this revision.Aug 17 2021, 10:06 PM

As usual I can't speak to the RISCV specifics, but the patch looks good to me in general.

This revision is now accepted and ready to land.Aug 17 2021, 10:06 PM
This revision was landed with ongoing or failed builds.Aug 27 2021, 8:59 PM
This revision was automatically updated to reflect the committed changes.
jrtc27 added inline comments.Oct 11 2021, 7:26 PM
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
83

These look like Mach-O-isms, where sections are generally called __FOO. The ELF names for sections is normally .foo; e.g. the GOT is normally in a .got section. This does not make sense as an ELF section name. Assuming "stubs" here means PLT, it should be in a .plt section.

lhames added inline comments.Oct 11 2021, 11:21 PM
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
83

For now we're sticking to consistent names for synthetic sections, unless there's a concrete need to stick to format specifics -- this helps keep utility passes as simple as possible.

if ELF .got/.plt sections are referred to by name from other parts of the object that would be a good reason to change the names here, but I don't think that's supported?