Add the ability for nm to display symbol version information.

PR binutils/20751
	* nm.c (with_symbol_versions): New local variable.
	(long_options): Add --with-symbol-versions.
	(usage): Mention --with-symbol-versions.
	(print_symbol): If with_symbol_versions is set then display the
	version information associated with the symbol.
	* NEWS: Mention the new feature.
	* doc/binutils.texi (nm): Document the new option.
	(objdump): Describe how symbol version information is displayed
	for dynamic symbol dumps.
	(readelf): Describe how symbol version information is displayed.
	* testsuite/binutils-all/nm.exp: Add a test of the new feature.
This commit is contained in:
Nick Clifton
2016-11-11 11:49:45 +00:00
parent 74f5402d08
commit df2c87b580
6 changed files with 99 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
.symver foo_old,foo@VER_1
.hidden foo_old
foo_old:
.dc.b 0
.symver foo_new,foo@@VER_2
.global foo_new
foo_new:
.dc.b 0

View File

@@ -207,4 +207,35 @@ if [regexp $want $got] then {
fail "nm --size-sort"
}
if [is_elf_format] {
# PR binutils/20751
# Test nm --with-symbol-versions
if {![binutils_assemble $srcdir/$subdir/nm-ver.s tmpdir/nm-ver.o]} then {
fail "nm --with-symbol-versions (assembling)"
} else {
if [is_remote host] {
set tmpfile [remote_download host tmpdir/nm-ver.o]
} else {
set tmpfile tmpdir/nm-ver.o
}
set got [binutils_run $NM "$NMFLAGS --with-symbol-versions --format sysv $tmpfile"]
if {! [regexp "foo@VER_1" $got]} then {
fail "nm --with-symbol-versions (grep for @VER_1)"
} else {
if {! [regexp "foo@VER_1" $got]} then {
fail "nm --with-symbol-versions (grep for @@VER_2)"
} else {
pass "nm --with-symbol-versions"
}
}
if { $verbose < 1 } {
remote_file host delete "tmpdir/nm-ver.o"
}
}
}
# There are certainly other tests that could be run.