Unfortunately https://github.com/bebbo/binutils-gdb/issues/21 did not fix all problems I experience with gdb. Namely there's a mismatch between relocated addresses and source lines. I cannot use list to display source code of many routines nor use breakpoint on symbols.
To better explain the problem let's use an example. Below you can find a piece of .stabs section for wireframe.o. As you can see Load function is defined in at address .text+0x1ca and UnLoad at .text+0x1ec.
(gdb) maintenance info line-table
...
INDEX LINE ADDRESS IS-STMT
0 23 0x00c7a4e2 Y
1 24 0x00c7a4e2 Y
2 25 0x00c7a4ec Y
3 26 0x00c7a4f6 Y
4 27 0x00c7a500 Y
5 29 0x00c7a706 Y
6 30 0x00c7a706 Y
7 31 0x00c7a710 Y
Expected output is:
(gdb) maintenance info line-table
...
INDEX LINE ADDRESS IS-STMT
0 23 0x00c7a4e2 Y
1 24 0x00c7a4e2 Y
2 25 0x00c7a4ec Y
3 26 0x00c7a4f6 Y
4 27 0x00c7a500 Y
5 29 0x00c7a504 Y
6 30 0x00c7a504 Y
7 31 0x00c7a50e Y
Please note that Load is the first function in .text section while UnLoad is the second. As one can see current version of gdb assigns address 0x00c7a706 to UnLoad (at line 29 of wireframe.c) instead of 0x00c7a504.
I've managed to patch it locally (works for me), but I don't know how the change can affect other users. Hence I decided to leave it up to you if that should be patched and how. Here's proposed change:
--- binutils-gdb.orig/gdb/dbxread.c
+++ binutils-gdb/gdb/dbxread.c
@@ -2581,7 +2581,7 @@ process_one_symbol (int type, int desc,
/* Relocate for dynamic loading and for ELF acc
function-relative symbols. */
- valu += function_start_offset;
+ /* valu += function_start_offset; */
/* GCC 2.95.3 emits the first N_SLINE stab somewhere in the
middle of the prologue instead of right at the start of the
Unfortunately https://github.com/bebbo/binutils-gdb/issues/21 did not fix all problems I experience with
gdb
. Namely there's a mismatch between relocated addresses and source lines. I cannot uselist
to display source code of many routines nor usebreakpoint
on symbols.To better explain the problem let's use an example. Below you can find a piece of
.stabs
section forwireframe.o
. As you can seeLoad
function is defined in at address.text+0x1ca
andUnLoad
at.text+0x1ec
.This is what https://github.com/bebbo/binutils-gdb/commit/4a73175ec833bf743fa4791a5d3d71f71836e600 displays when asked about line-to-address correspondence:
Expected output is:
Please note that
Load
is the first function in.text
section whileUnLoad
is the second. As one can see current version ofgdb
assigns address0x00c7a706
toUnLoad
(at line 29 ofwireframe.c
) instead of0x00c7a504
.I've managed to patch it locally (works for me), but I don't know how the change can affect other users. Hence I decided to leave it up to you if that should be patched and how. Here's proposed change: