This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH (libstdc++-v3): Enhance binutils/readelf portability
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Aug 2002 22:03:59 -0500 (CDT)
- Subject: PATCH (libstdc++-v3): Enhance binutils/readelf portability
- Reply-to: rittle at labs dot mot dot com
Rebuilt abi_check on i386-unknown-freebsd4.6 in already built tree.
Self-approved as non-controversial and installed. Tested against:
GNU readelf 2.13
GNU readelf 2.12.90 20020717
GNU readelf 2.12.1 20020517
GNU readelf 2.11.2 20010719 [FreeBSD]
(In all cases, same baseline as generated with 2.12.90 was used.)
`make check-abi' fails against readelf 2.11.2 and older without this
patch. FYI, I avoided both -q and -s with grep based on commentary
within the GNU grep man page.
* testsuite/abi_check.cc: Support older binutils/readelf.
Index: testsuite/abi_check.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/abi_check.cc,v
retrieving revision 1.2
diff -c -r1.2 abi_check.cc
*** testsuite/abi_check.cc 23 Aug 2002 01:50:15 -0000 1.2
--- testsuite/abi_check.cc 23 Aug 2002 02:47:52 -0000
***************
*** 236,243 ****
*/
const char quote = '"';
const char bslash = '\\';
ostringstream cmd;
! cmd << "readelf -s -W " << test_lib << " | sed '/" << bslash
<< ".dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' | "
<< "awk '{ if ($4 == " << quote << "FUNC" << quote << "|| $4 == "
<< quote << "NOTYPE" << quote << ") printf " << quote << "%s:%s"
--- 236,251 ----
*/
const char quote = '"';
const char bslash = '\\';
+
+ // GNU binutils, somewhere after version 2.11.2, requires -W/--wide
+ // to avoid default line truncation. -W is not supported and
+ // truncation did not occur by default before that point.
+ bool readelf_need_wide =
+ (system("readelf --help | grep -- --wide >/dev/null") == 0);
+
ostringstream cmd;
! cmd << "readelf -s " << (readelf_need_wide ? "-W " : "")
! << test_lib << " | sed '/" << bslash
<< ".dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' | "
<< "awk '{ if ($4 == " << quote << "FUNC" << quote << "|| $4 == "
<< quote << "NOTYPE" << quote << ") printf " << quote << "%s:%s"