https://sourceware.org/bugzilla/show_bug.cgi?id=19965
Bug ID: 19965
Summary: Copy relocation leads to change in read-only data
Product: binutils
Version: 2.27 (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
[hjl@gnu-6 relro-9]$ cat x.c
int const p1[1] = { -1 };
[hjl@gnu-6 relro-9]$ cat foo.c
#include <stdlib.h>
extern int const p1[1];
void
foo (void)
{
if (p1[0] != -1)
abort ();
}
[hjl@gnu-6 relro-9]$ cat m.c
#include <stdio.h>
extern void foo (void);
extern int p1[1];
int
main ()
{
foo ();
printf ("%d\n", p1[0]);
p1[0] = 0;
foo ();
return 0;
}
[hjl@gnu-6 relro-9]$ make
gcc -O2 -g -c -o m.o m.c
gcc -O2 -g -fPIC -c -o x.o x.c
gcc -O2 -g -fPIC -c -o foo.o foo.c
ld -shared --gc-sections -z relro -o libx.so x.o foo.o
gcc -o x -O2 -g m.o libx.so -Wl,-R,.
./x
-1
Makefile:10: recipe for target 'all' failed
make: *** [all] Aborted
[hjl@gnu-6 relro-9]$
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils