This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fix addr2line and -msym32 and mips64 (Linux kernel)
- From: Alan Modra <amodra at gmail dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Fri, 1 Jun 2012 10:37:23 +0930
- Subject: Re: [PATCH] Fix addr2line and -msym32 and mips64 (Linux kernel)
- References: <CA+=Sn1mKCPc-SQTtJ7upsOsjAMi8ywXq7PSNr54AOK7_oTYs6Q@mail.gmail.com>
On Thu, May 31, 2012 at 03:12:01PM -0700, Andrew Pinski wrote:
> * addr2line.c (translate_addresses): Sign extend the pc
> if sign_extend_vma is enabled.
>
> Using addr2line is broken on mips64-linux-gnu with the Linux kernel (-msym32).
That's odd. I fixed this horrible code quite a while ago, but it
doesn't look like I committed it, or even posted it.
Now committed.
* addr2line.c (translate_addresses): Truncate input addresses to
arch_size bits. Avoid undefined shift. Print '?' for zero line.
Index: binutils/addr2line.c
===================================================================
RCS file: /cvs/src/src/binutils/addr2line.c,v
retrieving revision 1.40
diff -u -p -r1.40 addr2line.c
--- binutils/addr2line.c 13 Oct 2011 15:33:32 -0000 1.40
+++ binutils/addr2line.c 23 Jan 2012 01:38:49 -0000
@@ -196,8 +196,6 @@ find_offset_in_section (bfd *abfd, asect
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
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
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
--
Alan Modra
Australia Development Lab, IBM