1999-05-03 15:29:11 +08:00
|
|
|
|
/* addr2line.c -- convert addresses to line number and function name
|
2022-01-02 06:30:17 +08:00
|
|
|
|
Copyright (C) 1997-2022 Free Software Foundation, Inc.
|
2000-08-22 04:30:04 +08:00
|
|
|
|
Contributed by Ulrich Lauther <Ulrich.Lauther@mchp.siemens.de>
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GNU Binutils.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-06 00:54:46 +08:00
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2007-07-06 00:54:46 +08:00
|
|
|
|
Foundation, 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA. */
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-22 04:30:04 +08:00
|
|
|
|
/* Derived from objdump.c and nm.c by Ulrich.Lauther@mchp.siemens.de
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-05-20 00:17:54 +08:00
|
|
|
|
Usage:
|
1999-05-03 15:29:11 +08:00
|
|
|
|
addr2line [options] addr addr ...
|
|
|
|
|
or
|
2002-05-20 00:17:54 +08:00
|
|
|
|
addr2line [options]
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
both forms write results to stdout, the second form reads addresses
|
|
|
|
|
to be converted from stdin. */
|
|
|
|
|
|
2007-04-26 22:47:00 +08:00
|
|
|
|
#include "sysdep.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#include "bfd.h"
|
|
|
|
|
#include "getopt.h"
|
|
|
|
|
#include "libiberty.h"
|
|
|
|
|
#include "demangle.h"
|
|
|
|
|
#include "bucomm.h"
|
2011-03-31 00:09:40 +08:00
|
|
|
|
#include "elf-bfd.h"
|
2021-12-24 01:55:07 +08:00
|
|
|
|
#include "safe-ctype.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
static bool unwind_inlines; /* -i, unwind inlined functions. */
|
|
|
|
|
static bool with_addresses; /* -a, show addresses. */
|
|
|
|
|
static bool with_functions; /* -f, show function names. */
|
|
|
|
|
static bool do_demangle; /* -C, demangle names. */
|
|
|
|
|
static bool pretty_print; /* -p, print on one line. */
|
|
|
|
|
static bool base_names; /* -s, strip directory names. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2018-12-07 19:32:55 +08:00
|
|
|
|
/* Flags passed to the name demangler. */
|
|
|
|
|
static int demangle_flags = DMGL_PARAMS | DMGL_ANSI;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static int naddr; /* Number of addresses to process. */
|
|
|
|
|
static char **addr; /* Hex addresses to process. */
|
|
|
|
|
|
2021-12-24 01:55:07 +08:00
|
|
|
|
static long symcount;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static asymbol **syms; /* Symbol table. */
|
|
|
|
|
|
|
|
|
|
static struct option long_options[] =
|
|
|
|
|
{
|
2009-12-09 20:58:23 +08:00
|
|
|
|
{"addresses", no_argument, NULL, 'a'},
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{"basenames", no_argument, NULL, 's'},
|
2000-07-21 02:02:56 +08:00
|
|
|
|
{"demangle", optional_argument, NULL, 'C'},
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{"exe", required_argument, NULL, 'e'},
|
|
|
|
|
{"functions", no_argument, NULL, 'f'},
|
2005-05-24 01:45:42 +08:00
|
|
|
|
{"inlines", no_argument, NULL, 'i'},
|
2009-12-11 00:12:33 +08:00
|
|
|
|
{"pretty-print", no_argument, NULL, 'p'},
|
2018-12-07 19:32:55 +08:00
|
|
|
|
{"recurse-limit", no_argument, NULL, 'R'},
|
|
|
|
|
{"recursion-limit", no_argument, NULL, 'R'},
|
|
|
|
|
{"no-recurse-limit", no_argument, NULL, 'r'},
|
|
|
|
|
{"no-recursion-limit", no_argument, NULL, 'r'},
|
2006-04-06 00:12:01 +08:00
|
|
|
|
{"section", required_argument, NULL, 'j'},
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{"target", required_argument, NULL, 'b'},
|
|
|
|
|
{"help", no_argument, NULL, 'H'},
|
|
|
|
|
{"version", no_argument, NULL, 'V'},
|
|
|
|
|
{0, no_argument, 0, 0}
|
|
|
|
|
};
|
|
|
|
|
|
2003-09-14 20:20:17 +08:00
|
|
|
|
static void usage (FILE *, int);
|
|
|
|
|
static void slurp_symtab (bfd *);
|
|
|
|
|
static void find_address_in_section (bfd *, asection *, void *);
|
2006-04-06 00:12:01 +08:00
|
|
|
|
static void find_offset_in_section (bfd *, asection *);
|
|
|
|
|
static void translate_addresses (bfd *, asection *);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Print a usage message to STREAM and exit with STATUS. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-14 20:20:17 +08:00
|
|
|
|
usage (FILE *stream, int status)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-01-24 00:12:56 +08:00
|
|
|
|
fprintf (stream, _("Usage: %s [option(s)] [addr(s)]\n"), program_name);
|
|
|
|
|
fprintf (stream, _(" Convert addresses into line number/file name pairs.\n"));
|
|
|
|
|
fprintf (stream, _(" If no addresses are specified on the command line, they will be read from stdin\n"));
|
|
|
|
|
fprintf (stream, _(" The options are:\n\
|
2005-10-04 03:37:44 +08:00
|
|
|
|
@<file> Read options from <file>\n\
|
2009-12-09 20:58:23 +08:00
|
|
|
|
-a --addresses Show addresses\n\
|
2002-01-24 00:12:56 +08:00
|
|
|
|
-b --target=<bfdname> Set the binary file format\n\
|
|
|
|
|
-e --exe=<executable> Set the input file name (default is a.out)\n\
|
2006-04-06 00:12:01 +08:00
|
|
|
|
-i --inlines Unwind inlined functions\n\
|
|
|
|
|
-j --section=<name> Read section-relative offsets instead of addresses\n\
|
2009-12-11 00:12:33 +08:00
|
|
|
|
-p --pretty-print Make the output easier to read for humans\n\
|
2002-01-24 00:12:56 +08:00
|
|
|
|
-s --basenames Strip directory names\n\
|
|
|
|
|
-f --functions Show function names\n\
|
|
|
|
|
-C --demangle[=style] Demangle function names\n\
|
2018-12-07 19:32:55 +08:00
|
|
|
|
-R --recurse-limit Enable a limit on recursion whilst demangling. [Default]\n\
|
|
|
|
|
-r --no-recurse-limit Disable a limit on recursion whilst demangling\n\
|
2002-01-24 00:12:56 +08:00
|
|
|
|
-h --help Display this information\n\
|
|
|
|
|
-v --version Display the program's version\n\
|
|
|
|
|
\n"));
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
list_supported_targets (program_name, stream);
|
2007-02-17 21:33:57 +08:00
|
|
|
|
if (REPORT_BUGS_TO[0] && status == 0)
|
2000-04-04 22:32:35 +08:00
|
|
|
|
fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
exit (status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read in the symbol table. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-14 20:20:17 +08:00
|
|
|
|
slurp_symtab (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2009-10-01 14:33:15 +08:00
|
|
|
|
long storage;
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
bool dynamic = false;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if ((bfd_get_file_flags (abfd) & HAS_SYMS) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-10-01 14:33:15 +08:00
|
|
|
|
storage = bfd_get_symtab_upper_bound (abfd);
|
|
|
|
|
if (storage == 0)
|
|
|
|
|
{
|
|
|
|
|
storage = bfd_get_dynamic_symtab_upper_bound (abfd);
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
dynamic = true;
|
2009-10-01 14:33:15 +08:00
|
|
|
|
}
|
|
|
|
|
if (storage < 0)
|
|
|
|
|
bfd_fatal (bfd_get_filename (abfd));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-10-01 14:33:15 +08:00
|
|
|
|
syms = (asymbol **) xmalloc (storage);
|
|
|
|
|
if (dynamic)
|
|
|
|
|
symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
|
|
|
|
|
else
|
|
|
|
|
symcount = bfd_canonicalize_symtab (abfd, syms);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (symcount < 0)
|
|
|
|
|
bfd_fatal (bfd_get_filename (abfd));
|
2013-03-16 00:25:00 +08:00
|
|
|
|
|
|
|
|
|
/* If there are no symbols left after canonicalization and
|
|
|
|
|
we have not tried the dynamic symbols then give them a go. */
|
|
|
|
|
if (symcount == 0
|
|
|
|
|
&& ! dynamic
|
|
|
|
|
&& (storage = bfd_get_dynamic_symtab_upper_bound (abfd)) > 0)
|
|
|
|
|
{
|
|
|
|
|
free (syms);
|
|
|
|
|
syms = xmalloc (storage);
|
|
|
|
|
symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
|
|
|
|
|
}
|
2015-01-27 23:49:12 +08:00
|
|
|
|
|
|
|
|
|
/* PR 17512: file: 2a1d3b5b.
|
|
|
|
|
Do not pretend that we have some symbols when we don't. */
|
|
|
|
|
if (symcount <= 0)
|
|
|
|
|
{
|
|
|
|
|
free (syms);
|
|
|
|
|
syms = NULL;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* These global variables are used to pass information between
|
|
|
|
|
translate_addresses and find_address_in_section. */
|
|
|
|
|
|
|
|
|
|
static bfd_vma pc;
|
|
|
|
|
static const char *filename;
|
|
|
|
|
static const char *functionname;
|
|
|
|
|
static unsigned int line;
|
2012-07-25 05:06:58 +08:00
|
|
|
|
static unsigned int discriminator;
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
static bool found;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Look for an address in a section. This is called via
|
|
|
|
|
bfd_map_over_sections. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-14 20:20:17 +08:00
|
|
|
|
find_address_in_section (bfd *abfd, asection *section,
|
|
|
|
|
void *data ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
bfd_vma vma;
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
return;
|
|
|
|
|
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 18:55:17 +08:00
|
|
|
|
if ((bfd_section_flags (section) & SEC_ALLOC) == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 18:55:17 +08:00
|
|
|
|
vma = bfd_section_vma (section);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (pc < vma)
|
|
|
|
|
return;
|
|
|
|
|
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 18:55:17 +08:00
|
|
|
|
size = bfd_section_size (section);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (pc >= vma + size)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-07-25 05:06:58 +08:00
|
|
|
|
found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc - vma,
|
|
|
|
|
&filename, &functionname,
|
|
|
|
|
&line, &discriminator);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-06 00:12:01 +08:00
|
|
|
|
/* Look for an offset in a section. This is directly called. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
find_offset_in_section (bfd *abfd, asection *section)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
return;
|
|
|
|
|
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 18:55:17 +08:00
|
|
|
|
if ((bfd_section_flags (section) & SEC_ALLOC) == 0)
|
2006-04-06 00:12:01 +08:00
|
|
|
|
return;
|
|
|
|
|
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 18:55:17 +08:00
|
|
|
|
size = bfd_section_size (section);
|
2006-04-06 00:12:01 +08:00
|
|
|
|
if (pc >= size)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-07-25 05:06:58 +08:00
|
|
|
|
found = bfd_find_nearest_line_discriminator (abfd, section, syms, pc,
|
|
|
|
|
&filename, &functionname,
|
|
|
|
|
&line, &discriminator);
|
2006-04-06 00:12:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-24 01:55:07 +08:00
|
|
|
|
/* Lookup a symbol with offset in symbol table. */
|
|
|
|
|
|
|
|
|
|
static bfd_vma
|
|
|
|
|
lookup_symbol (bfd *abfd, char *sym, size_t offset)
|
|
|
|
|
{
|
|
|
|
|
long i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < symcount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (syms[i]->name, sym))
|
|
|
|
|
return syms[i]->value + offset + bfd_asymbol_section (syms[i])->vma;
|
|
|
|
|
}
|
|
|
|
|
/* Try again mangled */
|
|
|
|
|
for (i = 0; i < symcount; i++)
|
|
|
|
|
{
|
|
|
|
|
char *d = bfd_demangle (abfd, syms[i]->name, demangle_flags);
|
|
|
|
|
bool match = d && !strcmp (d, sym);
|
|
|
|
|
free (d);
|
|
|
|
|
|
|
|
|
|
if (match)
|
|
|
|
|
return syms[i]->value + offset + bfd_asymbol_section (syms[i])->vma;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Split an symbol+offset expression. adr is modified. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
is_symbol (char *adr, char **symp, size_t *offset)
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
|
|
|
|
|
while (ISSPACE (*adr))
|
|
|
|
|
adr++;
|
|
|
|
|
if (ISDIGIT (*adr) || *adr == 0)
|
|
|
|
|
return false;
|
|
|
|
|
/* Could be either symbol or hex number. Check if it has +. */
|
|
|
|
|
if (TOUPPER(*adr) >= 'A' && TOUPPER(*adr) <= 'F' && !strchr (adr, '+'))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*symp = adr;
|
|
|
|
|
while (*adr && !ISSPACE (*adr) && *adr != '+')
|
|
|
|
|
adr++;
|
|
|
|
|
end = adr;
|
|
|
|
|
while (ISSPACE (*adr))
|
|
|
|
|
adr++;
|
|
|
|
|
*offset = 0;
|
|
|
|
|
if (*adr == '+')
|
|
|
|
|
{
|
|
|
|
|
adr++;
|
|
|
|
|
*offset = strtoul(adr, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
*end = 0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read hexadecimal or symbolic with offset addresses from stdin, translate into
|
1999-05-03 15:29:11 +08:00
|
|
|
|
file_name:line_number and optionally function name. */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-04-06 00:12:01 +08:00
|
|
|
|
translate_addresses (bfd *abfd, asection *section)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
int read_stdin = (naddr == 0);
|
2021-12-24 01:55:07 +08:00
|
|
|
|
char *adr;
|
|
|
|
|
char addr_hex[100];
|
|
|
|
|
char *symp;
|
|
|
|
|
size_t offset;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (read_stdin)
|
|
|
|
|
{
|
|
|
|
|
if (fgets (addr_hex, sizeof addr_hex, stdin) == NULL)
|
|
|
|
|
break;
|
2021-12-24 01:55:07 +08:00
|
|
|
|
adr = addr_hex;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (naddr <= 0)
|
|
|
|
|
break;
|
|
|
|
|
--naddr;
|
2021-12-24 01:55:07 +08:00
|
|
|
|
adr = *addr++;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-24 01:55:07 +08:00
|
|
|
|
if (is_symbol (adr, &symp, &offset))
|
|
|
|
|
pc = lookup_symbol (abfd, symp, offset);
|
|
|
|
|
else
|
|
|
|
|
pc = bfd_scan_vma (adr, NULL, 16);
|
2012-06-01 09:04:29 +08:00
|
|
|
|
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
|
|
|
|
{
|
|
|
|
|
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
|
|
|
bfd_vma sign = (bfd_vma) 1 << (bed->s->arch_size - 1);
|
|
|
|
|
|
|
|
|
|
pc &= (sign << 1) - 1;
|
|
|
|
|
if (bed->sign_extend_vma)
|
|
|
|
|
pc = (pc ^ sign) - sign;
|
|
|
|
|
}
|
2011-03-31 00:09:40 +08:00
|
|
|
|
|
2009-12-09 20:58:23 +08:00
|
|
|
|
if (with_addresses)
|
|
|
|
|
{
|
|
|
|
|
printf ("0x");
|
|
|
|
|
bfd_printf_vma (abfd, pc);
|
2009-12-11 00:12:33 +08:00
|
|
|
|
|
|
|
|
|
if (pretty_print)
|
|
|
|
|
printf (": ");
|
|
|
|
|
else
|
|
|
|
|
printf ("\n");
|
2009-12-09 20:58:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
found = false;
|
2006-04-06 00:12:01 +08:00
|
|
|
|
if (section)
|
|
|
|
|
find_offset_in_section (abfd, section);
|
|
|
|
|
else
|
|
|
|
|
bfd_map_over_sections (abfd, find_address_in_section, NULL);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if (! found)
|
|
|
|
|
{
|
|
|
|
|
if (with_functions)
|
2013-01-18 21:14:35 +08:00
|
|
|
|
{
|
|
|
|
|
if (pretty_print)
|
|
|
|
|
printf ("?? ");
|
|
|
|
|
else
|
|
|
|
|
printf ("??\n");
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
printf ("??:0\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-11 00:12:33 +08:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (with_functions)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
char *alloc = NULL;
|
|
|
|
|
|
|
|
|
|
name = functionname;
|
|
|
|
|
if (name == NULL || *name == '\0')
|
|
|
|
|
name = "??";
|
|
|
|
|
else if (do_demangle)
|
|
|
|
|
{
|
2018-12-07 19:32:55 +08:00
|
|
|
|
alloc = bfd_demangle (abfd, name, demangle_flags);
|
2009-12-11 00:12:33 +08:00
|
|
|
|
if (alloc != NULL)
|
|
|
|
|
name = alloc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf ("%s", name);
|
|
|
|
|
if (pretty_print)
|
2011-10-13 23:33:34 +08:00
|
|
|
|
/* Note for translators: This printf is used to join the
|
|
|
|
|
function name just printed above to the line number/
|
|
|
|
|
file name pair that is about to be printed below. Eg:
|
|
|
|
|
|
|
|
|
|
foo at 123:bar.c */
|
2009-12-11 00:12:33 +08:00
|
|
|
|
printf (_(" at "));
|
|
|
|
|
else
|
|
|
|
|
printf ("\n");
|
|
|
|
|
|
2020-05-20 21:18:41 +08:00
|
|
|
|
free (alloc);
|
2009-12-11 00:12:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (base_names && filename != NULL)
|
|
|
|
|
{
|
|
|
|
|
char *h;
|
|
|
|
|
|
|
|
|
|
h = strrchr (filename, '/');
|
|
|
|
|
if (h != NULL)
|
|
|
|
|
filename = h + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-01 09:04:29 +08:00
|
|
|
|
printf ("%s:", filename ? filename : "??");
|
|
|
|
|
if (line != 0)
|
2012-07-25 05:06:58 +08:00
|
|
|
|
{
|
|
|
|
|
if (discriminator != 0)
|
|
|
|
|
printf ("%u (discriminator %u)\n", line, discriminator);
|
|
|
|
|
else
|
|
|
|
|
printf ("%u\n", line);
|
|
|
|
|
}
|
2012-06-01 09:04:29 +08:00
|
|
|
|
else
|
|
|
|
|
printf ("?\n");
|
2009-12-11 00:12:33 +08:00
|
|
|
|
if (!unwind_inlines)
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
found = false;
|
2009-12-11 00:12:33 +08:00
|
|
|
|
else
|
2011-10-13 23:33:34 +08:00
|
|
|
|
found = bfd_find_inliner_info (abfd, &filename, &functionname,
|
|
|
|
|
&line);
|
2009-12-11 00:12:33 +08:00
|
|
|
|
if (! found)
|
|
|
|
|
break;
|
|
|
|
|
if (pretty_print)
|
2011-10-13 23:33:34 +08:00
|
|
|
|
/* Note for translators: This printf is used to join the
|
|
|
|
|
line number/file name pair that has just been printed with
|
|
|
|
|
the line number/file name pair that is going to be printed
|
|
|
|
|
by the next iteration of the while loop. Eg:
|
|
|
|
|
|
|
|
|
|
123:bar.c (inlined by) 456:main.c */
|
2009-12-11 00:12:33 +08:00
|
|
|
|
printf (_(" (inlined by) "));
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fflush() is essential for using this command as a server
|
|
|
|
|
child process that reads addresses from a pipe and responds
|
|
|
|
|
with line number information, processing one address at a
|
|
|
|
|
time. */
|
|
|
|
|
fflush (stdout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-06 23:49:46 +08:00
|
|
|
|
/* Process a file. Returns an exit value for main(). */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2006-08-06 23:49:46 +08:00
|
|
|
|
static int
|
2006-04-06 00:12:01 +08:00
|
|
|
|
process_file (const char *file_name, const char *section_name,
|
|
|
|
|
const char *target)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
bfd *abfd;
|
2006-04-06 00:12:01 +08:00
|
|
|
|
asection *section;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
char **matching;
|
|
|
|
|
|
2003-11-07 20:19:34 +08:00
|
|
|
|
if (get_file_size (file_name) < 1)
|
2006-08-06 23:49:46 +08:00
|
|
|
|
return 1;
|
2003-11-07 20:19:34 +08:00
|
|
|
|
|
2002-07-31 17:38:04 +08:00
|
|
|
|
abfd = bfd_openr (file_name, target);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (abfd == NULL)
|
2002-07-31 17:38:04 +08:00
|
|
|
|
bfd_fatal (file_name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2010-10-29 20:10:39 +08:00
|
|
|
|
/* Decompress sections. */
|
|
|
|
|
abfd->flags |= BFD_DECOMPRESS;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (bfd_check_format (abfd, bfd_archive))
|
2006-04-06 00:12:01 +08:00
|
|
|
|
fatal (_("%s: cannot get addresses from archive"), file_name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if (! bfd_check_format_matches (abfd, bfd_object, &matching))
|
|
|
|
|
{
|
|
|
|
|
bfd_nonfatal (bfd_get_filename (abfd));
|
|
|
|
|
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
|
2022-06-16 13:18:13 +08:00
|
|
|
|
list_matching_formats (matching);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
xexit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-06 00:12:01 +08:00
|
|
|
|
if (section_name != NULL)
|
|
|
|
|
{
|
|
|
|
|
section = bfd_get_section_by_name (abfd, section_name);
|
|
|
|
|
if (section == NULL)
|
|
|
|
|
fatal (_("%s: cannot find section %s"), file_name, section_name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
section = NULL;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
slurp_symtab (abfd);
|
|
|
|
|
|
2006-04-06 00:12:01 +08:00
|
|
|
|
translate_addresses (abfd, section);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2020-05-20 21:18:41 +08:00
|
|
|
|
free (syms);
|
|
|
|
|
syms = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
bfd_close (abfd);
|
2006-08-06 23:49:46 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2003-09-14 20:20:17 +08:00
|
|
|
|
main (int argc, char **argv)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-07-31 17:38:04 +08:00
|
|
|
|
const char *file_name;
|
2006-04-06 00:12:01 +08:00
|
|
|
|
const char *section_name;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
char *target;
|
|
|
|
|
int c;
|
|
|
|
|
|
C99 binutils configury
* configure.ac: Assume long long is available. Don't test for
strings.h, stdlib.h, limits.h, locale.h, or wchar.h. Check
inttypes.h, stdint.h, sys/stat.h and sys/types.h. Don't check for
strcoll, setlocale, setmode or location of time_t. Don't check
for fprintf, getenv, snprintf, strnlen, strstr or vsnprintf decls.
(AC_ISC_POSIX, AXC_HEADER_STRING, AC_FUNC_ALLOCA): Don't invoke.
* sysdep.h: Don't include alloca-conf.h, include config.h instead.
Test HAVE_SYS_TYPES_H and reorder includes. Include limits.h,
locale.h, string.h and stdlib.h unconditionally. Remove various
fallback declarations. Assume long long is available.
* addr2line.c: Don't test HAVE_SETLOCALE.
* ar.c: Likewise.
* coffdump.c: Likewise.
* dlltool.c: Likewise.
* dllwrap.c: Likewise.
* elfedit.c: Likewise.
* nm.c: Likewise.
* objcopy.c: Likewise.
* objdump.c: Likewise.
* readelf.c: Likewise.
* size.c: Likewise.
* srconv.c: Likewise.
* strings.c: Likewise.
* sysdump.c: Likewise.
* windmc.c: Likewise.
* windres.c: Likewise.
* bucomm.c: Don't test HAVE_TIME_T_IN_TIME_H or HAVE_TIME_T_IN_TYPES_H.
* dwarf.c: Include limits.h unconditionally. Assume long long
is available.
* nm.c: Don't test HAVE_STRCOLL.
* readelf.c: Don't test HAVE_WCHAR_H.
* strings.c: Assume long long is available.
* syslex.l: Include string.h unconditionally.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
2021-04-05 14:00:22 +08:00
|
|
|
|
#ifdef HAVE_LC_MESSAGES
|
1999-05-03 15:29:11 +08:00
|
|
|
|
setlocale (LC_MESSAGES, "");
|
2001-09-19 13:33:36 +08:00
|
|
|
|
#endif
|
|
|
|
|
setlocale (LC_CTYPE, "");
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
|
textdomain (PACKAGE);
|
|
|
|
|
|
|
|
|
|
program_name = *argv;
|
|
|
|
|
xmalloc_set_program_name (program_name);
|
2015-01-22 01:37:23 +08:00
|
|
|
|
bfd_set_error_program_name (program_name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-10-01 00:37:32 +08:00
|
|
|
|
expandargv (&argc, &argv);
|
|
|
|
|
|
2018-10-15 13:40:27 +08:00
|
|
|
|
if (bfd_init () != BFD_INIT_MAGIC)
|
|
|
|
|
fatal (_("fatal error: libbfd ABI mismatch"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
set_default_bfd_target ();
|
|
|
|
|
|
2002-07-31 17:38:04 +08:00
|
|
|
|
file_name = NULL;
|
2006-04-06 00:12:01 +08:00
|
|
|
|
section_name = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
target = NULL;
|
2018-12-07 19:32:55 +08:00
|
|
|
|
while ((c = getopt_long (argc, argv, "ab:Ce:rRsfHhij:pVv", long_options, (int *) 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
!= EOF)
|
|
|
|
|
{
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2002-01-24 00:12:56 +08:00
|
|
|
|
break; /* We've been given a long option. */
|
2009-12-09 20:58:23 +08:00
|
|
|
|
case 'a':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
with_addresses = true;
|
2009-12-09 20:58:23 +08:00
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case 'b':
|
|
|
|
|
target = optarg;
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
do_demangle = true;
|
2000-07-21 02:02:56 +08:00
|
|
|
|
if (optarg != NULL)
|
|
|
|
|
{
|
|
|
|
|
enum demangling_styles style;
|
2002-05-20 00:17:54 +08:00
|
|
|
|
|
2000-07-21 02:02:56 +08:00
|
|
|
|
style = cplus_demangle_name_to_style (optarg);
|
2002-05-20 00:17:54 +08:00
|
|
|
|
if (style == unknown_demangling)
|
2000-07-21 02:02:56 +08:00
|
|
|
|
fatal (_("unknown demangling style `%s'"),
|
|
|
|
|
optarg);
|
2002-05-20 00:17:54 +08:00
|
|
|
|
|
2000-07-21 02:02:56 +08:00
|
|
|
|
cplus_demangle_set_style (style);
|
2002-05-20 00:17:54 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2018-12-07 19:32:55 +08:00
|
|
|
|
case 'r':
|
|
|
|
|
demangle_flags |= DMGL_NO_RECURSE_LIMIT;
|
|
|
|
|
break;
|
|
|
|
|
case 'R':
|
|
|
|
|
demangle_flags &= ~ DMGL_NO_RECURSE_LIMIT;
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case 'e':
|
2002-07-31 17:38:04 +08:00
|
|
|
|
file_name = optarg;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 's':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
base_names = true;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'f':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
with_functions = true;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2009-12-11 00:12:33 +08:00
|
|
|
|
case 'p':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
pretty_print = true;
|
2009-12-11 00:12:33 +08:00
|
|
|
|
break;
|
2002-01-24 00:12:56 +08:00
|
|
|
|
case 'v':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case 'V':
|
|
|
|
|
print_version ("addr2line");
|
|
|
|
|
break;
|
2002-01-24 00:12:56 +08:00
|
|
|
|
case 'h':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case 'H':
|
|
|
|
|
usage (stdout, 0);
|
|
|
|
|
break;
|
2005-05-24 01:45:42 +08:00
|
|
|
|
case 'i':
|
Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
* windmc.c, * windmc.h, * windres.c, * winduni.c,
* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
and TRUE with true throughout.
2021-03-31 08:09:37 +08:00
|
|
|
|
unwind_inlines = true;
|
2005-05-24 01:45:42 +08:00
|
|
|
|
break;
|
2006-04-06 00:12:01 +08:00
|
|
|
|
case 'j':
|
|
|
|
|
section_name = optarg;
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
default:
|
|
|
|
|
usage (stderr, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-31 17:38:04 +08:00
|
|
|
|
if (file_name == NULL)
|
|
|
|
|
file_name = "a.out";
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
addr = argv + optind;
|
|
|
|
|
naddr = argc - optind;
|
|
|
|
|
|
2006-08-06 23:49:46 +08:00
|
|
|
|
return process_file (file_name, section_name, target);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|