This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
hppa unwind entries
- From: Nick Hudson <nick dot hudson at dsl dot pipex dot com>
- To: binutils at sourceware dot org
- Date: Wed, 12 Dec 2007 13:18:20 +0000
- Subject: hppa unwind entries
Hi,
Here's a test case that produces incorrect unwind entries on hpppa
$ cat foo.s
.text
.export foo, entry
.label foo
.proc
.callinfo frame=0
.entry
bv %r0(%rp)
nop
.exit
.procend
.size foo, .-foo
.end
$ hppa--netbsd-as -o foo.o foo.s
$ hppa--netbsd-ld -Ttext 0x20000 -e foo -o foo foo.o
$ readelf -u foo
Unwind section '.PARISC.unwind' at offset 0x1008 contains 1 entries:
<foo+1000>: [0x21000-0x21004]
$
Note the "<foo+1000>"
It seems to me that the calculation of text_segment_base and data_segment_base
are incorrect and here's a patch that address the problem by using the method
ia64 SEGREL stuff is done.
Is this right? Is there a simpler way?
All help gratefully received.
Thanks,
Nick
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.157
diff -u -p -u -r1.157 elf32-hppa.c
--- bfd/elf32-hppa.c 26 Sep 2007 13:45:32 -0000 1.157
+++ bfd/elf32-hppa.c 12 Dec 2007 13:11:59 -0000
@@ -3256,7 +3256,7 @@ elf32_hppa_final_link (bfd *abfd, struct
/* Record the lowest address for the data and text segments. */
static void
-hppa_record_segment_addr (bfd *abfd ATTRIBUTE_UNUSED,
+hppa_record_segment_addr (bfd *abfd,
asection *section,
void *data)
{
@@ -3266,8 +3266,28 @@ hppa_record_segment_addr (bfd *abfd ATTR
if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
{
- bfd_vma value = section->vma - section->filepos;
+ bfd_vma value;
+ struct elf_segment_map *m;
+ Elf_Internal_Phdr *p;
+
+ /* Find the segment that contains the output_section. */
+ for (m = elf_tdata (abfd)->segment_map,
+ p = elf_tdata (abfd)->phdr;
+ m != NULL;
+ m = m->next, p++)
+ {
+ int i;
+ for (i = m->count - 1; i >= 0; i--)
+ if (m->sections[i] == section->output_section)
+ break;
+ if (i >= 0)
+ break;
+ }
+
+ if (m == NULL)
+ return;
+ value = p->p_vaddr;
if ((section->flags & SEC_READONLY) != 0)
{
if (value < htab->text_segment_base)