forked from Imagelibrary/binutils-gdb
Fix line table regression
Simon pointed out a line table regression, and after a couple of false starts, I was able to reproduce it by hand using his instructions. The bug is that most of the code in do_mixed_source_and_assembly uses unrelocated addresses, but one spot does: pc = low; ... after the text offset has been removed. This patch fixes the problem by introducing a new type to represent unrelocated addresses in the line table. This prevents this sort of bug to some degree (it's still possible to manipulate a CORE_ADDR in a bad way, this is unavoidable). However, this did let the compiler flag a few spots in that function, and now it's not possible to compare an unrelocated address from a line table with an ordinary CORE_ADDR. Regression tested on x86-64 Fedora 36, though note this setup never reproduced the bug in the first place. I also tested it by hand on the disasm-optim test program.
This commit is contained in:
@@ -1130,9 +1130,10 @@ coff_symtab_read (minimal_symbol_reader &reader,
|
||||
of the closing '}', and for which we do not have any
|
||||
other statement-line-number. */
|
||||
if (fcn_last_line == 1)
|
||||
record_line (get_current_subfile (), fcn_first_line,
|
||||
gdbarch_addr_bits_remove (gdbarch,
|
||||
fcn_first_line_addr));
|
||||
record_line
|
||||
(get_current_subfile (), fcn_first_line,
|
||||
unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
|
||||
fcn_first_line_addr)));
|
||||
else
|
||||
enter_linenos (fcn_line_ptr, fcn_first_line,
|
||||
fcn_last_line, objfile);
|
||||
@@ -1460,7 +1461,8 @@ enter_linenos (file_ptr file_offset, int first_line,
|
||||
CORE_ADDR addr = lptr.l_addr.l_paddr;
|
||||
record_line (get_current_subfile (),
|
||||
first_line + L_LNNO32 (&lptr),
|
||||
gdbarch_addr_bits_remove (gdbarch, addr));
|
||||
unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
|
||||
addr)));
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user