https://sourceware.org/bugzilla/show_bug.cgi?id=23411
Bug ID: 23411 Summary: Different behavior when linking common symbol statically or to shared object Product: binutils Version: 2.32 (HEAD) Status: NEW Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: hjl.tools at gmail dot com CC: ian at airs dot com Target Milestone: --- [hjl@gnu-cfl-1 gold-2]$ cat con.c int globalInt = 7; [hjl@gnu-cfl-1 gold-2]$ cat main.c #include <stdio.h> int globalInt; int main() { printf("globalInt is %d\n", globalInt); return 0; } [hjl@gnu-cfl-1 gold-2]$ make gcc -fuse-ld=gold -fpic -c -o main.o main.c gcc -fuse-ld=gold -fpic -c -o con.o con.c gcc -fuse-ld=gold -shared -fpic -o libcon.so con.o gcc -fuse-ld=gold -o app.shared main.o -L. -lcon -Wl,-R,. gcc -fuse-ld=gold -o app.static main.o con.o ar rv libcon.a con.o r - con.o gcc -fuse-ld=gold -o app.a main.o libcon.a ./app.shared globalInt is 0 ./app.static globalInt is 7 ./app.a globalInt is 0 [hjl@gnu-cfl-1 gold-2]$ make clean rm -f *.o libcon.so app.shared app.static [hjl@gnu-cfl-1 gold-2]$ make CC=gcc gcc -fpic -c -o main.o main.c gcc -fpic -c -o con.o con.c gcc -shared -fpic -o libcon.so con.o gcc -o app.shared main.o -L. -lcon -Wl,-R,. gcc -o app.static main.o con.o ar rv libcon.a con.o r - con.o gcc -o app.a main.o libcon.a ./app.shared globalInt is 7 ./app.static globalInt is 7 ./app.a globalInt is 7 [hjl@gnu-cfl-1 gold-2]$ -- 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