[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/22001] New: -z nocopyreloc doesn't work right
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/22001] New: -z nocopyreloc doesn't work right |
Date: |
Thu, 24 Aug 2017 00:24:55 +0000 |
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
address@hidden 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;
}
address@hidden 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;
}
address@hidden nocopy-1]$ cat shared.c
int copy = 1;
int
get_copy ()
{
return copy;
}
int *
get_copy_p ()
{
return ©
}
address@hidden 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
address@hidden nocopy-1]$ ./foo
./foo: Symbol `copy' causes overflow in R_X86_64_PC32 relocation
Segmentation fault
address@hidden nocopy-1]$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/22001] New: -z nocopyreloc doesn't work right,
hjl.tools at gmail dot com <=