aboutsummaryrefslogtreecommitdiff
path: root/binutils/doc/binutils.texi
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2021-12-23 09:55:07 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-02-03 18:41:56 -0800
commitfd3c53675c01472caaa4eb976781b9d6d2d3c53d (patch)
treefbdc0290490829e5835d8da542470167b08cfdaf /binutils/doc/binutils.texi
parent78110c3f7743e8177859fb03db1aeaf327a51459 (diff)
downloadgdb-fd3c53675c01472caaa4eb976781b9d6d2d3c53d.zip
gdb-fd3c53675c01472caaa4eb976781b9d6d2d3c53d.tar.gz
gdb-fd3c53675c01472caaa4eb976781b9d6d2d3c53d.tar.bz2
Support symbol+offset lookup in addr2line
The Linux kernel usually ouputs symbol+offset instead of plain code addresses these days, to avoid leaking ASLR secrets and to handle dynamically loaded modules. Converting those with addr2line is somewhat involved: it requires looking up the symbol first using nm and then manually compute the offset, and then pass it to addr2line. This patch implements the necessary steps directly in addr2line, by looking up the symbol (with demangling if needed) and computing the offset. It's possible that a symbol is ambigious with a hex number. In this case it uses the symbol lookup if the string contains a +. When it isn't ambigious the + is optional.
Diffstat (limited to 'binutils/doc/binutils.texi')
-rw-r--r--binutils/doc/binutils.texi18
1 files changed, 11 insertions, 7 deletions
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 54845c5..288974b 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -118,7 +118,7 @@ Demangle encoded C++ symbols (on MS-DOS, this program is named
@code{cxxfilt})
@item addr2line
-Convert addresses into file names and line numbers
+Convert addresses or symbol+offset into file names and line numbers
@item windres
Manipulate Windows resources
@@ -146,7 +146,7 @@ in the section entitled ``GNU Free Documentation License''.
* strip:: Discard symbols
* c++filt:: Filter to demangle encoded C++ symbols
* cxxfilt: c++filt. MS-DOS name for c++filt
-* addr2line:: Convert addresses to file and line
+* addr2line:: Convert addresses or symbol+offset to file and line
* windmc:: Generator for Windows message resources
* windres:: Manipulate Windows resources
* dlltool:: Create files needed to build and use DLLs
@@ -3902,7 +3902,7 @@ c++filt @var{option} @var{symbol}
@kindex addr2line
@cindex address to file name and line number
-@c man title addr2line convert addresses into file names and line numbers
+@c man title addr2line convert addresses or symbol+offset into file names and line numbers
@smallexample
@c man begin SYNOPSIS addr2line
@@ -3923,8 +3923,8 @@ addr2line [@option{-a}|@option{--addresses}]
@c man begin DESCRIPTION addr2line
-@command{addr2line} translates addresses into file names and line numbers.
-Given an address in an executable or an offset in a section of a relocatable
+@command{addr2line} translates addresses or symbol+offset into file names and line numbers.
+Given an address or symbol+offset in an executable or an offset in a section of a relocatable
object, it uses the debugging information to figure out which file name and
line number are associated with it.
@@ -3934,11 +3934,11 @@ object to use is specified with the @option{-j} option.
@command{addr2line} has two modes of operation.
-In the first, hexadecimal addresses are specified on the command line,
+In the first, hexadecimal addresses or symbol+offset are specified on the command line,
and @command{addr2line} displays the file name and line number for each
address.
-In the second, @command{addr2line} reads hexadecimal addresses from
+In the second, @command{addr2line} reads hexadecimal addresses or symbol+offset from
standard input, and prints the file name and line number for each
address on standard output. In this mode, @command{addr2line} may be used
in a pipe to convert dynamically chosen addresses.
@@ -3975,6 +3975,10 @@ If the file name or function name can not be determined,
@command{addr2line} will print two question marks in their place. If the
line number can not be determined, @command{addr2line} will print 0.
+When symbol+offset is used, +offset is optional, except when the symbol
+is ambigious with a hex number. The resolved symbols can be mangled
+or unmangled, except unmangled symbols with + are not allowed.
+
@c man end
@c man begin OPTIONS addr2line