Bad PIC on Solaris

Alexandre Oliva aoliva@cygnus.com
Mon Apr 10 13:40:00 GMT 2000


On Jan 26, 2000, Alexandre Oliva <oliva@lsd.ic.unicamp.br> wrote:

> GCC won't emit PIC typeinfo nodes on Solaris, both /sparc and /x86.
> GNU ld doesn't complain when a shared library is created with an
> object file containing such typeinfo nodes, but Sun ld does, when run
> with `-z text'.  For example, given the following file:

> class foo {};
> class bar : foo {};

> #include <typeinfo>

> int main() {
>   typeid(bar);
> }

> % g++ -shared -fPIC test.cc -o /dev/null
> ld: Software Generation Utilities - Solaris/ELF (3.0)
> Text relocation remains                         referenced
>     against symbol                  offset      in file
> foo type_info node                  0x0         test.o
> ld: fatal: relocations remain against allocatable but non-writable sections
> collect2: ld returned 1 exit status

Here's a patch that fixes this problem.  Tested on Solaris2.6/sparc
and 7/x86, as well as RedHat Linux 6.2 /x86 and /alpha.  Ok to
install?



More information about the Gcc-bugs mailing list