public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21277] New: gcc 4.0 fails to statically link on Solaris SPARC 64 bit
@ 2005-04-29  7:33 info at yourkit dot com
  2005-04-29  7:39 ` [Bug libstdc++/21277] " pinskia at gcc dot gnu dot org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: info at yourkit dot com @ 2005-04-29  7:33 UTC (permalink / raw)
  To: gcc-bugs

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++
--disable-shared
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 libq.so
>file libq.so
libq.so:        ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically
linked, not stripped
>ldd -Ur libq.so
        libm.so.1 =>     /usr/lib/64/libm.so.1
        libc.so.1 =>     /usr/lib/64/libc.so.1
        libdl.so.1 =>    /usr/lib/64/libdl.so.1
        /usr/platform/SUNW,Sun-Blade-100/lib/sparcv9/libc_psr.so.1

   unreferenced object=/usr/lib/64/libm.so.1; unused dependency of ./libq.so
   unused object=/usr/lib/64/libm.so.1; 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
message:

=== 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/libq.so", RTLD_LAZY);
  if (!lib_handle) {
      fprintf(stderr, "Error during dlopen(): %s\n", dlerror());
      exit(1);
  }

}
=== test.cpp end ===

>g++ -m64 test.cpp
>./a.out
Error during dlopen(): ld.so.1: a.out: fatal: relocation error: R_SPARC_WDISP30:
file /home2/anton/projects/frekenbok/libq.so: 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 libstdc++.so 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


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


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2005-05-02 15:54 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-29  7:33 [Bug c++/21277] New: gcc 4.0 fails to statically link on Solaris SPARC 64 bit info at yourkit dot com
2005-04-29  7:39 ` [Bug libstdc++/21277] " pinskia at gcc dot gnu dot org
2005-04-29  7:39 ` [Bug c++/21277] " info at yourkit dot com
2005-04-29  7:39 ` pinskia at gcc dot gnu dot org
2005-04-29  7:55 ` [Bug libstdc++/21277] " pcarlini at suse dot de
2005-04-29  8:27 ` [Bug c++/21277] " info at yourkit dot com
2005-04-29 12:40 ` [Bug target/21277] " pinskia at gcc dot gnu dot org
2005-04-29 15:25 ` [Bug c++/21277] " info at yourkit dot com
2005-04-29 19:19 ` pinskia at gcc dot gnu dot org
2005-04-29 19:20 ` pinskia at gcc dot gnu dot org
2005-04-30 20:46 ` [Bug target/21277] Runtime error with C++ shared library and --disable-shared ebotcazou at gcc dot gnu dot org
2005-05-02  6:59 ` info at yourkit dot com
2005-05-02  7:16 ` ebotcazou at gcc dot gnu dot org
2005-05-02  7:19 ` info at yourkit dot com
2005-05-02  7:23 ` info at yourkit dot com
2005-05-02  7:27 ` ebotcazou at gcc dot gnu dot org
2005-05-02  7:33 ` info at yourkit dot com
2005-05-02  7:57 ` ebotcazou at gcc dot gnu dot org
2005-05-02  8:15 ` info at yourkit dot com
2005-05-02  9:05 ` ebotcazou at gcc dot gnu dot org
2005-05-02  9:25 ` info at yourkit dot com
2005-05-02  9:47 ` info at yourkit dot com
2005-05-02  9:54 ` ebotcazou at gcc dot gnu dot org
2005-05-02  9:58 ` ebotcazou at gcc dot gnu dot org
2005-05-02 11:10 ` info at yourkit dot com
2005-05-02 15:54 ` ebotcazou at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).