+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
static void
translate_addresses (bfd *abfd, asection *section)
{
- const struct elf_backend_data * bed;
-
int read_stdin = (naddr == 0);
for (;;)
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)
{
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