This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][ELF/AARCH64] Implement R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADD_ABS_LO12_NC
ClosedPublic

Authored by sunho on May 24 2022, 3:32 AM.

Details

Summary

This implements R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADD_ABS_LO12_NC fixup edges using the generic aarch64 patch edges.

Diff Detail

Event Timeline

sunho created this revision.May 24 2022, 3:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 3:32 AM
sunho requested review of this revision.May 24 2022, 3:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 3:32 AM
sunho added a subscriber: dongAxis.EditedMay 24 2022, 3:52 AM

Have to mention the test case is taken from https://reviews.llvm.org/D118346 by @dongAxis1944

sunho updated this revision to Diff 432001.May 25 2022, 8:09 AM
sunho updated this revision to Diff 432863.May 30 2022, 1:02 AM

Rename edges so that it's easy to find original relocation type.

sunho updated this revision to Diff 433033.May 31 2022, 12:45 AM

Merge testcases

Thanks for your patch. The tests look good and appear to work fine on my machine. Will have a closer look at it towards the end of the week.

llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
62

The using namespace on file level makes the explicit qualifications here redundant right? It's a detail, but let's agree on one option and stick to it consistently. (More cases below.)

llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
50

The value of p2align varies between test cases. How does it affect the resolution? (Trying other values like 1 or 2 doesn't fail the test.)

sunho updated this revision to Diff 433775.Jun 2 2022, 9:42 AM

Update the code

llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
62

In other backends, using namespace seems to be more common. I changed the code to consistently do without namespace.

llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
50

It didn't affect the test result since we don't execute the code (-noexec), but in arm64, function entries need to be aligned to 4 bytes. Although techincally not required, I just added p2align 2 to function entry for the sake of cleaness.

The reason for p2align 4 in named_data is since it might be used to test 128bit/64bit data load/store.

sunho marked 2 inline comments as done.Jun 2 2022, 10:02 AM
sunho updated this revision to Diff 433787.Jun 2 2022, 10:08 AM

Use enum without namespace in getELFAArch64RelocationKindName

sunho edited the summary of this revision. (Show Details)Jun 2 2022, 10:23 AM
sgraenitz accepted this revision.Jun 5 2022, 12:04 PM

LGTM, thanks for working on this!

llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
50

Alright, thanks for the explanation.

The reason for p2align 4 in named_data is since it might be used to test 128bit/64bit data load/store

Yes, I realized that it makes a difference once I found it's used for the LDST relocations from D126630 as well.

This revision is now accepted and ready to land.Jun 5 2022, 12:04 PM
lhames accepted this revision.Jun 7 2022, 1:38 PM

LGTM -- Thanks very much @sunho!

This revision was landed with ongoing or failed builds.Jun 7 2022, 4:42 PM
This revision was automatically updated to reflect the committed changes.