This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c/15906] New: unable to link with static libgcc.a if gcc runtime helper functions used (hidden symbol `__ashldi3')


I am unable to link with a static libgcc if gcc runtime helper functions are
used.  Linking with a shared libgcc_s.so works.  This is with gcc 3.3.3 on a
Solaris 2.8 (sparc) machine using binutils 2.14.  I've distilled this down to a
simple testcase:

> cat lib.c 
unsigned long long
getval()
{
    unsigned long long value = 1;
    int sh = 10;
    value <<= (64-sh);
    return value;
}

> cat main.c 
unsigned long long getval();

int
main(void)
{
    return getval();
}

> sh -x compile.sh 
+ /usr/local/fbe/3.0/bin/gcc -nodefaultlibs -fPIC -shared lib.c -o libashldi.so 
+ /usr/local/fbe/3.0/bin/gcc -nodefaultlibs -static-libgcc -o test main.c -L .
-lashldi -lc -lgcc 
/usr/local/fbe/3.0/lib/gcc-lib/sparc-sun-solaris2.8/3.3.3/../../../../sparc-sun-solaris2.8/bin/ld:
test: hidden symbol `__ashldi3' in
/usr/local/fbe/3.0/lib/gcc-lib/sparc-sun-solaris2.8/3.3.3/libgcc.a(_ashldi3.oS)
is referenced by DSO
collect2: ld returned 1 exit status


Using libgcc_s.so works however:

> /usr/local/fbe/3.0/bin/gcc -nodefaultlibs -shared-libgcc -o test main.c -L .
-lashldi -lc -lgcc_s
> ./test
> echo $?
0


> /usr/local/fbe/3.0/bin/gcc -v
Reading specs from /usr/local/fbe/3.0/lib/gcc-lib/sparc-sun-solaris2.8/3.3.3/specs
Configured with: ../gcc-3.3.3/configure --prefix=/usr/local/fbe/3.0 --with-stabs
--enable-shared --enable-threads=posix --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 3.3.3

> gcc -Wl,--version
GNU ld version 2.14 20030612


The __ashldi3 symbol appears in libgcc_s.so, but is different in libgcc.a, it is
marked ".hidden" -- I'm not sure why this is:

> objdump -tT /usr/local/fbe/3.0/lib/libgcc_s.so |& grep  ashldi
00001b58 g     F .text  0000004c              __ashldi3
00001b58 g    DF .text  0000004c  GCC_3.0     __ashldi3

> objdump -tT /usr/local/fbe/3.0/lib/gcc-lib/sparc-sun-solaris2.8/3.3.3/libgcc.a
|& grep ashldi
objdump: _ashldi3.oS: not a dynamic object
_ashldi3.oS:     file format elf32-sparc
00000000 g     F .text  0000004c .hidden __ashldi3


It appears as an undefined shared symbol (like one would expect) in the
testcase's shared library:

> objdump -tT libashldi.so |& grep ashldi
libashldi.so:     file format elf32-sparc
00000000         *UND*  00000000 __ashldi3
00000000      D  *UND*  00000000 __ashldi3


So, if anyone could shed some light on this, it would be helpful.  A couple
questions I have about this:

1. What makes the __ashldi3 symbol hidden in libgcc.a but not libgcc_s.so?
2. Is there a linker flag to ignore/override the enforcement of hidden symbols?
3. Is there a way to avoid this error while still using static libgcc?  Some
flag to disable the runtime support functions?
4. Is static libgcc not functional on Solaris?


Thanks for looking at this.
-Chris

-- 
           Summary: unable to link with static libgcc.a if gcc runtime
                    helper functions used (hidden symbol `__ashldi3')
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cruvolo at inviosoftware dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15906


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