[Bug lto/86517] New: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object with LTO
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 13 14:19:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86517
Bug ID: 86517
Summary: relocation R_X86_64_32 against `.rodata.str1.1' can
not be used when making a shared object with LTO
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: hubicka at gcc dot gnu.org, marxin at gcc dot gnu.org
Target Milestone: ---
When mixing PIE and PIC one gets:
$ cat 1.i
int key_thread_attempt_id ;
int main() {
}
$ cat 2.i
void get_ioctl_ops();
void a() {
get_ioctl_ops();
}
$ cat lib.i
void open_fd(char *);
void init_ioctl_ctl() { open_fd(""); }
void get_ioctl_ops() {}
$ gcc -flto -c -fPIE -O2 1.i 2.i && gcc -fPIC -c -O2 lib.i -flto && ar rv x.a
lib.o && gcc -pie -O2 -pthread -ldl -lxml2 1.o 2.o x.a -rdynamic -flto=9
-shared
r - lib.o
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld:
/tmp/cctTbHed.ltrans0.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1'
can not be used when making a shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: final
link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Without LTO it works fine:
$ gcc -c -fPIE -O2 1.i 2.i && gcc -fPIC -c -O2 lib.i && ar rv x.a lib.o && gcc
-pie -O2 -pthread -ldl -lxml2 1.o 2.o x.a -rdynamic -shared
Note that usage -shared is trick how I was able to reduce number of object
files. But original test-case does not use it.
More information about the Gcc-bugs
mailing list