https://llvm.org/bugs/show_bug.cgi?id=26818
Bug ID: 26818 Summary: lld incorrectly resolves function pointer relocation in dso Product: lld Version: unspecified Hardware: PC OS: FreeBSD Status: NEW Severity: normal Priority: P Component: All Bugs Assignee: unassignedb...@nondot.org Reporter: ema...@freebsd.org CC: llvm-bugs@lists.llvm.org Blocks: 23214 Classification: Unclassified Consider this test program: % cat lib.c #include <stdio.h> int(*fp)(const char *, ...) = printf; void fn(void) { fp("hello %s\n", "world"); } % cat main.c void fn(void); int main(int argc, char *argv[]) { fn(); } Linking with ld.bfd: % cc -fPIC -shared -o lib.so lib.c % cc -fPIC -Wl,-rpath=. lib.so main.c % ./a.out hello world And there's a relocation for 'fp' for printf: % readelf -s lib.so | grep fp 7: 0000000000200808 8 OBJECT GLOBAL DEFAULT 22 fp 47: 0000000000200808 8 OBJECT GLOBAL DEFAULT 22 fp % readelf -r lib.so | grep 200808 0000002007c8 000700000006 R_X86_64_GLOB_DAT 0000000000200808 fp + 0 000000200808 000400000001 R_X86_64_64 0000000000000000 printf + 0 Linking with ld.lld: % cc -fuse-ld=lld -fPIC -shared -o lib.so lib.c % cc -fuse-ld=lld -fPIC -Wl,-rpath=. lib.so main.c % ./a.out zsh: segmentation fault (core dumped) ./a.out And no relocation for the function pointer: % readelf -s lib.so | grep fp 6: 0000000000003018 8 OBJECT GLOBAL DEFAULT 19 fp 21: 0000000000003018 8 OBJECT GLOBAL DEFAULT 19 fp % readelf -r lib.so Relocation section '.rela.dyn' at offset 0x438 contains 5 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000002138 000300000006 R_X86_64_GLOB_DAT 0000000000000000 __cxa_finalize + 0 000000002140 000200000006 R_X86_64_GLOB_DAT 0000000000000000 _Jv_RegisterClasses + 0 000000003008 000000000008 R_X86_64_RELATIVE 0000000000003008 000000003010 000000000008 R_X86_64_RELATIVE 0000000000002018 000000002148 000600000006 R_X86_64_GLOB_DAT 0000000000003018 fp + 0 Relocation section '.rela.plt' at offset 0x4b0 contains 2 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000003038 000300000007 R_X86_64_JUMP_SLO 0000000000000000 __cxa_finalize + 0 000000003040 000700000007 R_X86_64_JUMP_SLO 0000000000001150 printf + 0 -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs