This is an archive of the discontinued LLVM Phabricator instance.

ELF: Do not relax ADRP/LDR -> ADRP/ADD for absolute symbols in PIC.
ClosedPublic

Authored by pcc on Jun 23 2022, 10:23 PM.

Details

Summary

GOT references to absolute symbols can't be relaxed to use ADRP/ADD in
position-independent code because these instructions produce a relative
address.

Diff Detail

Event Timeline

pcc created this revision.Jun 23 2022, 10:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 10:23 PM
pcc requested review of this revision.Jun 23 2022, 10:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 10:23 PM

Thanks for catching this case. For absolute symbols we can choose not relaxing in -no-pie mode. Do you prefer relaxing?

lld/test/ELF/aarch64-adrp-ldr-got-symbols.s
42

can be applied in -no-pie mode?

pcc added a comment.Jun 23 2022, 10:37 PM

Thanks for catching this case. For absolute symbols we can choose not relaxing in -no-pie mode. Do you prefer relaxing?

Either way is fine with me.

pcc updated this revision to Diff 439625.Jun 23 2022, 10:38 PM

Comment

pcc marked an inline comment as done.Jun 23 2022, 10:38 PM
peter.smith accepted this revision.Jun 24 2022, 1:34 AM

Thanks for the fix. I'll see about getting a condition added to the ABI to mention Absolute addresses in a PI context.

This revision is now accepted and ready to land.Jun 24 2022, 1:34 AM