Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1738677

Summary: dts9 rhel6 g++ creates reference to unresolvable hidden symbol _ZSt19__throw_ios_failurePKc
Product: Red Hat Developer Toolset Reporter: Frank Ch. Eigler <fche>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Alexandra Petlanová Hájková <ahajkova>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: DTS 4.1 RHEL 6CC: ahajkova, dsmith, jakub, law, mcermak, mnewsome, ohudlick, tborcin
Target Milestone: alpha   
Target Release: 9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: devtoolset-9-gcc-9.1.1-2.3.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-10 07:49:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
.o file being linked into soliv none

Description Frank Ch. Eigler 2019-08-07 20:27:09 UTC
Created attachment 1601561 [details]
.o file being linked into soliv

With prerelease dts9 rhel6 tooling:

devtoolset-9-gcc-c++-9.1.1-2.2.el6.x86_64
devtoolset-9-elfutils-0.176-5.el6.x86_64
devtoolset-9-binutils-2.32-9.el6.x86_64

building the dts9 dyninst-9.3.2 rhel6 srpm, fails:

cd /root/rpmbuild/BUILD/devtoolset-9-dyninst-9.3.2/dyninst-9.3.2/elf && /usr/bin/cmake -E cmake_link_script CMakeFiles/dynElf.dir/link.txt --verbose=1
/opt/rh/devtoolset-9/root/usr/bin/c++  -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -std=c++11  -fvisibility=hidden -fvisibility-inlines-hidden -W -Wall -Wpointer-arith -Wcast-qual -Woverloaded-virtual -Wcast-align -Wno-non-template-friend -Wno-unused-local-typedefs -Wno-deprecated-declarations   -Wl,--no-undefined  -shared -Wl,-soname,libdynElf.so.9.3 -o libdynElf.so.dts.9.3.2 CMakeFiles/dynElf.dir/src/Elf_X.C.o /usr/lib64/libelf.so.1 
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libdynElf.so.dts.9.3.2: hidden symbol `_ZSt19__throw_ios_failurePKc' isn't defined
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

Attaching the sole .o file that's the link input.  Note that it doesn't have a reference to that symbol!  Tracking down where that's from.

Comment 2 Marek Polacek 2019-08-07 20:38:22 UTC
I now realize this might be a similar bug to one I fixed a few years ago.  I even happen to have a verification script I wrote for it:

$ cat ./check-hidden.sh
#!/bin/bash
# Find STV_HIDDEN SHN_UNDEF symbols mixed with STV_DEFAULT definition.

readelf -Ws libstdc++_nonshared.a \
  | awk '{ if ($8 ~ /^_Z/ && (($6 == "HIDDEN" && $7 == "UND") || ($6 == "DEFAULT" && $7 != "UND"))) { printf "%s %s %s\n", $8, $6, $7 } }' \
  | LC_ALL=C sort -u > nonshared.symlist
awk '
  NR>1 && $1 == prev && $2 != prevvis { print prev }
  {prev=$1; prevvis=$2}
  ' nonshared.symlist

Running it on libstdc++_nonshared.a from DTS 8 yields nothing, but with DTS 9 gcc:

$ ./check-hidden.sh 
_ZNSt12future_errorC1ESt10error_code
_ZNSt12future_errorC2ESt10error_code
_ZNSt13__future_base11_State_base15_M_run_deferredEv
_ZSt19__throw_ios_failurePKc
_ZTSNSt13__future_base11_State_baseE

So this might be the issue.

Comment 3 Marek Polacek 2019-08-07 20:55:00 UTC
(That was Bug 1519073.)

Comment 4 Frank Ch. Eigler 2019-08-07 20:55:51 UTC
% readelf -Ws /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++_nonshared.a| grep _ZSt19__throw_ios_failurePKc
   134: 0000000000000000   154 FUNC    GLOBAL DEFAULT   64 _ZSt19__throw_ios_failurePKc
   140: 0000000000000000   174 FUNC    GLOBAL DEFAULT   67 _ZSt19__throw_ios_failurePKci
     9: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN   UND _ZSt19__throw_ios_failurePKc

Comment 5 Marek Polacek 2019-08-09 19:44:31 UTC
I hope this will fix it:

--- gcc-9.1.1-20190605.patch/libstdc++-v3/src/nonshared11/compatibility-thread-c++0x.cc	2019-08-09 15:41:07.291603397 -0400
+++ gcc-9.1.1-20190605/libstdc++-v3/src/nonshared11/compatibility-thread-c++0x.cc	2019-08-09 15:29:14.790056479 -0400
@@ -37,3 +37,5 @@ asm (".hidden _ZZSt9call_onceIMSt6thread
 asm (".hidden _ZZSt9call_onceIMSt6threadFvvEJPS0_EEvRSt9once_flagOT_DpOT0_ENUlvE0_4_FUNEv");
 asm (".hidden _ZNSt13__future_base19_Async_state_common15_M_run_deferredEv"); 
 asm (".hidden _ZNSt13__future_base7_ResultIvE10_M_destroyEv");
+asm (".hidden _ZNSt13__future_base11_State_base15_M_run_deferredEv");
+asm (".hidden _ZTSNSt13__future_base11_State_baseE");
--- gcc-9.1.1-20190605.patch/libstdc++-v3/src/nonshared11/cxx11-ios_failure.cc	2019-08-09 15:41:07.268603031 -0400
+++ gcc-9.1.1-20190605/libstdc++-v3/src/nonshared11/cxx11-ios_failure.cc	2019-08-09 14:13:23.981785422 -0400
@@ -34,3 +34,4 @@ asm (".hidden _ZTSSt13__ios_failure");
 asm (".hidden _ZTSSt19__iosfail_type_info");
 asm (".hidden _ZTVSt13__ios_failure");
 asm (".hidden _ZTVSt19__iosfail_type_info");
+asm (".hidden _ZSt19__throw_ios_failurePKc");
--- gcc-9.1.1-20190605.patch/libstdc++-v3/src/nonshared11/functexcept.cc	2019-08-09 15:41:07.310603699 -0400
+++ gcc-9.1.1-20190605/libstdc++-v3/src/nonshared11/functexcept.cc	2019-08-09 14:32:26.645609903 -0400
@@ -68,5 +68,3 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
-asm (".hidden _ZNSt12future_errorC1ESt10error_code");
-asm (".hidden _ZNSt12future_errorC2ESt10error_code");
--- gcc-9.1.1-20190605.patch/libstdc++-v3/src/nonshared11/future.cc	2019-08-09 15:41:07.266603000 -0400
+++ gcc-9.1.1-20190605/libstdc++-v3/src/nonshared11/future.cc	2019-08-09 15:29:11.929010029 -0400
@@ -24,11 +24,11 @@
 #undef _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE
 #include "../c++11/future.cc"
 const std::error_category* _ZSt15future_category = &__future_category_instance();
-asm (".hidden _ZNSt13__future_base11_State_base15_M_run_deferredEv");
-asm (".hidden _ZTSNSt13__future_base11_State_baseE");
 asm (".hidden _ZTSNSt13__future_base12_Result_baseE");
 asm (".hidden _ZNSt15_Sp_counted_ptrIDnLN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv");
 asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv");
 asm (".hidden _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv");
 asm (".hidden _ZSt16__at_thread_exitPSt20__at_thread_exit_elt");
 asm (".hidden _ZNSt13__future_base13_State_baseV211_Make_ready6_S_runEPv");
+asm (".hidden _ZNSt12future_errorC1ESt10error_code");
+asm (".hidden _ZNSt12future_errorC2ESt10error_code");
--- gcc-9.1.1-20190605.patch/libstdc++-v3/src/nonshared11/ios.cc	2019-08-09 15:41:07.294603444 -0400
+++ gcc-9.1.1-20190605/libstdc++-v3/src/nonshared11/ios.cc	2019-08-09 14:13:22.038752367 -0400
@@ -28,5 +28,3 @@
 
 #define _GLIBCXX_NONSHARED_CXX11
 #include "../c++11/ios.cc"
-
-asm (".hidden _ZSt19__throw_ios_failurePKc");

Comment 6 Marek Polacek 2019-08-10 19:35:25 UTC
Reproduced with devtoolset-9-gcc-9.1.1-2.2.el6.x86_64:

make[2]: Entering directory `/root/rpmbuild/BUILD/devtoolset-9-dyninst-9.3.2/dyninst-9.3.2'
Linking CXX shared library libdynElf.so
cd /root/rpmbuild/BUILD/devtoolset-9-dyninst-9.3.2/dyninst-9.3.2/elf && /usr/bin/cmake -E cmake_link_script CMakeFiles/dynElf.dir/link.txt --verbose=1
/opt/rh/devtoolset-9/root/usr/bin/c++  -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -std=c++11  -fvisibility=hidden -fvisibility-inlines-hidden -W -Wall -Wpointer-arith -Wcast-qual -Woverloaded-virtual -Wcast-align -Wno-non-template-friend -Wno-unused-local-typedefs -Wno-deprecated-declarations   -Wl,--no-undefined  -shared -Wl,-soname,libdynElf.so.9.3 -o libdynElf.so.dts.9.3.2 CMakeFiles/dynElf.dir/src/Elf_X.C.o /usr/lib64/libelf.so.1 
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libdynElf.so.dts.9.3.2: hidden symbol `_ZSt19__throw_ios_failurePKc' isn't defined
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [elf/libdynElf.so.dts.9.3.2] Error 1
make[2]: Leaving directory `/root/rpmbuild/BUILD/devtoolset-9-dyninst-9.3.2/dyninst-9.3.2'
make[1]: *** [elf/CMakeFiles/dynElf.dir/all] Error 2
make[1]: Leaving directory `/root/rpmbuild/BUILD/devtoolset-9-dyninst-9.3.2/dyninst-9.3.2'
make: *** [all] Error 2

With devtoolset-9-gcc-9.1.1-2.3.el6.x86_64 the build went fine:

Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-9.3.2-6.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-doc-9.3.2-6.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-devel-9.3.2-6.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-static-9.3.2-6.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-testsuite-9.3.2-6.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/devtoolset-9-dyninst-debuginfo-9.3.2-6.el6.x86_64.rpm

and check-hidden.sh issues no symbols now.

Comment 11 errata-xmlrpc 2019-12-10 07:49:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2019:4134