Bug 22185 - final link failed: Nonrepresentable section on output
Summary: final link failed: Nonrepresentable section on output
Status: RESOLVED DUPLICATE of bug 19664
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-25 16:08 UTC by Pedro Lamarão
Modified: 2005-08-26 01:31 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Problem code (58.13 KB, text/plain)
2005-06-25 16:10 UTC, Pedro Lamarão
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Lamarão 2005-06-25 16:08:10 UTC
I get the following with the net_error.ii file attached to this bug:

[pedro@localhost Projetos]$ g++ -O3 -fPIC -c -o net_error.o net_error.ii
[pedro@localhost Projetos]$ g++ -fPIC -shared -o net_error.so net_error.o
/usr/bin/ld: net_error.o(.text+0x8e): unresolvable relocation against symbol
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::_Rep::_S_empty_rep_storage@@GLIBCXX_3.4'
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

[pedro@localhost Projetos]$ g++ -O3 -c -o net_error.o net_error.ii
[pedro@localhost Projetos]$ g++ -shared -o net_error.so net_error.o
[pedro@localhost Projetos]$

Works fine.

[pedro@localhost Projetos]$ g++ -fPIC -c -o net_error.o net_error.ii
[pedro@localhost Projetos]$ g++ -fPIC -shared -o net_error.so net_error.o
[pedro@localhost Projetos]$

Works fine.

[pedro@localhost Projetos]$ g++ -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)

The machine runs a Fedora Core 4 system.
Comment 1 Pedro Lamarão 2005-06-25 16:10:53 UTC
Created attachment 9149 [details]
Problem code

This file contains the declaration for a class inheriting from
std::runtime_error.
Comment 2 Andrew Pinski 2005-06-25 18:23:42 UTC
I think this is a binutils bug and not a bug in GCC and/or libstdc++.
Comment 3 Pedro Lamarão 2005-06-26 14:58:45 UTC
Works in the same system with a g++ 3.4.4 compiled from source:

[pedro@localhost Projetos]$ $HOME/.local/gcc-3.4.4/bin/g++ -O3 -fPIC -c -o
net_error.o net_error.ii
[pedro@localhost Projetos]$ $HOME/.local/gcc-3.4.4/bin/g++ -fPIC -shared -o
net_error.so net_error.o
[pedro@localhost Projetos]$ $HOME/.local/gcc-3.4.4/bin/g++ -v Reading specs from
/home/pedro/.local/gcc-3.4.4/lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with: ../configure --prefix=/home/pedro/.local/gcc-3.4.4
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.4
[pedro@localhost Projetos]$
Comment 4 H.J. Lu 2005-08-21 18:02:33 UTC
It is a gcc bug and has been fixed in CVS:

[hjl@gnu .libs]$ readelf --wide -s    /usr/lib/libstdc++.so.6 | grep
_ZNSs4_Rep20_S_empty_rep_s | c++filt
  1536: 000e3ef8    16 OBJECT  WEAK   DEFAULT   25 std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>::_Rep::_S_empty_rep_storage@@GLIBCXX_3.4
[hjl@gnu .libs]$ readelf --wide -s    libstdc++.so.6 | grep
_ZNSs4_Rep20_S_empty_rep_s | c++filt
  1535: 000d7d18    16 OBJECT  WEAK   DEFAULT   25 std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>::_Rep::_S_empty_rep_storage@@GLIBCXX_3.4
  2520: 000d7d18    16 OBJECT  WEAK   DEFAULT   25 std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage


*** This bug has been marked as a duplicate of 22109 ***
Comment 5 H.J. Lu 2005-08-21 20:22:42 UTC
Wrong duplicated bug.
Comment 6 H.J. Lu 2005-08-21 20:25:49 UTC
The real isssue is you can't use

#pragma GCC visibility push(hidden)

on libstdc++ and glibc since they don't support them. We need to fix both glibc
and libstdc++ header files.

*** This bug has been marked as a duplicate of 19664 ***
Comment 7 H.J. Lu 2005-08-21 20:40:12 UTC
One solution is to put

#pragma GCC visibility push(default)
...
#pragma GCC visibility pop

around all libc and libstdc++ header files, like

#pragma GCC visibility push(default)
#include <iostream.h>
#pragma GCC visibility pop

But you may run into bug 20303.
Comment 8 Pedro Lamarão 2005-08-26 01:31:15 UTC
Substituting the pragma for -fvisibility=hidden also seems to solve the problem.