diff options
author | Tom Tromey <tom@tromey.com> | 2023-03-16 14:41:31 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-03-17 16:17:43 -0600 |
commit | 48e0f38c30a153855e1adc9dc76614f3f88d686a (patch) | |
tree | fd93b0e93df5852cd5bfcb81e7854fa418234ffb /gdb/dbxread.c | |
parent | 152d9c48a29685752ce06a0248a3f0f490c5660a (diff) | |
download | fsf-binutils-gdb-48e0f38c30a153855e1adc9dc76614f3f88d686a.zip fsf-binutils-gdb-48e0f38c30a153855e1adc9dc76614f3f88d686a.tar.gz fsf-binutils-gdb-48e0f38c30a153855e1adc9dc76614f3f88d686a.tar.bz2 |
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.
Diffstat (limited to 'gdb/dbxread.c')
-rw-r--r-- | gdb/dbxread.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 1e88121..e5366cc 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2453,9 +2453,10 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name, { CORE_ADDR addr = last_function_start + valu; - record_line (get_current_subfile (), 0, - gdbarch_addr_bits_remove (gdbarch, addr) - - objfile->text_section_offset ()); + record_line + (get_current_subfile (), 0, + unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr) + - objfile->text_section_offset ())); } within_function = 0; @@ -2662,15 +2663,17 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name, CORE_ADDR addr = processing_gcc_compilation == 2 ? last_function_start : valu; - record_line (get_current_subfile (), desc, - gdbarch_addr_bits_remove (gdbarch, addr) - - objfile->text_section_offset ()); + record_line + (get_current_subfile (), desc, + unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr) + - objfile->text_section_offset ())); sline_found_in_function = 1; } else - record_line (get_current_subfile (), desc, - gdbarch_addr_bits_remove (gdbarch, valu) - - objfile->text_section_offset ()); + record_line + (get_current_subfile (), desc, + unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, valu) + - objfile->text_section_offset ())); break; case N_BCOMM: |