[addr2line] Printing symbol names

Alan Modra amodra@gmail.com
Mon Jun 24 11:57:41 GMT 2024


On Mon, Jun 24, 2024 at 09:29:34AM +0200, Jiří Wolker wrote:
> On 2024-06-24 v 2:27 Alan Modra wrote:
> > On Sun, Jun 23, 2024 at 03:49:07PM +0200, Jiří Wolker wrote:
> > > I can't find a way to print symbol names for non-functions using
> > > ‘addr2line’. It is possible to print function names, but this prints
> > > just ‘??’ for symbols in data sections.
> > 
> > Works for me.
> > $ binutils/addr2line --exe=gas/as.o --section=.data 8
> > /home/alan/src/binutils-gdb/gas/as.c:84
> > $ binutils/addr2line --exe=gas/as-new 0xa423f8
> > /home/alan/src/binutils-gdb/gas/as.c:84
> > 
> 
> I am talking about this feature (enabled by ‘-f’/‘--functions’:

Sorry, I didn't read your message carefully enough.  Implementing this
for data symbols might be possible, but you'd need to be willing to
write a non-trivial amount of code to add the support to
bfd_find_nearest_line.  It's not just a matter of reading symbol
tables and choosing the correct symbol (because symbol tables might be
incomplete), support for retrieving a name from debug info is needed.

> $ addr2line -pf --exe ./cc1plus 0000000002412ae0
> _Z9xrecallocPvmmm at /path/to/gcc/haifa-sched.cc:8081
> 
> It would be nice to have something that will print also data symbol names.
> For example, trying it with an address from .rodata:
> 
> $ addr2line -pf --exe ./cc1plus 00000000029553e0
> ?? at /path/to/gcc/cp/call.cc:2273
> $ nm ./cc1plus | grep 00000000029553e0
> 00000000029553e0 r
> _ZZL21add_ignored_candidatePP11z_candidateP9tree_nodeE14reason_ignored
> 
> In this case, I would expect the symbol name in place of ‘??’ (possibly
> after enabling that using some option).

-- 
Alan Modra


More information about the Binutils mailing list