bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/23411] New: Different behavior when linking common symbol stat


From: hjl.tools at gmail dot com
Subject: [Bug gold/23411] New: Different behavior when linking common symbol statically or to shared object
Date: Fri, 13 Jul 2018 17:55:41 +0000

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: ---

address@hidden gold-2]$ cat con.c
int globalInt = 7;
address@hidden gold-2]$ cat main.c
#include <stdio.h>

int globalInt;

int main()
{
   printf("globalInt is %d\n", globalInt);
   return 0;
}
address@hidden 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
address@hidden gold-2]$ make clean
rm -f *.o libcon.so app.shared app.static
address@hidden 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
address@hidden gold-2]$

-- 
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]