Bug 200350 - elftoolchain incorrect strip(1) SHT_GROUP handling
Summary: elftoolchain incorrect strip(1) SHT_GROUP handling
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks: 198611
  Show dependency treegraph
 
Reported: 2015-05-20 15:15 UTC by Ed Maste
Modified: 2015-05-27 14:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2015-05-20 15:15:33 UTC
Opening a PR to track this issue specifically in FreeBSD; this is also https://sourceforge.net/p/elftoolchain/tickets/486/

In PR198611 it was reported that after the switch to ELF Tool Chain strip libtool no longer strips libraries.  Fixing that problem and allowing it to strip libs uncovered a number of problems, all of which are now addressed except for this one port failure in lang/gnatdroid-armv7.

The failure looks like:

g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -Ic-family -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/c-family -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/../include -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/../libcpp/include -I/usr/local/include -I/usr/local/include -I/usr/local/include  -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/../libdecnumber -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/../libdecnumber/dpd -I../libdecnumber -I/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/../libbacktrace    -o c-family/cppspec.o -MT c-family/cppspec.o -MMD -MP -MF c-family/.deps/cppspec.TPo /wrkdirs/usr/ports/lang/gnatdroid-armv7/work/gcc-4.9.2/gcc/c-family/cppspec.c
g++   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o cpp gcc.o ggc-none.o \
  c-family/cppspec.o  libcommon-target.a \
   libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a 
/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/build/./gcc/xgcc -B/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/build/./gcc/ -dumpspecs > tmp-specs
Makefile:1824: recipe for target 'specs' failed
gmake[3]: *** [specs] Segmentation fault (core dumped)
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gnatdroid-armv7/work/build/gcc'
Makefile:3971: recipe for target 'all-gcc' failed
gmake[2]: *** [all-gcc] Error 2

(see various logs linked from PR 198611 for more detail)

lang/gnatdroid-armv7 depends on:
feynman% make pretty-print-build-depends-list
This port requires package(s) "binutils-2.25 gcc-aux-20141023_1 gettext-runtime-0.19.4 gmake-4.1_2 gmp-5.1.3_2 gnatdroid-binutils-2.25 gnatdroid-sysroot-19_1 indexinfo-0.2.3 mpc-1.0.3 mpfr-3.1.2_2 perl5-5.20.2_4" to build.

It looks like lang/gcc-aux gets built with a corrupted libstdc++.a due to the various SHT_GROUP issues.  Prior to ELF Tool Chain commit r3207 gnatdroid-armv7 completely failed to build, but it now looks like it manages to build the cross-compiler, but it then crashes.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2015-05-20 17:18:34 UTC
New issues with upstream reports relating to elfcopy/strip and SHT_GROUP:

https://sourceforge.net/p/elftoolchain/tickets/494/
https://sourceforge.net/p/elftoolchain/tickets/495/
Comment 2 Ed Maste freebsd_committer freebsd_triage 2015-05-25 18:45:54 UTC
Upstream tickets 494 and 495 are now closed. Ticket 486 is believed fixed, but I'm waiting on the exp-run results for verification.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-05-27 14:28:27 UTC
A commit references this bug:

Author: emaste
Date: Wed May 27 14:28:22 UTC 2015
New revision: 283616
URL: https://svnweb.freebsd.org/changeset/base/283616

Log:
  Update to ELF Tool Chain r3223

  Highlights (upstream revisions):
   - Fix SHT_GROUP handling in elfcopy/strip (3206 3220 3221)
   - Misc elfcopy / strip bug fixes (3215 3216 3217)
   - Many C++ demangler improvements (3199 3200 3201 3202 3203 3204 3205
     3208 3210 3211 3212)
   - Improve GNU binutils compatibility in elfcopy / strip (3213 3214)
   - Add -g option to readelf(1): dump contents of section groups (3219)
   - Add EM_IAMCU 32-bit Intel MCU (3198)

  Also add a compat #define for building with older FreeBSD ELF headers.
  The GRP_COMDAT flag was added to elf_common.h in r283110, but it's not
  available during the bootstrap build.  It is also convenient to be able
  to build on older hosts.

  Thanks to antoine@ for tracking down issues through multiple exp-runs
  and to kaiw@ for fixing.

  PR:		198611 (exp-run), 200350
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  head/contrib/elftoolchain/
  head/contrib/elftoolchain/common/_elftc.h
  head/contrib/elftoolchain/common/elfdefinitions.h
  head/contrib/elftoolchain/elfcopy/elfcopy.h
  head/contrib/elftoolchain/elfcopy/main.c
  head/contrib/elftoolchain/elfcopy/sections.c
  head/contrib/elftoolchain/elfcopy/symbols.c
  head/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
  head/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  head/contrib/elftoolchain/libelftc/os.Linux.mk
  head/contrib/elftoolchain/readelf/readelf.1
  head/contrib/elftoolchain/readelf/readelf.c
  head/lib/libelftc/elftc_version.c
Comment 4 Ed Maste freebsd_committer freebsd_triage 2015-05-27 14:30:05 UTC
Fixed with ELF Tool Chain update to r3223.