This is an archive of the discontinued LLVM Phabricator instance.

Allow targets to override the use of getKindForGlobal in AsmPrinter to avoid text relocations on PPC64
AbandonedPublic

Authored by joerg on Nov 5 2016, 4:55 PM.

Details

Summary

getKindForGlobal is currently a static member of TargetLoweringObjectFile and can't be easily customised. One of the more complicated uses is to decide whether a IR constant with relocations can be emitted as constant section.

The default implementation can deal with static vs PIC, but the SYSV ABI for PPC64 is special in that it always requires the PIC rules to be followed. The patch introduces a new method getSectionKindForGlobal with a matching override in the PPC implementation to get the right behavior.

Diff Detail

Repository
rL LLVM

Event Timeline

joerg updated this revision to Diff 76973.Nov 5 2016, 4:55 PM
joerg retitled this revision from to Allow targets to override the use of getKindForGlobal in AsmPrinter to avoid text relocations on PPC64.
joerg updated this object.
joerg added reviewers: grosbach, hfinkel.
joerg set the repository for this revision to rL LLVM.
joerg added a subscriber: llvm-commits.
echristo added a subscriber: echristo.

I've been in this code more than anyone, I'll add it to my list.

hfinkel edited edge metadata.Nov 8 2016, 5:00 PM

The default implementation can deal with static vs PIC, but the SYSV ABI for PPC64 is special in that it always requires the PIC rules to be followed.

Please demonstrate where the ABI requires this; I'm not sure that your premise is correct. http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html says, for example, "One aspect of segment loading differs between executable files and shared objects. Executable file segments may contain absolute code... On the other hand, shared object segments typically contain position-independent code...".

joerg added a comment.Nov 9 2016, 5:03 AM

The most explicit statement is http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#CODE-EX This is different from the ELFv2 statements, which explicitly also discusses position dependent code.

The most explicit statement is http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#CODE-EX This is different from the ELFv2 statements, which explicitly also discusses position dependent code.

Commented in D26290; let's work out the issue there and then come back to this one.

joerg abandoned this revision.Dec 14 2016, 4:13 PM

Superseded by PIC default for PPC64.