This is an archive of the discontinued LLVM Phabricator instance.

[PPC][PPC64] PPC_REL14 and PPC64_REL14 relocations
ClosedPublic

Authored by martell on Nov 24 2018, 6:48 AM.

Details

Summary

When linking the linux kernel on ppc64 and probably ppc
ld.lld: error: built-in.a(arch/powerpc/kernel/head_64.o):(.head.text.virt_vectors+0x53C): unrecognized reloc 11
11 is PPC_REL14 and PPC64_REL14

Diff Detail

Repository
rL LLVM

Event Timeline

martell created this revision.Nov 24 2018, 6:48 AM
martell updated this revision to Diff 175158.Nov 24 2018, 6:59 AM
martell edited the summary of this revision. (Show Details)Nov 24 2018, 2:48 PM
MaskRay accepted this revision.Nov 25 2018, 9:17 PM
MaskRay added inline comments.
ELF/Arch/PPC.cpp
41 ↗(On Diff #175158)

14 24 32 may feel more natural

ELF/Arch/PPC64.cpp
425 ↗(On Diff #175158)

ditto here

This revision is now accepted and ready to land.Nov 25 2018, 9:17 PM
ruiu accepted this revision.Nov 26 2018, 9:32 AM

LGTM with these changes.

ELF/Arch/PPC.cpp
41 ↗(On Diff #175158)

Yup, please sort.

70–72 ↗(On Diff #175158)

Add this before REL24, instead of adding to the end of the existing code.

ELF/Arch/PPC64.cpp
703 ↗(On Diff #175158)

Ditto

721 ↗(On Diff #175158)

Ditto

joel added a subscriber: joel.Nov 27 2018, 3:32 PM
joel added inline comments.
ELF/Arch/PPC64.cpp
720 ↗(On Diff #175158)

This comment is now stale

739 ↗(On Diff #175158)

This introduces a warning:

lld/ELF/Arch/PPC64.cpp:739:57: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   assert(Type == R_PPC64_REL24 || Type == R_PPC64_REL14 &&
                                   ~~~~~~~~~~~~~~~~~~~~~~^~
martell updated this revision to Diff 176304.Dec 2 2018, 3:52 PM
martell updated this revision to Diff 176306.

update to address comments

This probably needs another approval based on the small changes I made to address the warning

sfertile accepted this revision.Dec 3 2018, 7:00 AM

Other then my one comment it LGTM.

ELF/Arch/PPC64.cpp
743 ↗(On Diff #176306)

inBranchRange is either called from the end of PPC64::needsThunk in which case the type must be either REL14 or REL24, or from the thunk creation framework which means that PPC64::needsThunk must have been true (and the type must have been REL14/REL24) . Because of that I think an llvm_unreachable is more appropriate than an error message.

ruiu added inline comments.Dec 3 2018, 8:31 AM
ELF/Arch/PPC64.cpp
743 ↗(On Diff #176306)

Error messages should start with a lowercase letter.

This revision was automatically updated to reflect the committed changes.
ruiu added inline comments.Dec 4 2018, 11:02 AM
lld/trunk/ELF/Arch/PPC64.cpp
744

Please do not write any code after llvm_unreachable as the code is literally unreachable.