This is the mail archive of the 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++/21277] New: gcc 4.0 fails to statically link on Solaris SPARC 64 bit

Summary: gcc 4.0 produces corrupted shared library if it is statically linked
with libstdc++ and etc. stuff

>g++ -v

Using built-in specs.
Target: sparc-sun-solaris2.9
Configured with: ../gcc-4.0.0/configure
--prefix=/home2/anton/opt/gcc-4.0.0-noshared --with-gnu-ld
--with-ld=/home2/anton/opt/bin/ld --with-gnu-as
--with-as=/home2/anton/opt/bin/as --disable-libgcj --enable-languages=c,c++
Thread model: posix
gcc version 4.0.0

>uname -a

SunOS solaris 5.9 Generic_117171-07 sun4u sparc SUNW,Sun-Blade-100

Source code of shared library:

=== q.cpp start ===

#include <stdio.h>

extern "C" {
  void foo() {
    printf("sizeof(void*)=%d\n", sizeof(void*));

=== q.cpp end ===

>g++ -m64 -fPIC q.cpp -shared -o
>file        ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically
linked, not stripped
>ldd -Ur =>     /usr/lib/64/ =>     /usr/lib/64/ =>    /usr/lib/64/

   unreferenced object=/usr/lib/64/; unused dependency of ./
   unused object=/usr/lib/64/; member of cyclic group [1]

Everything seems to be OK.

But when we load .so with the following simple program test.cpp, it prints error

=== test.cpp start ===
#include <dlfcn.h>      /* defines dlopen(), etc.       */
#include <stdlib.h>
#include <stdio.h>

int main() {

  void* lib_handle = dlopen("/home2/anton/projects/frekenbok/", RTLD_LAZY);
  if (!lib_handle) {
      fprintf(stderr, "Error during dlopen(): %s\n", dlerror());

=== test.cpp end ===

>g++ -m64 test.cpp
Error during dlopen(): a.out: fatal: relocation error: R_SPARC_WDISP30:
file /home2/anton/projects/frekenbok/ symbol strcpy: value 0x6053f9f7
does not fit

There is no problem if gcc is configured with shared enabled (i.e. without
"--disable-shared" flag), and .so is dynamically linked with etc.
As well everything is fine in 32 bit mode (-m32), even statically linked.

So the problem appears _only_ in 64 bit mode and _only_ when resulting shared
library is statically linked.

           Summary: gcc 4.0 fails to statically link on Solaris SPARC 64 bit
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: info at yourkit dot com
                CC: gcc-bugs at gcc dot gnu dot org

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