Fix discrepancies in nm's --line-number output by adding support for the DW_AT_specification DWARF Attttribute.

PR 25676
bfd	* dwarf2.c (struct varinfo): Add unit_offset field to record the
	location of the varinfo in the unit's debug info data.  Change the
	type of the stack field to a boolean.
	(lookup_var_by_offset): New function.  Returns the varinfo
	structure for the variable described at the given offset in the
	unit's debug info.
	(scan_unit_for_symbols): Add support for variables which have the
	DW_AT_specification attribute.

binutils* testsuite/binutils-all/dw4.s: New test source file.
	* testsuite/binutils-all/nm.exp: Run the new test.
This commit is contained in:
Nick Clifton
2020-03-19 16:55:13 +00:00
parent 3734bec833
commit f3a08f7778
5 changed files with 2107 additions and 18 deletions

View File

@@ -1,3 +1,9 @@
2020-03-19 Nick Clifton <nickc@redhat.com>
PR 25676
* testsuite/binutils-all/dw4.s: New test source file.
* testsuite/binutils-all/nm.exp: Run the new test.
2020-03-19 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (process_symbol_table): Use unsigned long for si.

File diff suppressed because it is too large Load Diff

View File

@@ -247,6 +247,53 @@ if [is_elf_format] {
remote_file host delete "tmpdir/nm-ver.o"
}
}
# PR binutils/25676
# Test nm --line-numbers on DWARF-4 debug info.
set testname "nm --line-numbers on DWARF-4 debug info"
# The RISCV target does not (currently) support .uleb128.
setup_xfail "riscv*-*-*"
# The SH targets complain that the pseudo-ops used to construct
# the DWARF data are misaligned.
setup_xfail "sh*-*-*"
# The pre-compiled dwarf info in dw4.s is not compatible with the
# ALPHA, HPPA, IA64 and MIPS targets.
setup_xfail "alpha*-*-*" "hppa*-*-*" "ia64*-*-*" "mips*-*-*"
# Assembling the source file triggers an ICE in the FT32 assembler.
# FIXME: Fix the ICE...
setup_xfail "ft32-*-*"
# The AVR, MSP430, NDS32, PRU and XTENSA targets do not assemble the
# (64-bit) source file.
setup_xfail "avr-*-*" "msp430-*-*" "nds32*-*-*" "pru-*-*" "xtensa-*-*"
if {![binutils_assemble $srcdir/$subdir/dw4.s tmpdir/dw4.o]} then {
fail "$testname (assembly)"
} else {
# The test source is only intended for 64-bit targets.
# FIXME: Create a 32-bit version of this test.
if {! [is_elf64 tmpdir/dw4.o]} {
unsupported "$testname (needs a 64-bit target)"
} else {
if [is_remote host] {
set tmpfile [remote_download host tmpdir/dw4r.o]
} else {
set tmpfile tmpdir/dw4.o
}
set got [binutils_run $NM "$NMFLAGS --line-numbers $tmpfile"]
if {! [regexp "g_my_externd_global.*tests/main.c:3" $got]} then {
fail "$testname (grep for externd global file/line)"
} else {
pass $testname
}
}
if { $verbose < 1 } {
remote_file host delete $tmpfile
}
}
}
# There are certainly other tests that could be run.