From d7285e190a2d84b4120f5230320124bfa517e1c7 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 23 Jan 2009 16:10:44 -0800 Subject: Print .strtab, .dynstr, and .comment for -a option of readelf. --- src/readelf.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/readelf.c') diff --git a/src/readelf.c b/src/readelf.c index d5a3b8d4..88eb9a7c 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -275,6 +275,17 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state __attribute__ ((unused))) { + void add_dump_section (const char *name) + { + struct section_argument *a = xmalloc (sizeof *a); + a->arg = name; + a->next = NULL; + struct section_argument ***tailp + = key == 'x' ? &dump_data_sections_tail : &string_sections_tail; + **tailp = a; + *tailp = &a->next; + } + switch (key) { case 'a': @@ -290,6 +301,9 @@ parse_opt (int key, char *arg, print_arch = true; print_notes = true; print_debug_sections |= section_exception; + add_dump_section (".strtab"); + add_dump_section (".dynstr"); + add_dump_section (".comment"); any_control_option = true; break; case 'A': @@ -387,15 +401,7 @@ parse_opt (int key, char *arg, } /* Fall through. */ case 'x': - { - struct section_argument *a = xmalloc (sizeof *a); - a->arg = arg; - a->next = NULL; - struct section_argument ***tailp - = key == 'x' ? &dump_data_sections_tail : &string_sections_tail; - **tailp = a; - *tailp = &a->next; - } + add_dump_section (arg); any_control_option = true; break; case ARGP_KEY_NO_ARGS: -- cgit v1.2.3 From 62c465323070bd837df170fc8a6bc02b8e31799b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 24 Jan 2009 17:01:08 -0800 Subject: Fix compuation of base address for printing stack frame program. --- src/readelf.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/readelf.c') diff --git a/src/readelf.c b/src/readelf.c index 88eb9a7c..55c906f7 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -4643,6 +4643,7 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, unsigned int fde_encoding = 0; unsigned int lsda_encoding = 0; Dwarf_Word initial_location = 0; + Dwarf_Word vma_base = 0; if (cie_id == (is_eh_frame ? 0 : DW_CIE_ID)) { @@ -4809,16 +4810,26 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, cie->cie_offset, (uint64_t) cie_id, (uint64_t) initial_location); if ((fde_encoding & 0x70) == DW_EH_PE_pcrel) - printf (gettext (" (offset: %#" PRIx64 ")"), - ((uint64_t) shdr->sh_offset - + (base - (const unsigned char *) data->d_buf) - + (uint64_t) initial_location) + { + vma_base = (((uint64_t) shdr->sh_offset + + (base - (const unsigned char *) data->d_buf) + + (uint64_t) initial_location) + & (ptr_size == 4 + ? UINT64_C (0xffffffff) + : UINT64_C (0xffffffffffffffff))); + printf (gettext (" (offset: %#" PRIx64 ")"), + (uint64_t) vma_base); + } + + printf ("\n address_range: %#" PRIx64, + (uint64_t) address_range); + if ((fde_encoding & 0x70) == DW_EH_PE_pcrel) + printf (gettext (" (end offset: %#" PRIx64 ")"), + ((uint64_t) vma_base + (uint64_t) address_range) & (ptr_size == 4 ? UINT64_C (0xffffffff) : UINT64_C (0xffffffffffffffff))); - - printf ("\n address_range: %#" PRIx64 "\n", - (uint64_t) address_range); + putchar ('\n'); if (cie->augmentation[0] == 'z') { @@ -4859,13 +4870,6 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, } } - /* To print correct addresses compute the base address. */ - Dwarf_Word vma_base; - if ((fde_encoding & 0x70) == DW_EH_PE_pcrel && ehdr->e_type != ET_REL) - vma_base = shdr->sh_addr + initial_location; - else - vma_base = 0; - /* Handle the initialization instructions. */ print_cfa_program (readp, cieend, vma_base, code_alignment_factor, data_alignment_factor, ptr_size, dwflmod, ebl, dbg); -- cgit v1.2.3