<div dir="ltr"><div>The following code currently links incorrectly when linking against a dynamic libc on Ubuntu 12.10 unless -fpic is specified.</div><div><br></div><div>#include <stdio.h></div><div><br></div><div>int main() {</div>
<div> fputs("hi\n", stdout);<br>}</div><div><br></div><div>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.</div>
<div><br></div><div>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.</div><br clear="all"><div>- Michael Spencer</div>
</div>