Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang generates @PLT branches for powerpc, even when built without -fPIC #43075

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR44105
Status NEW
Importance P enhancement
Reported by Justin Hibbits (chmeeedalf@gmail.com)
Reported on 2019-11-21 13:18:26 -0800
Last modified on 2019-11-22 07:21:11 -0800
Version trunk
Hardware Macintosh All
CC hfinkel@anl.gov, llvm-bugs@lists.llvm.org, neeilans@live.com, nemanja.i.ibm@gmail.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
A simple program:

int main(int);

int __start(void) {
  return main(0);
}

When built with clang for powerpc: cc -m32 -ffreestanding -o freestanding.o

generates R_PPC_PLTREL24 relocations, when it should be generating only
R_PPC_REL32 relocations, and letting the linker do the fixups.  These
R_PPC_PLTREL24 relocations appear to be forcing GNU ld to use BSS-PLT instead
of secure-PLT.  Generating to asm, hand-removing the @PLT annotation, GNU ld
does not choose bss-plt.

Not sure if this is a clang bug or LLVM bug, as the intermediate LLVM listing
is difficult to decipher.
Quuxplusone commented 4 years ago

Even explicitly passing -fno-PIC/-fno-pic it still generates PLT relocations.

Quuxplusone commented 4 years ago

A patch is available at https://reviews.llvm.org/D70570

Quuxplusone commented 4 years ago

I confirmed with a FreeBSD 'make buildworld', that the patch in the review fixes building with secure-plt for powerpc.