aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2012-06-01 01:04:29 +0000
committerAlan Modra <amodra@gmail.com>2012-06-01 01:04:29 +0000
commit670b0bad30115b2324a83f7df343cc83f8d0b901 (patch)
treedc47a418a438522a9fab1d86ca5d52d700f445a7
parentcb66d1c01801934773d55bf9c53199834a062000 (diff)
downloadgdb-670b0bad30115b2324a83f7df343cc83f8d0b901.zip
gdb-670b0bad30115b2324a83f7df343cc83f8d0b901.tar.gz
gdb-670b0bad30115b2324a83f7df343cc83f8d0b901.tar.bz2
* addr2line.c (translate_addresses): Truncate input addresses to
arch_size bits. Avoid undefined shift. Print '?' for zero line.
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/addr2line.c22
2 files changed, 19 insertions, 8 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 2b916a8..14d720f 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-01 Alan Modra <amodra@gmail.com>
+
+ * addr2line.c (translate_addresses): Truncate input addresses to
+ arch_size bits. Avoid undefined shift. Print '?' for zero line.
+
2012-05-30 Nick Clifton <nickc@redhat.com>
* readelf.c (process_section_headers): Correct bug in previous
diff --git a/binutils/addr2line.c b/binutils/addr2line.c
index d0f4567..663da45 100644
--- a/binutils/addr2line.c
+++ b/binutils/addr2line.c
@@ -196,8 +196,6 @@ find_offset_in_section (bfd *abfd, asection *section)
static void
translate_addresses (bfd *abfd, asection *section)
{
- const struct elf_backend_data * bed;
-
int read_stdin = (naddr == 0);
for (;;)
@@ -218,11 +216,15 @@ translate_addresses (bfd *abfd, asection *section)
pc = bfd_scan_vma (*addr++, NULL, 16);
}
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && (bed = get_elf_backend_data (abfd)) != NULL
- && bed->sign_extend_vma
- && (pc & (bfd_vma) 1 << (bed->s->arch_size - 1)))
- pc |= ((bfd_vma) -1) << bed->s->arch_size;
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ {
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_vma sign = (bfd_vma) 1 << (bed->s->arch_size - 1);
+
+ pc &= (sign << 1) - 1;
+ if (bed->sign_extend_vma)
+ pc = (pc ^ sign) - sign;
+ }
if (with_addresses)
{
@@ -290,7 +292,11 @@ translate_addresses (bfd *abfd, asection *section)
filename = h + 1;
}
- printf ("%s:%u\n", filename ? filename : "??", line);
+ printf ("%s:", filename ? filename : "??");
+ if (line != 0)
+ printf ("%u\n", line);
+ else
+ printf ("?\n");
if (!unwind_inlines)
found = FALSE;
else