https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94391
Bug ID: 94391 Summary: gcc refers to absolute symbols with R_X86_64_PC32 relocation Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: yshuiv7 at gmail dot com Target Milestone: --- Test case: Source file (a.c): extern char _binary_a_c_size[]; unsigned long foo() { return (unsigned long)_binary_a_c_size; } Run: objcopy -B i386:x86-64 -I binary -O elf64-x86-64 a.c b.o gcc -fuse-ld=lld -fpie -pie a.c b.o lld complains about: ld.lld: error: relocation R_X86_64_PC32 cannot refer to absolute symbol: _binary_a_c_size >>> defined in b.o >>> referenced by a.c >>> /tmp/cc3iReeC.o:(foo) Also, this seems to be more than just a problem in gcc. Doing the same test with clang+lld yields the expected results. However, with clang+gold/bfd, the absolute symbol is relocated.