diff options
author | anton <anton@cvs.openbsd.org> | 2018-09-18 18:25:32 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2018-09-18 18:25:32 +0000 |
commit | 2bef9a6b1fc85fe4a1f9bfac1c99d1d35a063068 (patch) | |
tree | 2e612fa3e42d263439f4d63d80a1396642a351f6 | |
parent | 7224ddcf0cdb9004c6cecc2f9c66404ff0e5ea87 (diff) |
Backport support for option -a to addr2line, which will display each address
given as input before the resolved source location. This change was introduced
to bintutils after the switch from GPLv2 but the author Tristan Gingold granted
me permission relicense the diff under GPLv2; thanks!
Taken as is from binutils commit be6f64938f985dfb0eaa2107b99f193bb865ce04
This option is used by the syzkaller kernel fuzzer to produce a human readable
representation of the coverage collected by kcov.
ok deraadt@ jca@ visa@
-rw-r--r-- | gnu/usr.bin/binutils-2.17/binutils/addr2line.c | 15 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/binutils/doc/binutils.texi | 8 |
2 files changed, 21 insertions, 2 deletions
diff --git a/gnu/usr.bin/binutils-2.17/binutils/addr2line.c b/gnu/usr.bin/binutils-2.17/binutils/addr2line.c index 47367093140..5a8d42e1285 100644 --- a/gnu/usr.bin/binutils-2.17/binutils/addr2line.c +++ b/gnu/usr.bin/binutils-2.17/binutils/addr2line.c @@ -40,6 +40,7 @@ #include "budemang.h" static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */ +static bfd_boolean with_addresses; /* -a, show addresses. */ static bfd_boolean with_functions; /* -f, show function names. */ static bfd_boolean do_demangle; /* -C, demangle names. */ static bfd_boolean base_names; /* -s, strip directory names. */ @@ -51,6 +52,7 @@ static asymbol **syms; /* Symbol table. */ static struct option long_options[] = { + {"addresses", no_argument, NULL, 'a'}, {"basenames", no_argument, NULL, 's'}, {"demangle", optional_argument, NULL, 'C'}, {"exe", required_argument, NULL, 'e'}, @@ -80,6 +82,7 @@ usage (FILE *stream, int status) fprintf (stream, _(" If no addresses are specified on the command line, they will be read from stdin\n")); fprintf (stream, _(" The options are:\n\ @<file> Read options from <file>\n\ + -a --addresses Show addresses\n\ -b --target=<bfdname> Set the binary file format\n\ -e --exe=<executable> Set the input file name (default is a.out)\n\ -i --inlines Unwind inlined functions\n\ @@ -200,6 +203,13 @@ translate_addresses (bfd *abfd, asection *section) pc = bfd_scan_vma (*addr++, NULL, 16); } + if (with_addresses) + { + printf ("0x"); + bfd_printf_vma (abfd, pc); + printf ("\n"); + } + found = FALSE; if (section) find_offset_in_section (abfd, section); @@ -345,13 +355,16 @@ main (int argc, char **argv) file_name = NULL; section_name = NULL; target = NULL; - while ((c = getopt_long (argc, argv, "b:Ce:sfHhij:Vv", long_options, (int *) 0)) + while ((c = getopt_long (argc, argv, "ab:Ce:sfHhij:Vv", long_options, (int *) 0)) != EOF) { switch (c) { case 0: break; /* We've been given a long option. */ + case 'a': + with_addresses = TRUE; + break; case 'b': target = optarg; break; diff --git a/gnu/usr.bin/binutils-2.17/binutils/doc/binutils.texi b/gnu/usr.bin/binutils-2.17/binutils/doc/binutils.texi index 567954ced18..0668b85d933 100644 --- a/gnu/usr.bin/binutils-2.17/binutils/doc/binutils.texi +++ b/gnu/usr.bin/binutils-2.17/binutils/doc/binutils.texi @@ -2602,7 +2602,8 @@ c++filt @var{option} @var{symbol} @smallexample @c man begin SYNOPSIS addr2line -addr2line [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] +addr2line [@option{-a}|@option{--addresses}] + [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] [@option{-C}|@option{--demangle}[=@var{style}]] [@option{-e} @var{filename}|@option{--exe=}@var{filename}] [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] @@ -2653,6 +2654,11 @@ The long and short forms of options, shown here as alternatives, are equivalent. @table @env +@item -a +@itemx --addresses +Display the address before the function name, file and line number information. +The address is printed with a @samp{0x} prefix to easily identify it. + @item -b @var{bfdname} @itemx --target=@var{bfdname} @cindex object code format |