This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Bad PIC on Solaris


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


Several people have reported this problem before, when building on
Solaris with --enable-shared, but they usually forgot to mention that
they were not using GNU ld.  And then, since our installation
instructions currently recommend the native ld for Solaris, people end
up not being able to build C++ shared libraries; not even libstdc++
will build correctly.

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them

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