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.
This commit is contained in:
Nick Clifton
2022-05-18 13:15:22 +01:00
parent c76d61da4a
commit 2c3cc81e06
6 changed files with 74 additions and 2 deletions

View File

@ -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.

View File

@ -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