This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Broken `-z relro' test?


Hello,

Commit defe906180bad4e356bb55b60b10abd41b7ee3a1 breaks for me.

Given the new test file:

--8<---------------cut here---------------start------------->8---
int _start (void) { return 42; }
extern void _exit (int);
const void *const relro[] = { &_start, &_exit, 0 };
--8<---------------cut here---------------end--------------->8---

... hereâs what I observe:

--8<---------------cut here---------------start------------->8---
$ gcc -fPIC -shared -o t.so -Wl,-z,relro -Wall -nostartfiles -nostdlib t.c

$ readelf -Wl t.so | grep -i rel.*ro
   01     .data.rel.ro .dynamic 

$ gcc -fPIC -shared -o t.so -Wl,-z,relro -Wall -nostartfiles t.c

$ readelf -Wl t.so | grep -i rel.*ro
   01     .data.rel.ro .dynamic 

$ gcc -fPIC -shared -o t.so -Wl,-z,relro -Wall -nostdlib t.c

$ readelf -Wl t.so | grep -i rel.*ro
   01     .data.rel.ro .dynamic 

$ gcc -fPIC -shared -o t.so -Wl,-z,relro -Wall t.c

$ readelf -Wl t.so | grep -i rel.*ro
  GNU_RELRO      0x000de8 0x0000000000200de8 0x0000000000200de8 0x000218 0x000218 R   0x1
   01     .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .bss 
   05     .ctors .dtors .jcr .data.rel.ro .dynamic .got 

$ gcc --version
gcc (GCC) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ $(gcc -print-file-name=ld) --version
GNU ld (GNU Binutils) 2.21
Copyright 2010 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
--8<---------------cut here---------------end--------------->8---

For some reason, no âGNU_RELROâ segment is emitted when the -no* flags
are passed.  Any ideas?

(Conversely, with the previous test:

--8<---------------cut here---------------start------------->8---
$ gcc -fPIC -shared -o t.so -Wl,-z,relro -Wall -nostartfiles -nostdlib t.c

$ readelf -Wl t.so | grep -i rel.*ro
  GNU_RELRO      0x000ee8 0x0000000000200ee8 0x0000000000200ee8 0x000118 0x000118 R   0x1
--8<---------------cut here---------------end--------------->8---

A âGNU_RELROâ segment was emitted even though there was no
â.data.rel.roâ section, leading the test to succeed by chance.)

Thanks,
Ludoâ.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]