#include "safe-ctype.h"
char *program_name = "readelf";
+int do_wide;
static long archive_file_offset;
static unsigned long archive_file_size;
static unsigned long dynamic_addr;
static int do_header;
static int do_dump;
static int do_version;
-static int do_wide;
static int do_histogram;
static int do_debugging;
static int do_arch;
return 0;
}
-/* Display a symbol on stdout. If do_wide is not true then
- format the symbol to be at most WIDTH characters,
- truncating as necessary. If WIDTH is negative then
- format the string to be exactly - WIDTH characters,
- truncating or padding as necessary. */
+/* Display a symbol on stdout. Handles the display of
+ non-printing characters.
+ If DO_WIDE is not true then format the symbol to be
+ at most WIDTH characters, truncating as necessary.
+ If WIDTH is negative then format the string to be
+ exactly - WIDTH characters, truncating or padding
+ as necessary. */
static void
print_symbol (int width, const char *symbol)
{
+ const char * format_string;
+ const char * c;
+
if (do_wide)
- printf ("%s", symbol);
+ {
+ format_string = "%.*s";
+ /* Set the width to a very large value. This simplifies the code below. */
+ width = INT_MAX;
+ }
else if (width < 0)
- printf ("%-*.*s", width, width, symbol);
+ {
+ format_string = "%-*.*2s";
+ /* Keep the width positive. This also helps. */
+ width = - width;
+ }
else
- printf ("%-.*s", width, symbol);
+ {
+ format_string = "%-.*s";
+ }
+
+ while (width)
+ {
+ int len;
+
+ c = symbol;
+
+ /* Look for non-printing symbols inside the symbol's name.
+ This test is triggered in particular by the names generated
+ by the assembler for local labels. */
+ while (ISPRINT (* c))
+ c++;
+
+ len = c - symbol;
+
+ if (len)
+ {
+ if (len > width)
+ len = width;
+
+ printf (format_string, len, symbol);
+
+ width -= len;
+ }
+
+ if (* c == 0 || width == 0)
+ break;
+
+ /* Now display the non-printing character, if
+ there is room left in which to dipslay it. */
+ if (*c < 32)
+ {
+ if (width < 2)
+ break;
+
+ printf ("^%c", *c + 0x40);
+
+ width -= 2;
+ }
+ else
+ {
+ if (width < 6)
+ break;
+
+ printf ("<0x%.2x>", *c);
+
+ width -= 6;
+ }
+
+ symbol = c + 1;
+ }
}
static void
Dump the contents of section <number|name> as bytes\n\
-p --string-dump=<number|name>\n\
Dump the contents of section <number|name> as strings\n\
- -w[liaprmfFsoR] or\n\
- --debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
+ -w[lLiaprmfFsoR] or\n\
+ --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
Display the contents of DWARF2 debug sections\n"));
#ifdef SUPPORT_DISASSEMBLY
fprintf (stream, _("\
do_debug_lines = 1;
break;
+ case 'L':
+ do_debug_lines_decoded = 1;
+ break;
+
case 'p':
do_debug_pubnames = 1;
break;
{ "frames", & do_debug_frames },
{ "frames-interp", & do_debug_frames_interp },
{ "info", & do_debug_info },
- { "line", & do_debug_lines },
+ { "line", & do_debug_lines }, /* For backwards compatibility. */
+ { "rawline", & do_debug_lines },
+ { "decodedline", & do_debug_lines_decoded },
{ "loc", & do_debug_loc },
{ "macro", & do_debug_macinfo },
{ "pubnames", & do_debug_pubnames },
Elf_Internal_Shdr *section;
segment = program_headers + i;
- section = section_headers;
+ section = section_headers + 1;
printf (" %2.2d ", i);
else if (section->sh_type == SHT_RELA)
CHECK_ENTSIZE (section, i, Rela);
else if ((do_debugging || do_debug_info || do_debug_abbrevs
- || do_debug_lines || do_debug_pubnames || do_debug_aranges
- || do_debug_frames || do_debug_macinfo || do_debug_str
- || do_debug_loc || do_debug_ranges)
+ || do_debug_lines || do_debug_lines_decoded || do_debug_pubnames
+ || do_debug_aranges || do_debug_frames || do_debug_macinfo
+ || do_debug_str || do_debug_loc || do_debug_ranges)
&& const_strneq (name, ".debug_"))
{
name += 7;
if (do_debugging
|| (do_debug_info && streq (name, "info"))
|| (do_debug_abbrevs && streq (name, "abbrev"))
- || (do_debug_lines && streq (name, "line"))
+ || ((do_debug_lines || do_debug_lines_decoded)
+ && streq (name, "line"))
|| (do_debug_pubnames && streq (name, "pubnames"))
|| (do_debug_aranges && streq (name, "aranges"))
|| (do_debug_ranges && streq (name, "ranges"))
)
request_dump_bynumber (i, DEBUG_DUMP);
}
- /* linkonce section to be combined with .debug_info at link time. */
+ /* Linkonce section to be combined with .debug_info at link time. */
else if ((do_debugging || do_debug_info)
&& const_strneq (name, ".gnu.linkonce.wi."))
request_dump_bynumber (i, DEBUG_DUMP);
return _("NT_GNU_HWCAP (DSO-supplied software HWCAP info)");
case NT_GNU_BUILD_ID:
return _("NT_GNU_BUILD_ID (unique build ID bitstring)");
+ case NT_GNU_GOLD_VERSION:
+ return _("NT_GNU_GOLD_VERSION (gold version)");
default:
break;
}