public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "info at yourkit dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/21277] New: gcc 4.0 fails to statically link on Solaris SPARC 64 bit
Date: Fri, 29 Apr 2005 07:33:00 -0000	[thread overview]
Message-ID: <20050429073316.21277.info@yourkit.com> (raw)

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


             reply	other threads:[~2005-04-29  7:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-29  7:33 info at yourkit dot com [this message]
2005-04-29  7:39 ` [Bug libstdc++/21277] " pinskia at gcc dot gnu dot org
2005-04-29  7:39 ` [Bug c++/21277] " pinskia at gcc dot gnu dot org
2005-04-29  7:39 ` info at yourkit dot com
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050429073316.21277.info@yourkit.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).