https://sourceware.org/bugzilla/show_bug.cgi?id=22001
Bug ID: 22001 Summary: -z nocopyreloc doesn't work right Product: binutils Version: 2.30 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: hjl.tools at gmail dot com Target Milestone: --- Target: x86-64 [hjl@gnu-6 nocopy-1]$ cat foo.c #include <stdlib.h> extern int copy; extern int get_copy (void); int main() { if (copy != get_copy ()) abort (); return 0; } [hjl@gnu-6 nocopy-1]$ cat bar.c #include <stdlib.h> extern int copy; extern int* get_copy_p (void); int main() { if (© != get_copy_p ()) abort (); return 0; } [hjl@gnu-6 nocopy-1]$ cat shared.c int copy = 1; int get_copy () { return copy; } int * get_copy_p () { return © } [hjl@gnu-6 nocopy-1]$ make gcc -O -c foo.c gcc -O -fPIC -c shared.c ./ld -shared -o libshared.so shared.o gcc -Wl,-z,nocopyreloc -o foo foo.o libshared.so -Wl,-rpath,. gcc -O -c bar.c gcc -Wl,-z,nocopyreloc -o bar bar.o libshared.so -Wl,-rpath,. /usr/local/bin/ld: bar.o(.text+0xb): unresolvable R_X86_64_32S relocation against symbol `copy' /usr/local/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status make: *** [Makefile:21: bar] Error 1 [hjl@gnu-6 nocopy-1]$ ./foo ./foo: Symbol `copy' causes overflow in R_X86_64_PC32 relocation Segmentation fault [hjl@gnu-6 nocopy-1]$ -- 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