[LLVMdev] [lld] ELF needs type for SharedLibraryAtom.

Michael Spencer bigcheesegs at gmail.com
Mon Sep 23 16:52:16 PDT 2013


The following code currently links incorrectly when linking against a
dynamic libc on Ubuntu 12.10 unless -fpic is specified.

#include <stdio.h>

int main() {
  fputs("hi\n", stdout);
}

The reason is that stdout gets a R_X86_64_PC32 relocation, but is of type
Object. The ELF writer can't see this, and assumes all R_X86_64_PC32
relocations in dynamic outputs are to functions and thus need PLT entries.
The correct behavior is to treat this as a R_X86_64_GOTPCREL relocation. As
this is what both gnu-ld and gold do.

To handle this correctly we will need to add type information to
SharedLibraryAtom. We will also need to know about STT_COMMON in the future.

- Michael Spencer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130923/89eb337d/attachment.html>


More information about the llvm-dev mailing list