Page MenuHomePhabricator

Support PC relative relocation on AArch64 and PPC64 in RelocationResolver
AbandonedPublic

Authored by yuyichao on Jul 14 2020, 11:24 AM.

Details

Summary

Ref https://github.com/JuliaLang/julia/issues/35460

When compiled with --code-model=large --relocation-model=static, LLVM emits PC relative relocations in the .eh_frame section. Loading it then causes a waring to be printed.

AFAICT, the actual relocation is not actually used by any existing tools which is why I'm not adding any test. This also seems to be the case for X86 ref https://reviews.llvm.org/D67779 . The only test done is confirming that this fixes the warning with llvm-dwarfdump.

Diff Detail

Event Timeline

yuyichao created this revision.Jul 14 2020, 11:24 AM
mstorsjo edited reviewers, added: MaskRay; removed: mstorsjo.Jul 14 2020, 11:39 AM

Yes, .eh_frame may have such PC-relative relocations. Ideally R_PPC64_REL32 needs 0xffffffff. We need tests for these relocation types. If you don't mind I'll add them and commit the patch for you.

Is there a difference between R_PPC64_REL32 vs R_AARCH64_PREL32 vs R_X86_64_PC32? I didn't add mask because the x86 one doesn't have it.

I know for some relocations, some bits should be masked off. However, I'm under the impression that for these relocation if the value doesn't fit it would just be an error. Is that the case?

MaskRay added a comment.EditedJul 17 2020, 10:19 PM

Is there a difference between R_PPC64_REL32 vs R_AARCH64_PREL32 vs R_X86_64_PC32? I didn't add mask because the x86 one doesn't have it.

I know for some relocations, some bits should be masked off. However, I'm under the impression that for these relocation if the value doesn't fit it would just be an error. Is that the case?

Ideally the interface should report an error. Unfortunately it does not do that (yet). This is OK because RelocationResolver is only used by llvm-dwarfdump and LLD (and also llvm-xray but that use case can be avoided) and their use cases don't really error reporting for relocations.

yuyichao added a comment.EditedJul 17 2020, 10:56 PM

OK, so I guess at least R_X86_64_PC32 should be fixed too. If you don't mind, feel free to commit an updated version of this. I can also update this later next week after I'm free again, though, as I said, I have a hard time constructing an IR test for this....

This is OK because RelocationResolver is only used by llvm-dwarfdump and LLD

And I still hope that there are fewer relocation resolvers in LLVM but I digress...

Closed by b922004ea29d54534c4f09b9cfa655bf5f3360f0 & 3073a3aa1ef1ce8c9cac9b97a8e5905dd8779e16

I left a comment in that Julia bug as well... Thanks!

yuyichao abandoned this revision.Jul 22 2020, 9:32 AM

Seems that this wasn't automatically closed by the two commits so I'm closing manually...