When linking the linux kernel on ppc64
ld.lld: error: unrecognized reloc 58
58 is R_PPC64_GOT16_DS
Details
- Reviewers
ruiu • espindola
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
Tracking issue for clang built linux for @nickdesaulniers
https://github.com/ClangBuiltLinux/linux/issues/285
I implemented this for ppc32 as well but there are a few things that need to be changed as a result of this so I will put that in a separate patch
I'm going to add a bunch of inline comments about things that could change.
I'm probably going to learn something valuable about the global offsets table or the table of contents sections from the response to this :)
ELF/Arch/PPC64.cpp | ||
---|---|---|
23 | Any suggestions on a rename here? | |
63 | Ditto | |
530 | ditto | |
600 | I don't think I can just optimize got relocations like toc relocations Take R_PPC64_ADDR16_HA for R_PPC64_GOT16_HA as an example case R_PPC64_ADDR16_HA: if (Config->GotOptimize && IsGotRelType && ha(Val) == 0) writeInstrFromHalf16(Loc, 0x60000000); else write16(Loc, ha(Val)); break; | |
606 | comments probably need to change |
Hi @martell, Thanks for creating this patch. If I was aware of it I would have skipped mine and helped review this one. I've left a few comments below related to some of your comments.
ELF/Arch/PPC64.cpp | ||
---|---|---|
23 | I think we should update this name possibly to PPC64TocBaseOffset or PPC64TocBaseBias . TOC/toc is somewhat overloaded in the ABI, a clearer name makes it explicit that this is an offset used in building the TocBase value. | |
63 | I think this name is good as is. This calculates the address the toc pointer points at which is typically known as the tocbase. | |
67 | This comment is out of date. I'm guessing this description is for the V1 abi. The V2 abi is unfortunately somewhat ambiguous on what exactly is and isn't contained in the Table-Of-Contents. | |
600 | The optimization done here is strictly the transformation of a 2 instruction access sequence into a single instruction access sequence when the relocation offset fits in a single signed 16-bit immediate. It works similarly for got based relocation's as well as the toc based relocation (except it will work on the first 2 instructions of a 3 instruction got-indirect access sequence). For example a got-indirect access where the high-adjusted part of the access is zero gets transformed as such: addis r3, r2, sym@got@ha --> nop ld r3, sym@got@l(r3) --> ld r3, sym@got@l(r2) lwa r3, 0(r3) --> lwa r3, 0(r3) As for naming, gold does all these optimization with the --toc-optimize flag (likely because the optimization's are related to the toc-pointer ) |
Any suggestions on a rename here?
(It is no longer just toc but is got also)