Project

General

Profile

Actions

Bug #3436

closed

relocatable objects also need sloppy relocation

Added by Alasdair Lumsden over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2012-12-31
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

Hi,

We've been using gcc 4.4 with ec-userland over the past 2 years with no issue. Over Christmas I started work to update it to gcc 4.7.2. I got it all built, but unfortunately some software just wouldn't link with the code generated by the updated gcc, such as pcre:

CXXLD  libpcrecpp.la
ld: fatal: relocation error: R_386_GOTOFF: file .libs/libpcrecpp_la-pcre_scanner.o: section [170].rel.eh_frame: symbol .LFB930: symbol has been discarded with discarded section: [68].text._ZN7pcrecpp11StringPieceC2ERKSs

I get the same issue with gcc 4.6.2. I haven't tried gcc 4.5, but I have rebuilt gcc 4.4 and there are no issues with that. I've tried two different GNU as/binutil versions (2.20 and 2.23) and that made no difference - seems to be gcc specific.

It seems to be related to c++ code, and indeed gcc can't even build itself with the updated version:

/bin/sh ../libtool --tag CXX   --mode=link /ws/ec-userland/components/gcc46/build/i86/./gcc/xgcc -shared-libgcc -B/ws/ec-userland/components/gcc46/build/i86/./gcc -nostdinc++ -L/ws/ec-userland/components/gcc46/build/i86/i386-pc-solaris2.11/libstdc++-v3/src -L/ws/ec-userland/components/gcc46/build/i86/i386-pc-solaris2.11/libstdc++-v3/src/.libs -B/usr/i386-pc-solaris2.11/bin/ -B/usr/i386-pc-solaris2.11/lib/ -isystem /usr/i386-pc-solaris2.11/include -isystem /usr/i386-pc-solaris2.11/sys-include      -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual  -fdiagnostics-show-location=once  -ffunction-sections -fdata-sections   -o libstdc++.la -version-info 6:16:0 -Wl,-M,libstdc++-symbols.ver-sun -lm -rpath /usr/lib atomic.lo bitmap_allocator.lo pool_allocator.lo mt_allocator.lo codecvt.lo compatibility.lo compatibility-c++0x.lo compatibility-debug_list.lo compatibility-debug_list-2.lo compatibility-list.lo compatibility-list-2.lo complex_io.lo ctype.lo debug.lo functexcept.lo functional.lo globals_io.lo hash_c++0x.lo hash_tr1.lo hashtable_c++0x.lo hashtable_tr1.lo ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo locale.lo locale_init.lo locale_facets.lo localename.lo math_stubs_float.lo math_stubs_long_double.lo stdexcept.lo strstream.lo system_error.lo tree.lo istream.lo placeholders.lo regex.lo shared_ptr.lo streambuf.lo mutex.lo condition_variable.lo chrono.lo thread.lo future.lo valarray.lo atomicity.lo codecvt_members.lo collate_members.lo ctype_members.lo messages_members.lo monetary_members.lo numeric_members.lo time_members.lo basic_file.lo c++locale.lo allocator-inst.lo concept-inst.lo ext-inst.lo fstream-inst.lo ios-inst.lo iostream-inst.lo istream-inst.lo locale-inst.lo misc-inst.lo ostream-inst.lo sstream-inst.lo streambuf-inst.lo string-inst.lo wlocale-inst.lo wstring-inst.lo  parallel_settings.lo compatibility-parallel_list.lo compatibility-parallel_list-2.lo  ../libsupc++/libsupc++convenience.la 
libtool: link: /ws/ec-userland/components/gcc46/build/i86/./gcc/collect-ld -r -o .libs/libstdc++.la-1.o .libs/atomic.o .libs/bitmap_allocator.o .libs/pool_allocator.o .libs/mt_allocator.o .libs/codecvt.o .libs/compatibility.o .libs/compatibility-c++0x.o .libs/compatibility-debug_list.o .libs/compatibility-debug_list-2.o .libs/compatibility-list.o .libs/compatibility-list-2.o .libs/complex_io.o .libs/ctype.o .libs/debug.o .libs/functexcept.o .libs/functional.o .libs/globals_io.o .libs/hash_c++0x.o .libs/hash_tr1.o
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv (section): symbol has been discarded with discarded section: [40].text._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv (section): symbol has been discarded with discarded section: [42].text._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZN9__gnu_cxx24__concurrence_lock_errorD2Ev (section): symbol has been discarded with discarded section: [44].text._ZN9__gnu_cxx24__concurrence_lock_errorD2Ev
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZN9__gnu_cxx26__concurrence_unlock_errorD2Ev (section): symbol has been discarded with discarded section: [46].text._ZN9__gnu_cxx26__concurrence_unlock_errorD2Ev
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZN9__gnu_cxx24__concurrence_lock_errorD0Ev (section): symbol has been discarded with discarded section: [50].text._ZN9__gnu_cxx24__concurrence_lock_errorD0Ev
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev (section): symbol has been discarded with discarded section: [52].text._ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev
ld: fatal: relocation error: R_386_32: file .libs/pool_allocator.o: section [113].rel.debug_frame: symbol .text._ZN9__gnu_cxx13__scoped_lockD2Ev (section): symbol has been discarded with discarded section: [54].text._ZN9__gnu_cxx13__scoped_lockD2Ev
make[5]: *** [libstdc++.la] Error 1
make[5]: Leaving directory `/ws/ec-userland/components/gcc46/build/i86/i386-pc-solaris2.11/libstdc++-v3/src'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/ws/ec-userland/components/gcc46/build/i86/i386-pc-solaris2.11/libstdc++-v3'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/ws/ec-userland/components/gcc46/build/i86/i386-pc-solaris2.11/libstdc++-v3'
make[2]: *** [all-target-libstdc++-v3] Error 2
make[2]: Leaving directory `/ws/ec-userland/components/gcc46/build/i86'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/ws/ec-userland/components/gcc46/build/i86'
gmake: *** [/ws/ec-userland/components/gcc46/build/i86/.built] Error 2

The only thing I could really find on the subject that made any sense was this post by Rainer Orth about COMDAT:

http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01384.html

The post seems to be about Sun as, but we're using GNU as so I'm slightly confused, but it did mention this:

"After some discussion with the Sun assembler and linker maintainers, it was decided to work around this in Sun ld instead and relax a few checks there, too, to allow COMDAT with Sun as to work. The necessary support is included in ld 2.2267 (Solaris 11, build 164)."

I've attempted this with the Solaris 11 linker from build 175 (making sure to LD_PRELOAD libld.so.4 and libelf.so.1 from Solaris 11 too) and sure enough it links stuff just fine, and I can successfully build and link pcre and gcc with the newer gcc. GNU ld also works fine.

So it looks like our linker needs a prod.

Of course, I could also be doing something horribly stupid or wrong, so I'd be interested in hearing from anyone using a newer gcc with illumos (such as the OmniOS folk).

Cheers,

Alasdair


Files

pcre.txt (13.2 KB) pcre.txt here is a successful build of pkgsrc/devel/pcre Richard PALO, 2012-12-31 06:08 PM

Related issues

Related to illumos gate - Bug #3439: discarded sections shouldn't end up on output listsResolvedRich Lowe2013-01-01

Actions
Actions

Also available in: Atom PDF