static bfd_boolean check_all = FALSE;
static bfd_boolean is_32bit_elf = FALSE;
static bfd_boolean decompress_dumps = FALSE;
+static bfd_boolean do_not_show_symbol_truncation = FALSE;
static char *dump_ctf_parent_name;
static char *dump_ctf_symtab_name;
Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true.
+ If truncation will happen and do_not_show_symbol_truncation is FALSE then display
+ abs(WIDTH) - 5 characters followed by "[...]".
+
If WIDTH is negative then ensure that the output is at least (- WIDTH) characters,
padding as necessary.
Returns the number of emitted characters. */
static unsigned int
-print_symbol (signed int width, const char *symbol)
+print_symbol (signed int width, const char * symbol)
{
bfd_boolean extra_padding = FALSE;
+ bfd_boolean do_dots = FALSE;
signed int num_printed = 0;
#ifdef HAVE_MBSTATE_T
mbstate_t state;
This simplifies the code below. */
width_remaining = INT_MAX;
else
- width_remaining = width;
+ {
+ width_remaining = width;
+ if (! do_not_show_symbol_truncation
+ && (int) strlen (symbol) > width)
+ {
+ width_remaining -= 5;
+ if ((int) width_remaining < 0)
+ width_remaining = 0;
+ do_dots = TRUE;
+ }
+ }
#ifdef HAVE_MBSTATE_T
/* Initialise the multibyte conversion state. */
}
}
+ if (do_dots)
+ num_printed += printf ("[...]");
+
if (extra_padding && num_printed < width)
{
/* Fill in the remaining spaces. */
{"dwarf-start", required_argument, 0, OPTION_DWARF_START},
{"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
+#ifdef ENABLE_LIBCTF
{"ctf", required_argument, 0, OPTION_CTF_DUMP},
{"ctf-symbols", required_argument, 0, OPTION_CTF_SYMBOLS},
{"ctf-strings", required_argument, 0, OPTION_CTF_STRINGS},
{"ctf-parent", required_argument, 0, OPTION_CTF_PARENT},
+#endif
{"version", no_argument, 0, 'v'},
{"wide", no_argument, 0, 'W'},
+ {"silent-truncation",no_argument, 0, 'T'},
{"help", no_argument, 0, 'H'},
{0, no_argument, 0, 0}
};
--dwarf-depth=N Do not display DIEs at depth N or greater\n\
--dwarf-start=N Display DIEs starting with N, at the same depth\n\
or deeper\n"));
+#ifdef ENABLE_LIBCTF
fprintf (stream, _("\
--ctf=<number|name> Display CTF info from section <number|name>\n\
--ctf-parent=<number|name>\n\
Use section <number|name> as the CTF external symtab\n\n\
--ctf-strings=<number|name>\n\
Use section <number|name> as the CTF external strtab\n\n"));
+#endif
#ifdef SUPPORT_DISASSEMBLY
fprintf (stream, _("\
fprintf (stream, _("\
-I --histogram Display histogram of bucket list lengths\n\
-W --wide Allow output width to exceed 80 characters\n\
+ -T --silent-truncation If a symbol name is truncated, do not add a suffix [...]\n\
@<file> Read options from <file>\n\
-H --help Display this information\n\
-v --version Display the version number of readelf\n"));
usage (stderr);
while ((c = getopt_long
- (argc, argv, "ADHILNR:SVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
+ (argc, argv, "ADHILNR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
{
switch (c)
{
case 'W':
do_wide = TRUE;
break;
+ case 'T':
+ do_not_show_symbol_truncation = TRUE;
+ break;
default:
/* xgettext:c-format */
error (_("Invalid option '-%c'\n"), c);
enum versioned_symbol_info sym_info;
unsigned short vna_other;
Elf_Internal_Sym *psym = symtab + si;
-
+
printf ("%6ld: ", si);
print_vma (psym->st_value, LONG_HEX);
putchar (' ');
printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis));
}
printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx));
- print_symbol (25, VALID_SYMBOL_NAME (strtab, strtab_size,
- psym->st_name)
- ? strtab + psym->st_name : _("<corrupt>"));
+
+ bfd_boolean is_valid = VALID_SYMBOL_NAME (strtab, strtab_size,
+ psym->st_name);
+ const char * sstr = is_valid ? strtab + psym->st_name : _("<corrupt>");
version_string
= get_symbol_version_string (filedata,
|| section->sh_type == SHT_DYNSYM),
strtab, strtab_size, si,
psym, &sym_info, &vna_other);
+
+ int len_avail = 21;
+ if (! do_wide && version_string != NULL)
+ {
+ char buffer[256];
+
+ len_avail -= sprintf (buffer, "@%s", version_string);
+
+ if (sym_info == symbol_undefined)
+ len_avail -= sprintf (buffer," (%d)", vna_other);
+ else if (sym_info != symbol_hidden)
+ len_avail -= 1;
+ }
+
+ print_symbol (len_avail, sstr);
+
if (version_string)
{
if (sym_info == symbol_undefined)
return FALSE;
}
+#ifdef ENABLE_LIBCTF
static ctf_sect_t *
shdr_to_ctf_sect (ctf_sect_t *buf, Elf_Internal_Shdr *shdr, Filedata *filedata)
{
it is passed, or a pointer to newly-allocated storage, in which case
dump_ctf() will free it when it no longer needs it. */
-static char *dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
- char *s, void *arg)
+static char *
+dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
+ char *s, void *arg)
{
const char *blanks = arg;
char *new_s;
return new_s;
}
+/* Dump one CTF archive member. */
+
+static int
+dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
+{
+ ctf_file_t *parent = (ctf_file_t *) arg;
+ const char *things[] = {"Header", "Labels", "Data objects",
+ "Function objects", "Variables", "Types", "Strings",
+ ""};
+ const char **thing;
+ size_t i;
+
+ /* Only print out the name of non-default-named archive members.
+ The name .ctf appears everywhere, even for things that aren't
+ really archives, so printing it out is liable to be confusing.
+
+ The parent, if there is one, is the default-owned archive member:
+ avoid importing it into itself. (This does no harm, but looks
+ confusing.) */
+
+ if (strcmp (name, ".ctf") != 0)
+ {
+ printf (_("\nCTF archive member: %s:\n"), name);
+ ctf_import (ctf, parent);
+ }
+
+ for (i = 0, thing = things; *thing[0]; thing++, i++)
+ {
+ ctf_dump_state_t *s = NULL;
+ char *item;
+
+ printf ("\n %s:\n", *thing);
+ while ((item = ctf_dump (ctf, &s, i, dump_ctf_indent_lines,
+ (void *) " ")) != NULL)
+ {
+ printf ("%s\n", item);
+ free (item);
+ }
+
+ if (ctf_errno (ctf))
+ {
+ error (_("Iteration failed: %s, %s\n"), *thing,
+ ctf_errmsg (ctf_errno (ctf)));
+ return 1;
+ }
+ }
+ return 0;
+}
+
static bfd_boolean
dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
{
ctf_sect_t ctfsect, symsect, strsect, parentsect;
ctf_sect_t * symsectp = NULL;
ctf_sect_t * strsectp = NULL;
- ctf_file_t * ctf = NULL;
- ctf_file_t * parent = NULL;
+ ctf_archive_t * ctfa = NULL;
+ ctf_archive_t * parenta = NULL, *lookparent;
+ ctf_file_t * parent = NULL;
- const char *things[] = {"Header", "Labels", "Data objects",
- "Function objects", "Variables", "Types", "Strings",
- ""};
- const char **thing;
int err;
bfd_boolean ret = FALSE;
- size_t i;
shdr_to_ctf_sect (&ctfsect, section, filedata);
data = get_section_contents (section, filedata);
parentsect.cts_data = parentdata;
}
- /* Load the CTF file and dump it. */
+ /* Load the CTF file and dump it. It may be a raw CTF section, or an archive:
+ libctf papers over the difference, so we can pretend it is always an
+ archive. Possibly open the parent as well, if one was specified. */
- if ((ctf = ctf_bufopen (&ctfsect, symsectp, strsectp, &err)) == NULL)
+ if ((ctfa = ctf_arc_bufopen (&ctfsect, symsectp, strsectp, &err)) == NULL)
{
error (_("CTF open failure: %s\n"), ctf_errmsg (err));
goto fail;
if (parentdata)
{
- if ((parent = ctf_bufopen (&parentsect, symsectp, strsectp, &err)) == NULL)
+ if ((parenta = ctf_arc_bufopen (&parentsect, symsectp, strsectp,
+ &err)) == NULL)
{
error (_("CTF open failure: %s\n"), ctf_errmsg (err));
goto fail;
}
+ lookparent = parenta;
+ }
+ else
+ lookparent = ctfa;
- ctf_import (ctf, parent);
+ /* Assume that the applicable parent archive member is the default one.
+ (This is what all known implementations are expected to do, if they
+ put CTFs and their parents in archives together.) */
+ if ((parent = ctf_arc_open_by_name (lookparent, NULL, &err)) == NULL)
+ {
+ error (_("CTF open failure: %s\n"), ctf_errmsg (err));
+ goto fail;
}
ret = TRUE;
printf (_("\nDump of CTF section '%s':\n"),
printable_section_name (filedata, section));
- for (i = 0, thing = things; *thing[0]; thing++, i++)
- {
- ctf_dump_state_t *s = NULL;
- char *item;
-
- printf ("\n %s:\n", *thing);
- while ((item = ctf_dump (ctf, &s, i, dump_ctf_indent_lines,
- (void *) " ")) != NULL)
- {
- printf ("%s\n", item);
- free (item);
- }
-
- if (ctf_errno (ctf))
- {
- error (_("Iteration failed: %s, %s\n"), *thing,
- ctf_errmsg (ctf_errno (ctf)));
- ret = FALSE;
- }
- }
+ if (ctf_archive_iter (ctfa, dump_ctf_archive_member, parent) != 0)
+ ret = FALSE;
fail:
- ctf_file_close (ctf);
ctf_file_close (parent);
+ ctf_close (ctfa);
+ ctf_close (parenta);
free (parentdata);
free (data);
free (symdata);
free (strdata);
return ret;
}
+#endif
static bfd_boolean
load_specific_debug_section (enum dwarf_section_display_enum debug,
res = FALSE;
}
+#ifdef ENABLE_LIBCTF
if (dump & CTF_DUMP)
{
if (! dump_section_as_ctf (section, filedata))
res = FALSE;
}
+#endif
}
/* Check to see if the user requested a