https://sourceware.org/bugzilla/show_bug.cgi?id=19965
Alan Modra <amodra at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amodra at gmail dot com --- Comment #3 from Alan Modra <amodra at gmail dot com> --- Here's a testcase that I think does not invoke any undefined behaviour, and shows various inconsistencies with protected variables and copy relocs. Depending on the version of gcc (and glibc!) you may see &x != x or no segfault. Compile protmain with -fPIC to see correct behaviour. cat > prot.h <<\EOF extern void *x; extern void aprint (void); extern void boom (void); EOF cat > prota.c <<\EOF #include "prot.h" void __attribute__ ((visibility ("protected"), section(".data.rel.ro"))) *x = &x; void aprint (void) { __builtin_printf ("A: &x = %p, x = %p\n", &x, x); } EOF cat > protb.c <<\EOF #include "prot.h" void boom (void) { x = 0; } EOF cat > protmain.c <<\EOF #include "prot.h" int main (void) { __builtin_printf ("main: &x = %p, x = %p\n", &x, x); aprint (); boom (); return 0; } EOF gcc -O2 -fPIC -shared -o liba.so prota.c protb.c -Wl,-z,relro gcc -O2 -o protmain protmain.c -L. -la -Wl,-rpath,. ./protmain -- 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