This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA] Handle pc sign extension in addr2line
- From: Catherine Moore <clm at codesourcery dot com>
- To: binutils at sourceware dot org
- Cc: clm at codesourcery dot com
- Date: Mon, 28 Mar 2011 13:15:34 -0400
- Subject: [RFA] Handle pc sign extension in addr2line
This patch fixes a problem with addr2line's failure to print line number
information for mips configurations. addr2line translates an address
that's passed on the command line. That address needs to be
sign-extended if the bfd backend uses a sign-extended vma.
I tested this patch for mips-sde-elf and ppc-eabi configs.
Does this look okay to install?
Thanks,
Catherine
2011-03-28 Catherine Moore <clm@codesourcery.com>
* addr2line.c (translate_addresses): Sign extend the pc
if sign_extend_vma is enabled.
Index: addr2line.c
===================================================================
RCS file: /cvs/src/src/binutils/addr2line.c,v
retrieving revision 1.38
diff -u -r1.38 addr2line.c
--- addr2line.c 29 Oct 2010 12:10:25 -0000 1.38
+++ addr2line.c 28 Mar 2011 17:07:05 -0000
@@ -37,6 +37,7 @@
#include "libiberty.h"
#include "demangle.h"
#include "bucomm.h"
+#include "elf-bfd.h"
static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */
static bfd_boolean with_addresses; /* -a, show addresses. */
@@ -195,6 +196,8 @@
static void
translate_addresses (bfd *abfd, asection *section)
{
+ const struct elf_backend_data * bed;
+
int read_stdin = (naddr == 0);
for (;;)
@@ -215,6 +218,12 @@
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 (with_addresses)
{
printf ("0x");