summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2009-01-24 22:55:08 -0800
committerRoland McGrath <[email protected]>2009-01-24 22:55:08 -0800
commitea7eb8e8e2606eaf7a895eb4aef06b314e6d5f3e (patch)
tree0ea62afbe045603e41a4bfb17233753ae1c320cb /src
parent47a5d755692acc628684d6579411486afd3a999b (diff)
parent6cbd7adf7eeb3f30632b53c8a68c470e0e47252b (diff)
Merge commit 'origin/master' into dwarf
Conflicts: ChangeLog libdw/ChangeLog src/ChangeLog
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/readelf.c56
-rw-r--r--src/size.c15
-rw-r--r--src/strip.c2
4 files changed, 61 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6e861506..35eb7964 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -117,6 +117,22 @@
* dwarflint.c: Checking for zero padding and unreferenced bytes.
CU size and padding at the end of CU are now checked.
+2009-01-24 Ulrich Drepper <[email protected]>
+
+ * readelf.c (print_debug_frame_section): Fix computation of vma_base
+ for PC-relative mode.
+
+2009-01-23 Ulrich Drepper <[email protected]>
+
+ * size.c (process_file): When handling archive, close file descriptor
+ here. For unknown file format also close file descriptor.
+ (handle_ar): Don't close file descriptor here.
+
+ * readelf.c (parse_opt): Move code to add to dump_data_sections and
+ string_sections list in local function add_dump_section. Adjust 'x'
+ key handling. For 'a' key add .strtab, .dynstr, and .comment section
+ to string_sections list.
+
2009-01-22 Roland McGrath <[email protected]>
* readelf.c (print_phdr): Don't print section mapping when no sections.
diff --git a/src/readelf.c b/src/readelf.c
index 884e799b..254cfcef 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -276,6 +276,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':
@@ -291,6 +302,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':
@@ -388,15 +402,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:
@@ -4054,6 +4060,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))
{
@@ -4220,16 +4227,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')
{
@@ -4270,13 +4287,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);
diff --git a/src/size.c b/src/size.c
index f6f23d55..4698c350 100644
--- a/src/size.c
+++ b/src/size.c
@@ -319,13 +319,23 @@ process_file (const char *fname)
return 0;
}
else if (likely (elf_kind (elf) == ELF_K_AR))
- return handle_ar (fd, elf, NULL, fname);
+ {
+ int result = handle_ar (fd, elf, NULL, fname);
+
+ if (unlikely (close (fd) != 0))
+ error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
+
+ return result;
+ }
/* We cannot handle this type. Close the descriptor anyway. */
if (unlikely (elf_end (elf) != 0))
INTERNAL_ERROR (fname);
}
+ if (unlikely (close (fd) != 0))
+ error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
+
error (0, 0, gettext ("%s: file format not recognized"), fname);
return 1;
@@ -396,9 +406,6 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname)
if (unlikely (elf_end (elf) != 0))
INTERNAL_ERROR (fname);
- if (unlikely (close (fd) != 0))
- error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
-
return result;
}
diff --git a/src/strip.c b/src/strip.c
index 1958bb51..27eb2106 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -437,7 +437,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
int debug_fd = -1;
/* Get the EBL handling. The -g option is currently the only reason
- we need EBL so dont open the backend unless necessary. */
+ we need EBL so don't open the backend unless necessary. */
Ebl *ebl = NULL;
if (remove_debug)
{