This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Prune BFD warnings for unknown GNU properties
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Thu, 16 Aug 2018 09:48:10 -0700
- Subject: [PATCH] Prune BFD warnings for unknown GNU properties
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
When glibc is enabled with the new GNU_PROPERTY_X86_XXX bits:
https://groups.google.com/forum/#!topic/x86-64-abi/-D05GQ3kWrA
BFD will issue an unknown GNU property warning like
warning: tmpdir/ld1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
and ignore such GNU properties. This patch adds prune_warnings_property
to prune such warnings.
OK for master branch?
H.J.
---
binutils/
PR ld/23536
* testsuite/binutils-all/objcopy.exp (strip_test): Call
prune_warnings_property to prune BFD output.
(strip_test_with_saving_a_symbol): Likewise.
(objcopy_test_without_global_symbol): Likewise.
* testsuite/lib/binutils-common.exp (prune_warnings_property):
New proc.
ld/
PR ld/23536
* testsuite/ld-bootstrap/bootstrap.exp: Call
prune_warnings_property to prune BFD output.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/lib/ld-lib.exp (prune_warnings): Likewise.
* testsuite/ld-elf/shared.exp: Allow "\n" in linker warnings.
---
binutils/testsuite/binutils-all/objcopy.exp | 9 +++++++++
binutils/testsuite/lib/binutils-common.exp | 11 +++++++++++
ld/testsuite/ld-bootstrap/bootstrap.exp | 1 +
ld/testsuite/ld-elf/shared.exp | 4 ++--
ld/testsuite/ld-plugin/lto.exp | 1 +
ld/testsuite/lib/ld-lib.exp | 9 ++++++++-
6 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 8d8b39909e..49c956af08 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -440,6 +440,7 @@ proc strip_test { } {
remote_file build delete tmpdir/libstrip.a
set exec_output [binutils_run $AR "rc $archive ${objfile}"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
@@ -447,6 +448,7 @@ proc strip_test { } {
}
set exec_output [binutils_run $STRIP "-g $archive"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
@@ -454,6 +456,7 @@ proc strip_test { } {
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
unresolved "$test preserving OS/ABI"
@@ -488,12 +491,14 @@ proc strip_test { } {
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string match "*: no symbols*" $exec_output] {
fail $test
return
@@ -529,12 +534,14 @@ proc strip_test_with_saving_a_symbol { } {
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
&& ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
fail $test
@@ -1206,12 +1213,14 @@ proc objcopy_test_without_global_symbol { } {
}
set exec_output [binutils_run $OBJCOPY "$OBJCOPYFLAGS --strip-unneeded $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if ![string equal "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $objfile"]
+ set exec_output [prune_warnings_property $exec_output]
if {![regexp "no symbols" $exec_output]} {
fail $test
return
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 7de7d6796a..9bef6121bc 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -376,3 +376,14 @@ proc regexp_diff { file_1 file_2 args } {
return $differences
}
+
+# prune_warnings_property -- delete warnings for unknown GNU properties
+# from TEXT.
+#
+# An example is:
+# ld: warning: /lib64/ld-linux-x86-64.so.2: unsupported GNU_PROPERTY_TYPE (5) type : 0xc0010001
+proc prune_warnings_property { text } {
+ # The "\\1" is to try to preserve a "\n" but only if necessary.
+ regsub -all "(^|\n)(\[^\n\]*: warning:\[^\n\]*unsupported GNU_PROPERTY_TYPE\[^\n\]*\n?)+" $text "\\1" text
+ return $text
+}
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 5c79e0315c..f271c82259 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -168,6 +168,7 @@ foreach flags $test_flags {
if {"$do_strip" == "yes"} {
verbose -log "$strip tmpdir/ld1"
catch "exec $strip tmpdir/ld1" exec_output
+ set exec_output [prune_warnings_property $exec_output]
if ![string match "" $exec_output] then {
verbose -log "$exec_output"
fail $testname
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 7970fe99ef..cdb171d0d1 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -513,7 +513,7 @@ set build_tests {
"-shared" "-fPIC"
{beginwarn.c end.c}
{{readelf {-S --wide} libbarw.rd}
- {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}}
+ {warning "^.*beginwarn.c:7: warning: function foo is deprecated\n?$"}}
"libbarw.so" "c"}
{"Build hidden libbar.so"
"-shared" "-fPIC"
@@ -792,7 +792,7 @@ set run_tests [list \
[list "Run warn with versioned libfoo.so" \
"-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
{main.c} "warn" "warn.out" \
- "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \
+ "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated\n?$} ] \
[list "Run protected with versioned libfoo.so" \
"-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
{main.c} "protected" "normal.out" ] \
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 5c581e498a..73ed2bceea 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -515,6 +515,7 @@ if { [at_least_gcc_version 4 7] } {
|| [istarget "amd64-*-linux*"]) } {
set testname "PR ld/12365"
set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
+ set exec_output [prune_warnings_property $exec_output]
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
# Linker should catch the reference to undefined `my_bcopy'
# error caused by a GCC bug.
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 2e7d368ce9..98bd55f5b0 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1433,9 +1433,16 @@ if ![string length [info proc prune_warnings]] {
# This is from sun4's. Do it for all machines for now.
# The "\\1" is to try to preserve a "\n" but only if necessary.
regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
-
# It might be tempting to get carried away and delete blank lines, etc.
# Just delete *exactly* what we're ask to, and that's it.
+ set text [prune_warnings_property $text]
+ return $text
+ }
+} elseif { [info procs saved-prune_warnings] == [list] } {
+ rename prune_warnings saved-prune_warnings
+ proc prune_warnings { text } {
+ set text [saved-prune_warnings $text]
+ set text [prune_warnings_property $text]
return $text
}
}
--
2.17.1