Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

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

Authored by Eymay 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
17

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
34

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.Wed, Sep 13, 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.Wed, Sep 13, 6:33 AM
Eymay updated this revision to Diff 556766.Thu, Sep 14, 3:44 AM

Update the test to align with ELF_static_thumb_reloc.s test.

Eymay marked an inline comment as done.Thu, Sep 14, 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.