static const char *
-section_name (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr)
+section_name (Ebl *ebl, GElf_Shdr *shdr)
{
- return elf_strptr (ebl->elf, ehdr->e_shstrndx, shdr->sh_name) ?: "???";
+ size_t shstrndx;
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
+ return "???";
+ return elf_strptr (ebl->elf, shstrndx, shdr->sh_name) ?: "???";
}
static void
print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl, GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
const size_t sh_size = (dbg->sectiondata[IDX_debug_abbrev] ?
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
" [ Code]\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
Dwarf_Off offset = 0;
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
if (shdr->sh_size == 0)
"\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entries:\n",
cnt),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset, cnt);
/* Compute floor(log16(cnt)). */
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
const unsigned char *readp = data->d_buf;
{
invalid_data:
error (0, 0, gettext ("invalid data in section [%zu] '%s'"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
+ elf_ndxscn (scn), section_name (ebl, shdr));
return;
}
/* Print content of DWARF .debug_rnglists section. */
static void
print_debug_rnglists_section (Dwfl_Module *dwflmod,
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr,
Dwarf *dbg __attribute__((unused)))
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
Elf_Data *data =(dbg->sectiondata[IDX_debug_rnglists]
{
invalid_data:
error (0, 0, gettext ("invalid data in section [%zu] '%s'"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
+ elf_ndxscn (scn), section_name (ebl, shdr));
return;
}
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
sort_listptr (&known_rangelistptr, "rangelistptr");
static void
print_debug_units (Dwfl_Module *dwflmod,
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl, GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr,
Dwarf *dbg, bool debug_types)
{
const bool silent = !(print_debug_sections & section_info) && !debug_types;
- const char *secname = section_name (ebl, ehdr, shdr);
+ const char *secname = section_name (ebl, shdr);
if (!silent)
printf (gettext ("\
static void
-print_decoded_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
+print_decoded_line_section (Dwfl_Module *dwflmod, Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
size_t address_size
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
if (shdr->sh_size == 0)
{
invalid_data:
error (0, 0, gettext ("invalid data in section [%zu] '%s'"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
+ elf_ndxscn (scn), section_name (ebl, shdr));
return;
}
unit_length = read_8ubyte_unaligned_inc (dbg, linep);
error (0, 0,
gettext ("invalid data at offset %tu in section [%zu] '%s'"),
linep - (const unsigned char *) data->d_buf,
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
+ elf_ndxscn (scn), section_name (ebl, shdr));
linep = lineendp;
continue;
}
static void
print_debug_loclists_section (Dwfl_Module *dwflmod,
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr,
Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
Elf_Data *data = (dbg->sectiondata[IDX_debug_loclists]
{
invalid_data:
error (0, 0, gettext ("invalid data in section [%zu] '%s'"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
+ elf_ndxscn (scn), section_name (ebl, shdr));
return;
}
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
sort_listptr (&known_locsptr, "loclistptr");
static void
print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
putc_unlocked ('\n', stdout);
static void
print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
putc_unlocked ('\n', stdout);
/* Print the known exported symbols in the DWARF section '.debug_pubnames'. */
static void
print_debug_pubnames_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
int n = 0;
/* Print the content of the DWARF string section '.debug_str'. */
static void
print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr,
Dwarf *dbg __attribute__ ((unused)))
{
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
" %*s String\n"),
elf_ndxscn (scn),
- section_name (ebl, ehdr, shdr), (uint64_t) shdr->sh_offset,
+ section_name (ebl, shdr), (uint64_t) shdr->sh_offset,
/* TRANS: the debugstr| prefix makes the string unique. */
digits + 2, sgettext ("debugstr|Offset"));
static void
print_debug_str_offsets_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl, GElf_Ehdr *ehdr,
+ Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset);
if (shdr->sh_size == 0)
http://sourceware.org/gdb/current/onlinedocs/gdb/Index-Section-Format.html
*/
static void
-print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
+print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl,
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\nGDB section [%2zu] '%s' at offset %#" PRIx64
" contains %" PRId64 " bytes :\n"),
- elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ elf_ndxscn (scn), section_name (ebl, shdr),
(uint64_t) shdr->sh_offset, (uint64_t) shdr->sh_size);
Elf_Data *data = elf_rawdata (scn, NULL);