This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][AArch32] Tests for ELF::R_ARM_ABS32 and ELF::R_ARM_REL32
ClosedPublic

Authored by sgraenitz on Aug 9 2023, 9:40 AM.

Details

Summary

Testing for Static Data relocations for both ARM and Thumb targets.

Diff Detail

Event Timeline

Eymay created this revision.Aug 9 2023, 9:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 9:40 AM
Eymay requested review of this revision.Aug 9 2023, 9:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 9:40 AM

This is looking very good already! Nice idea to check ARM and Thumb in one test. I am not sure, however, if it's worth the effort. They both produce R_ARM_ABS32 and R_ARM_REL32. The only difference is the alignment and here Thumb alone would be sufficient:

➜ llvm-objdump -r ...
RELOCATION RECORDS FOR [.text]:                   RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE                     VALUE           OFFSET   TYPE                     VALUE
00000004 R_ARM_ABS32              target          00000002 R_ARM_ABS32              target
00000008 R_ARM_REL32              target          00000006 R_ARM_REL32              target
       ^ ARM is on a 4-byte boundary                     ^ Thumb is 2-byte

What we should do at some point (not necessarily in this patch) is to check whether it works on big-endian targets. Add a eb suffix to the arch in order to test it, e.g. thumbebv7-none-linux-gnueabihf

llvm/test/ExecutionEngine/JITLink/AArch32/ELF_static_data_reloc.s
16

Yes, but it's no data-relocation, so it should be out-of-scope for this test.

sgraenitz added inline comments.Aug 9 2023, 12:02 PM
llvm/test/ExecutionEngine/JITLink/AArch32/ELF_static_data_reloc.s
33

Is your intention to distinguish command-lines from comments by using // and # respectively? Because then it seems you are rotating them here? All test I know use the same comment marker for both.

Eymay added a comment.Aug 11 2023, 5:38 AM

This is looking very good already! Nice idea to check ARM and Thumb in one test. I am not sure, however, if it's worth the effort. They both produce R_ARM_ABS32 and R_ARM_REL32. The only difference is the alignment and here Thumb alone would be sufficient:

➜ llvm-objdump -r ...
RELOCATION RECORDS FOR [.text]:                   RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE                     VALUE           OFFSET   TYPE                     VALUE
00000004 R_ARM_ABS32              target          00000002 R_ARM_ABS32              target
00000008 R_ARM_REL32              target          00000006 R_ARM_REL32              target
       ^ ARM is on a 4-byte boundary                     ^ Thumb is 2-byte

What we should do at some point (not necessarily in this patch) is to check whether it works on big-endian targets. Add a eb suffix to the arch in order to test it, e.g. thumbebv7-none-linux-gnueabihf

Agree, I'd say it is more a proof of concept. These provide the scaffolding to add tests for varying targets.

Eymay updated this revision to Diff 549358.Aug 11 2023, 5:50 AM

Removed non-data relocation checks and standardised comment styling

Eymay marked 2 inline comments as done.Aug 11 2023, 5:51 AM

Thanks for pointing out.

Eymay updated this revision to Diff 550740.Aug 16 2023, 7:02 AM

replace "//" with "#" entirely

sgraenitz accepted this revision.Sep 13 2023, 6:33 AM

Thanks for the updates! Can we align the assembly in the test a little more with the (now) existing ELF_static_thumb_reloc.s? That may avoid future divergence. Otherwise, this looks good to me.

llvm/test/ExecutionEngine/JITLink/AArch32/ELF_static_data_reloc.s
14

Function addresses are not in scope for this test, so we can drop the comment as well

This revision is now accepted and ready to land.Sep 13 2023, 6:33 AM
Eymay updated this revision to Diff 556766.Sep 14 2023, 3:44 AM

Update the test to align with ELF_static_thumb_reloc.s test.

Eymay marked an inline comment as done.Sep 14 2023, 3:47 AM

The disassembly of both ARM and Thumb turned out to be matching but CHECK-INSTR-{ARM,THM} can be added in the future for the lines that diverge.

sgraenitz commandeered this revision.Nov 6 2023, 8:41 AM
sgraenitz edited reviewers, added: Eymay; removed: sgraenitz.

Some polishing before landing this

This revision now requires review to proceed.Nov 6 2023, 8:41 AM
sgraenitz updated this revision to Diff 558026.Nov 6 2023, 8:45 AM

Drop check lines for disassembly. Data relocations don't invovle instruction opcodes.

sgraenitz updated this revision to Diff 558027.Nov 6 2023, 8:53 AM

Data relocations have no alignment requirements. Check it by turning target into a data symbol itself and injecting an uneven address.

sgraenitz updated this revision to Diff 558029.Nov 6 2023, 8:57 AM

Add suffixes _armv7 and _thumbv7 to temporary object file names in order to avoid collisions

sgraenitz updated this revision to Diff 558030.Nov 6 2023, 9:03 AM

Streamline indents, new-lines, comments

lhames accepted this revision.Nov 6 2023, 9:39 AM

LGTM too. Thanks @Eymay and @sgraenitz!

This revision is now accepted and ready to land.Nov 6 2023, 9:39 AM
Eymay accepted this revision.Nov 6 2023, 9:51 AM

LGTM!