# make gcc -O -DGCC_BUG -c main.c gcc -O -DGCC_BUG -fPIC -c shared.c gcc -shared -o libfoo.so shared.o gcc -o foo main.o libfoo.so -Wl,-rpath,. for f in foo; do echo "Running: $f"; ./$f; \ if [ $? != 0 ]; then echo Failed; fi; done Running: foo Data address: 0x8049924 != Data address from DSO: 0x400187e4 Function address: 0x80484c0 != Function address from DSO: 0x4001775f Data: 100 != Data from DSO: 10 Failed The testcase will always fail. But without -DGCC_BUG, Function address: 0x80484c0 != Function address from DSO: 0x4001775f won't be there.
Created attachment 90737 [details] A testcase.
Created attachment 91702 [details] A patch to fix the problem.
If you are convinced this is a bug, please push that upstream. I don't know why addresses of variables should be handled differently from function pointers and the code you're patching is certainly not there.