https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70305

            Bug ID: 70305
           Summary: 5.3.0 solaris: ld: fatal: relocation error:
                    R_SPARC_DISP32: file
                    ../src/c++11/.libs/libc++11convenience.a
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrew at ishiboo dot com
  Target Milestone: ---

In 5.3.0 release on Solaris, the libstdc++, libitm, and libgfortran libraries
all fail to link with hundreds of errors such as:

ld: fatal: relocation error: R_SPARC_DISP32: file
../src/c++11/.libs/libc++11convenience.a(wlocale-inst.o): section
[1504].rela.eh_frame: symbol
.text._ZNKSt19istreambuf_iteratorIwSt11char_traitsIwEE5equalERKS2_%std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> >::equal(std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > const&) const (section): symbol has been discarded
with discarded section:
[716].text._ZNKSt19istreambuf_iteratorIwSt11char_traitsIwEE5equalERKS2_%std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> >::equal(std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > const&) const

or

ld: fatal: relocation error: R_SPARC_UA32: file
../src/c++11/.libs/libc++11convenience.a(wlocale-inst.o): section [1509].rel
a.debug_line: symbol
.text._ZNKSt19istreambuf_iteratorIwSt11char_traitsIwEE5equalERKS2_%std::istreambuf_iterator<wchar_t,
st
d::char_traits<wchar_t> >::equal(std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > const&) const (section): symb
ol has been discarded with discarded section:
[716].text._ZNKSt19istreambuf_iteratorIwSt11char_traitsIwEE5equalERKS2_%std::i
streambuf_iterator<wchar_t, std::char_traits<wchar_t>
>::equal(std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> >
 const&) const

The Solaris 11 linker by default now is very strict about COMDAT relocation
processing. A new linker flag has been added `-z relax=comdat` that relaxes
COMDAT rules and enables sloppy relocation processing. In order to get a
working 5.3.0 build, it is necessary to patch configure (since libtool is not
patched) to add the `-z relax=comdat` linker flag in all cases where GCC is
used with the Solaris linker.

I opened this here because patching libtool to add this flag seems incorrect.
The built xg++ compiler should not be generating code that causes the (now)
more strict linker to fail.

$ ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2329
$ as -V
as: Sun Compiler Common 12 SunOS_sparc s11_2sru04_1 09/30/2014
$ uname -a
SunOS xxx 5.11 11.2 sun4v sparc sun4v Solaris

From the man page:

     -z relax=item1,item2,...

         The link-editor performs validity  checks  in  order  to
         ensure  that  the  resulting  output object is valid and
         usable at runtime.  In  addition,  the  link-editor  can
         transition  a  variety  of  relocations to generate more
         optimal instruction sequences. The -z relax  option  can
         be  used to relax validity checking and relocation tran-
         sitions in order to produce an output object that  would
         otherwise be rejected.

         comdat

             The link-editor normally issues a fatal  error  upon
             encountering a relocation using a symbol that refer-
             ences  an   eliminated   COMDAT   section.   If   -z
             relax=comdat  is  enabled,  the  link-editor instead
             redirects such relocations to the equivalent  symbol
             in the COMDAT section that was kept.

Reply via email to