https://sourceware.org/bugzilla/show_bug.cgi?id=22842
Bug ID: 22842 Summary: Handling of R_X86_64_PC32 in a PIE against a function in a shared library could be better Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: rafael.espindola at gmail dot com CC: ccoutant at gmail dot com, hjl.tools at gmail dot com Target Milestone: --- Created attachment 10815 --> https://sourceware.org/bugzilla/attachment.cgi?id=10815&action=edit testcase The attached testcase has a shared library that defines a function foo with default visibility. The function just prints its own address and argument: void foo(void *bar) { printf("%p %p\n", bar, foo); } There is also a position independent executable that uses a R_X86_64_PC32 to find the address of foo and call it with that value. The expected result is to see the same value printed twice. If we try to use gold it errors out when linking the executable: error: test.o: requires dynamic R_X86_64_PC32 reloc against 'foo' which may overflow at runtime; recompile with -fPIC With ld.bfd it links but fails at runtime: ./test: Symbol `foo' causes overflow in R_X86_64_PC32 relocation 0x55ae794c62d0 0x7f0b794c62d0 With lld it works since lld create a canonical plt entry for foo in the main executable: 6: 00000000000011f0 0 FUNC GLOBAL DEFAULT UND foo -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils