summaryrefslogtreecommitdiff
path: root/binutils/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2022-05-18 13:15:22 +0100
committerNick Clifton <nickc@redhat.com>2022-05-18 13:15:22 +0100
commit2c3cc81e068464b5a3d5bf19a9cf3cf3dd6b7b55 (patch)
tree5d5ae06c550788f2885c324e074395f6f10a971e /binutils/testsuite
parentc76d61da4a65eaadca861bf6c77d579a5cc3f422 (diff)
downloadbinutils-gdb-2c3cc81e068464b5a3d5bf19a9cf3cf3dd6b7b55.tar.gz
Add a --no-weak option to nm.
PR 29135 * nm.c (non_weak): New variable. (filter_symbols): When non-weak is true, ignore weak symbols. (long_options): Add --no-weak. (usage): Mention --no-weak. (main): Handle -W/--no-weak. * doc/binutils.texi: Document new feature. * NEWS: Mention the new feature. * testsuite/binutils-all/nm.exp: Add test of new feature. * testsuite/binutils-all/no-weak.s: New test source file.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r--binutils/testsuite/binutils-all/nm.exp32
-rw-r--r--binutils/testsuite/binutils-all/no-weak.s13
2 files changed, 44 insertions, 1 deletions
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
index 4560df16099..1c419df4d9a 100644
--- a/binutils/testsuite/binutils-all/nm.exp
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -340,7 +340,37 @@ if [is_elf_format] {
}
}
-
+ set testname "nm --no-weak"
+ if {![binutils_assemble $srcdir/$subdir/no-weak.s tmpdir/no-weak.o]} then {
+ fail "$testname (assembly)"
+ } else {
+ if [is_remote host] {
+ set tmpfile [remote_download host tmpdir/no-weak.o]
+ } else {
+ set tmpfile tmpdir/no-weak.o
+ }
+
+ set got [binutils_run $NM "$NMFLAGS --no-weak $tmpfile"]
+
+ if [regexp "weak_with_default_value" $got] then {
+ fail "$testname (weak symbol with default value)"
+ } else {
+ pass "$testname (weak symbol with default value)"
+ }
+
+ if [regexp "weak_without_default_value" $got] then {
+ fail "$testname (weak symbol without default value)"
+ } else {
+ pass "$testname (weak symbol without default value)"
+ }
+
+ # FIXME: We should re run this test without the --no-weak option
+ # and verify that the expected symbol names *are* shown...
+
+ if { $verbose < 1 } {
+ remote_file host delete "tmpdir/no0weak.o"
+ }
+ }
}
# There are certainly other tests that could be run.
diff --git a/binutils/testsuite/binutils-all/no-weak.s b/binutils/testsuite/binutils-all/no-weak.s
new file mode 100644
index 00000000000..a25454dd985
--- /dev/null
+++ b/binutils/testsuite/binutils-all/no-weak.s
@@ -0,0 +1,13 @@
+ .file "no-weak.c"
+ .text
+
+ .globl weak_with_default_value
+ .weak weak_with_default_value
+weak_with_default_value:
+ .nop
+
+ .data
+ .weak weak_without_default_value
+ .dc.a weak_without_default_value
+
+