Display the contents of a .debug.macinfo section
This commit is contained in:
parent
4ad0936356
commit
e0c60db230
5 changed files with 146 additions and 17 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2001-07-05 Daniel Berlin <dan@cgsoftware.com>
|
||||||
|
|
||||||
|
* readelf.c (display_debug_macinfo): New function, display
|
||||||
|
.debug_macinfo section.
|
||||||
|
(do_debug_macinfo): New variable.
|
||||||
|
(parse_args): Handle "-w[mM]" to mean display macro info.
|
||||||
|
(process_section_headers): Handle debug_macinfo.
|
||||||
|
(debug_displays): Replace unsupported function with macinfo
|
||||||
|
function for .debug_macinfo display.
|
||||||
|
* doc/binutils.texi: Document new command line switch.
|
||||||
|
* NEWS: Document new feature of readelf.
|
||||||
|
|
||||||
2001-07-05 H.J. Lu <hjl@gnu.org>
|
2001-07-05 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
* objcopy.c (filter_symbols): Don't turn undefined symbols
|
* objcopy.c (filter_symbols): Don't turn undefined symbols
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
-*- text -*-
|
-*- text -*-
|
||||||
|
|
||||||
|
* readelf: Support added for DWARF 2.1 extensions. Support added for
|
||||||
|
displaying the contents of .debug.macinfo sections.
|
||||||
|
|
||||||
* New command line switches added to objcopy to allow symbols to be kept as
|
* New command line switches added to objcopy to allow symbols to be kept as
|
||||||
global symbols, and also to specify files containing lists of such symbols.
|
global symbols, and also to specify files containing lists of such symbols.
|
||||||
by Honda Hiroki.
|
by Honda Hiroki.
|
||||||
|
|
|
@ -2785,7 +2785,7 @@ readelf [ -a | --all ]
|
||||||
[ -V | --version-info]
|
[ -V | --version-info]
|
||||||
[ -D | --use-dynamic]
|
[ -D | --use-dynamic]
|
||||||
[ -x <number> | --hex-dump=<number>]
|
[ -x <number> | --hex-dump=<number>]
|
||||||
[ -w[liaprf] | --debug-dump[=info,=line,=abbrev,=pubnames,=ranges,=frames]]
|
[ -w[liaprmf] | --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames]]
|
||||||
[ --histogram]
|
[ --histogram]
|
||||||
[ -v | --version]
|
[ -v | --version]
|
||||||
[ -H | --help]
|
[ -H | --help]
|
||||||
|
@ -2886,8 +2886,8 @@ symbols section.
|
||||||
@itemx --hex-dump=<number>
|
@itemx --hex-dump=<number>
|
||||||
Displays the contents of the indicated section as a hexadecimal dump.
|
Displays the contents of the indicated section as a hexadecimal dump.
|
||||||
|
|
||||||
@item -w[liaprf]
|
@item -w[liaprmf]
|
||||||
@itemx --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=frames]
|
@itemx --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames]
|
||||||
Displays the contents of the debug sections in the file, if any are
|
Displays the contents of the debug sections in the file, if any are
|
||||||
present. If one of the optional letters or words follows the switch
|
present. If one of the optional letters or words follows the switch
|
||||||
then only data found in those specific sections will be dumped.
|
then only data found in those specific sections will be dumped.
|
||||||
|
|
|
@ -807,7 +807,7 @@ filter_symbols (abfd, obfd, osyms, isyms, symcount)
|
||||||
keep = 1;
|
keep = 1;
|
||||||
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
|
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
|
||||||
keep = 0;
|
keep = 0;
|
||||||
|
|
||||||
if (keep && (flags & BSF_GLOBAL) != 0
|
if (keep && (flags & BSF_GLOBAL) != 0
|
||||||
&& (weaken || is_specified_symbol (name, weaken_specific_list)))
|
&& (weaken || is_specified_symbol (name, weaken_specific_list)))
|
||||||
{
|
{
|
||||||
|
@ -1570,9 +1570,7 @@ copy_section (ibfd, isection, obfdarg)
|
||||||
|| strip_symbols == STRIP_ALL
|
|| strip_symbols == STRIP_ALL
|
||||||
|| discard_locals == LOCALS_ALL
|
|| discard_locals == LOCALS_ALL
|
||||||
|| convert_debugging))
|
|| convert_debugging))
|
||||||
{
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = find_section_list (bfd_section_name (ibfd, isection), false);
|
p = find_section_list (bfd_section_name (ibfd, isection), false);
|
||||||
|
|
||||||
|
@ -1587,7 +1585,6 @@ copy_section (ibfd, isection, obfdarg)
|
||||||
if (size == 0 || osection == 0)
|
if (size == 0 || osection == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
relsize = bfd_get_reloc_upper_bound (ibfd, isection);
|
relsize = bfd_get_reloc_upper_bound (ibfd, isection);
|
||||||
if (relsize < 0)
|
if (relsize < 0)
|
||||||
RETURN_NONFATAL (bfd_get_filename (ibfd));
|
RETURN_NONFATAL (bfd_get_filename (ibfd));
|
||||||
|
@ -1619,6 +1616,33 @@ copy_section (ibfd, isection, obfdarg)
|
||||||
free (relpp);
|
free (relpp);
|
||||||
relpp = temp_relpp;
|
relpp = temp_relpp;
|
||||||
}
|
}
|
||||||
|
else if (sections_removed)
|
||||||
|
{
|
||||||
|
/* Remove relocations which are against symbols
|
||||||
|
in sections that have been removed, unless
|
||||||
|
the symbols are going to be preserved. */
|
||||||
|
arelent ** temp_relpp;
|
||||||
|
asymbol * sym;
|
||||||
|
long temp_relcount = 0;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
temp_relpp = (arelent **) xmalloc (relsize);
|
||||||
|
for (i = 0; i < relcount; i++)
|
||||||
|
{
|
||||||
|
sym = *relpp [i]->sym_ptr_ptr;
|
||||||
|
|
||||||
|
/* FIXME: Should we warn about deleted relocs ? */
|
||||||
|
if (is_specified_symbol (bfd_asymbol_name (sym),
|
||||||
|
keep_specific_list)
|
||||||
|
|| bfd_get_output_section (sym) != NULL)
|
||||||
|
temp_relpp [temp_relcount++] = relpp [i];
|
||||||
|
}
|
||||||
|
|
||||||
|
relcount = temp_relcount;
|
||||||
|
free (relpp);
|
||||||
|
relpp = temp_relpp;
|
||||||
|
}
|
||||||
|
|
||||||
bfd_set_reloc (obfd, osection,
|
bfd_set_reloc (obfd, osection,
|
||||||
(relcount == 0 ? (arelent **) NULL : relpp), relcount);
|
(relcount == 0 ? (arelent **) NULL : relpp), relcount);
|
||||||
}
|
}
|
||||||
|
@ -1753,14 +1777,22 @@ mark_symbols_used_in_relocations (ibfd, isection, symbolsarg)
|
||||||
if (relcount < 0)
|
if (relcount < 0)
|
||||||
bfd_fatal (bfd_get_filename (ibfd));
|
bfd_fatal (bfd_get_filename (ibfd));
|
||||||
|
|
||||||
/* Examine each symbol used in a relocation. If it's not one of the
|
/* Examine each symbol used in a relocation. */
|
||||||
special bfd section symbols, then mark it with BSF_KEEP. */
|
|
||||||
for (i = 0; i < relcount; i++)
|
for (i = 0; i < relcount; i++)
|
||||||
{
|
{
|
||||||
if (*relpp[i]->sym_ptr_ptr != bfd_com_section_ptr->symbol
|
asymbol * sym = * relpp[i]->sym_ptr_ptr;
|
||||||
&& *relpp[i]->sym_ptr_ptr != bfd_abs_section_ptr->symbol
|
|
||||||
&& *relpp[i]->sym_ptr_ptr != bfd_und_section_ptr->symbol)
|
/* If the symbol's output section does not exist (because it
|
||||||
(*relpp[i]->sym_ptr_ptr)->flags |= BSF_KEEP;
|
has been removed with -R) then do not keep the symbol. */
|
||||||
|
if (bfd_get_output_section (sym) == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* If the symbols is not one of the special bfd
|
||||||
|
section symbols, then mark it with BSF_KEEP. */
|
||||||
|
if (sym != bfd_com_section_ptr->symbol
|
||||||
|
&& sym != bfd_abs_section_ptr->symbol
|
||||||
|
&& sym != bfd_und_section_ptr->symbol)
|
||||||
|
sym->flags |= BSF_KEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relpp != NULL)
|
if (relpp != NULL)
|
||||||
|
|
|
@ -119,6 +119,7 @@ int do_debug_pubnames;
|
||||||
int do_debug_aranges;
|
int do_debug_aranges;
|
||||||
int do_debug_frames;
|
int do_debug_frames;
|
||||||
int do_debug_frames_interp;
|
int do_debug_frames_interp;
|
||||||
|
int do_debug_macinfo;
|
||||||
int do_arch;
|
int do_arch;
|
||||||
int do_notes;
|
int do_notes;
|
||||||
int is_32bit_elf;
|
int is_32bit_elf;
|
||||||
|
@ -210,6 +211,7 @@ static int display_debug_lines PARAMS ((Elf32_Internal_Sh
|
||||||
static int display_debug_abbrev PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
static int display_debug_abbrev PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
||||||
static int display_debug_aranges PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
static int display_debug_aranges PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
||||||
static int display_debug_frames PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
static int display_debug_frames PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
||||||
|
static int display_debug_macinfo PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
|
||||||
static unsigned char * process_abbrev_section PARAMS ((unsigned char *, unsigned char *));
|
static unsigned char * process_abbrev_section PARAMS ((unsigned char *, unsigned char *));
|
||||||
static unsigned long read_leb128 PARAMS ((unsigned char *, int *, int));
|
static unsigned long read_leb128 PARAMS ((unsigned char *, int *, int));
|
||||||
static int process_extended_line_op PARAMS ((unsigned char *, int, int));
|
static int process_extended_line_op PARAMS ((unsigned char *, int, int));
|
||||||
|
@ -2019,7 +2021,7 @@ usage ()
|
||||||
fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
|
fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
|
||||||
fprintf (stdout, _(" -x <number> or --hex-dump=<number>\n"));
|
fprintf (stdout, _(" -x <number> or --hex-dump=<number>\n"));
|
||||||
fprintf (stdout, _(" Dump the contents of section <number>\n"));
|
fprintf (stdout, _(" Dump the contents of section <number>\n"));
|
||||||
fprintf (stdout, _(" -w[liaprf] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=frames]\n"));
|
fprintf (stdout, _(" -w[liaprmf] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames]\n"));
|
||||||
fprintf (stdout, _(" Display the contents of DWARF2 debug sections\n"));
|
fprintf (stdout, _(" Display the contents of DWARF2 debug sections\n"));
|
||||||
#ifdef SUPPORT_DISASSEMBLY
|
#ifdef SUPPORT_DISASSEMBLY
|
||||||
fprintf (stdout, _(" -i <number> or --instruction-dump=<number>\n"));
|
fprintf (stdout, _(" -i <number> or --instruction-dump=<number>\n"));
|
||||||
|
@ -2189,6 +2191,11 @@ parse_args (argc, argv)
|
||||||
do_debug_frames = 1;
|
do_debug_frames = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
case 'M':
|
||||||
|
do_debug_macinfo = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
warn (_("Unrecognised debug option '%s'\n"), optarg);
|
warn (_("Unrecognised debug option '%s'\n"), optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -2935,7 +2942,7 @@ process_section_headers (file)
|
||||||
}
|
}
|
||||||
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|
||||||
|| do_debug_lines || do_debug_pubnames || do_debug_aranges
|
|| do_debug_lines || do_debug_pubnames || do_debug_aranges
|
||||||
|| do_debug_frames)
|
|| do_debug_frames || do_debug_macinfo)
|
||||||
&& strncmp (name, ".debug_", 7) == 0)
|
&& strncmp (name, ".debug_", 7) == 0)
|
||||||
{
|
{
|
||||||
name += 7;
|
name += 7;
|
||||||
|
@ -2947,6 +2954,7 @@ process_section_headers (file)
|
||||||
|| (do_debug_pubnames && (strcmp (name, "pubnames") == 0))
|
|| (do_debug_pubnames && (strcmp (name, "pubnames") == 0))
|
||||||
|| (do_debug_aranges && (strcmp (name, "aranges") == 0))
|
|| (do_debug_aranges && (strcmp (name, "aranges") == 0))
|
||||||
|| (do_debug_frames && (strcmp (name, "frame") == 0))
|
|| (do_debug_frames && (strcmp (name, "frame") == 0))
|
||||||
|
|| (do_debug_macinfo && (strcmp (name, "macinfo") == 0))
|
||||||
)
|
)
|
||||||
request_dump (i, DEBUG_DUMP);
|
request_dump (i, DEBUG_DUMP);
|
||||||
}
|
}
|
||||||
|
@ -6264,6 +6272,80 @@ process_abbrev_section (start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
display_debug_macinfo (section, start, file)
|
||||||
|
Elf32_Internal_Shdr * section;
|
||||||
|
unsigned char * start;
|
||||||
|
FILE * file ATTRIBUTE_UNUSED;
|
||||||
|
{
|
||||||
|
unsigned char * end = start + section->sh_size;
|
||||||
|
unsigned char * curr = start;
|
||||||
|
unsigned int bytes_read;
|
||||||
|
enum dwarf_macinfo_record_type op;
|
||||||
|
|
||||||
|
printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section));
|
||||||
|
|
||||||
|
while (curr < end)
|
||||||
|
{
|
||||||
|
unsigned int lineno;
|
||||||
|
const char * string;
|
||||||
|
|
||||||
|
op = * curr;
|
||||||
|
curr ++;
|
||||||
|
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case DW_MACINFO_start_file:
|
||||||
|
{
|
||||||
|
unsigned int filenum;
|
||||||
|
|
||||||
|
lineno = read_leb128 (curr, & bytes_read, 0);
|
||||||
|
curr += bytes_read;
|
||||||
|
filenum = read_leb128 (curr, & bytes_read, 0);
|
||||||
|
curr += bytes_read;
|
||||||
|
|
||||||
|
printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno, filenum);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DW_MACINFO_end_file:
|
||||||
|
printf (_(" DW_MACINFO_end_file\n"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DW_MACINFO_define:
|
||||||
|
lineno = read_leb128 (curr, & bytes_read, 0);
|
||||||
|
curr += bytes_read;
|
||||||
|
string = curr;
|
||||||
|
curr += strlen (string) + 1;
|
||||||
|
printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), lineno, string);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DW_MACINFO_undef:
|
||||||
|
lineno = read_leb128 (curr, & bytes_read, 0);
|
||||||
|
curr += bytes_read;
|
||||||
|
string = curr;
|
||||||
|
curr += strlen (string) + 1;
|
||||||
|
printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), lineno, string);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DW_MACINFO_vendor_ext:
|
||||||
|
{
|
||||||
|
unsigned int constant;
|
||||||
|
|
||||||
|
constant = read_leb128 (curr, & bytes_read, 0);
|
||||||
|
curr += bytes_read;
|
||||||
|
string = curr;
|
||||||
|
curr += strlen (string) + 1;
|
||||||
|
printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), constant, string);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
display_debug_abbrev (section, start, file)
|
display_debug_abbrev (section, start, file)
|
||||||
Elf32_Internal_Shdr * section;
|
Elf32_Internal_Shdr * section;
|
||||||
|
@ -7846,7 +7928,7 @@ debug_displays[] =
|
||||||
{ ".debug_pubnames", display_debug_pubnames, NULL },
|
{ ".debug_pubnames", display_debug_pubnames, NULL },
|
||||||
{ ".debug_frame", display_debug_frames, NULL },
|
{ ".debug_frame", display_debug_frames, NULL },
|
||||||
{ ".eh_frame", display_debug_frames, NULL },
|
{ ".eh_frame", display_debug_frames, NULL },
|
||||||
{ ".debug_macinfo", display_debug_not_supported, NULL },
|
{ ".debug_macinfo", display_debug_macinfo, NULL },
|
||||||
{ ".debug_str", display_debug_not_supported, NULL },
|
{ ".debug_str", display_debug_not_supported, NULL },
|
||||||
{ ".debug_static_func", display_debug_not_supported, NULL },
|
{ ".debug_static_func", display_debug_not_supported, NULL },
|
||||||
{ ".debug_static_vars", display_debug_not_supported, NULL },
|
{ ".debug_static_vars", display_debug_not_supported, NULL },
|
||||||
|
|
Loading…
Reference in a new issue