This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][ELF/AARCH64] Implement R_AARCH64_PREL32 and R_AARCH64_PREL64
ClosedPublic

Authored by sunho on Jun 4 2022, 5:28 PM.

Details

Summary

This patch implements R_AARCH64_PREL64 and R_AARCH64_PREL32 relocations that is used in eh frame pointers. The test case utlizes obj2yaml tool to create an artifical eh frame that generates related relocation types.

Diff Detail

Event Timeline

sunho created this revision.Jun 4 2022, 5:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2022, 5:28 PM
sunho requested review of this revision.Jun 4 2022, 5:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2022, 5:28 PM
sgraenitz added inline comments.Jun 7 2022, 7:01 AM
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.test
3

Trailing whitespace

62

Where do the offsets come from and what is text - eh_frame - <offset> supposed to be pointing at? I am getting these sections in the object:

.text
0000 e0031f2a c0035fd6

.eh_frame
0000 10000000 00000000 017a5200 017c1e01
0010 1b0c1f00 10000000 18000000 00000000
0020 08000000 00000000          ^^^^^^^^ eh_frame + 28
     ^^^^^^^^^^^^^^^^^ eh_frame + 32
sunho added inline comments.Jun 7 2022, 10:37 AM
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.test
62

It's the delta from eh_frame + 28 to text + 0. eh_frame + 28 is the bytes that's going to be patched and it should point to text + 0. I can probably make it more clear by rewriting it to

jitlink-check: *{4}(eh_frame + 28) = (text + 0) - (eh_frame + 28)
sunho added inline comments.Jun 7 2022, 10:38 AM
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.test
3

👀

sunho updated this revision to Diff 434888.Jun 7 2022, 10:48 AM

Rebase and address stefan's comments

sunho marked 2 inline comments as done.Jun 7 2022, 10:48 AM
lhames accepted this revision.Jun 8 2022, 12:13 PM

LGTM. Thanks @sunho!

llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.test
2–4

For single-file tests that don't need to name the object file in a jitlink-check expression, we usually omit the separate subdirectory:

# RUN: yaml2obj -o %t.o %s
# RUN: llvm-jitlink -noexec -check %s %t.o

I'll make this simplification here when I land the patch.

This revision is now accepted and ready to land.Jun 8 2022, 12:13 PM
This revision was landed with ongoing or failed builds.Jun 8 2022, 12:14 PM
This revision was automatically updated to reflect the committed changes.