bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/19965] New: Copy relocation leads to change in read-only data


From: hjl.tools at gmail dot com
Subject: [Bug ld/19965] New: Copy relocation leads to change in read-only data
Date: Mon, 18 Apr 2016 16:37:31 +0000

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

address@hidden relro-9]$ cat x.c
int const p1[1] = { -1 };
address@hidden relro-9]$ cat foo.c
#include <stdlib.h>

extern int const p1[1];

void
foo (void)
{
  if (p1[0] != -1)
    abort ();
}
address@hidden 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;
}
address@hidden 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
address@hidden relro-9]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]