This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
64-bit host failures, sh
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 27 Feb 2012 17:16:01 +1030
- Subject: 64-bit host failures, sh
- Authentication-results: mr.google.com; spf=pass (google.com: domain of amodra@gmail.com designates 10.68.125.168 as permitted sender) smtp.mail=amodra@gmail.com; dkim=pass header.i=amodra@gmail.com
- References: <20120227063137.GB3613@bubble.grove.modra.org>
Fixes another failure only seen on 64-bit hosts
sh-linux +FAIL: SH relaxing to S-records
sh-rtems +FAIL: SH relaxing to S-records
This one is a segfault. sh_elf_osec_to_segment returns -1u on failure
and sh_elf_osec_readonly_p blindly uses this value to index an array.
On a 32-bit host you read array[-1], while on a 64-bit host you read
array[4G-1].
* elf32-sh.c (sh_elf_osec_to_segment): Check for elf flavour bfd
before calling elf specific function.
(sh_elf_osec_readonly_p): Test for error return from above.
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.173
diff -u -p -r1.173 elf32-sh.c
--- bfd/elf32-sh.c 19 Oct 2011 07:17:14 -0000 1.173
+++ bfd/elf32-sh.c 26 Feb 2012 03:49:06 -0000
@@ -3788,8 +3788,10 @@ sh_elf_got_offset (struct elf_sh_link_ha
static unsigned
sh_elf_osec_to_segment (bfd *output_bfd, asection *osec)
{
- Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section (output_bfd,
- osec);
+ Elf_Internal_Phdr *p = NULL;
+
+ if (output_bfd->xvec->flavour == bfd_target_elf_flavour)
+ p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
/* FIXME: Nothing ever says what this index is relative to. The kernel
supplies data in terms of the number of load segments but this is
@@ -3802,7 +3804,8 @@ sh_elf_osec_readonly_p (bfd *output_bfd,
{
unsigned seg = sh_elf_osec_to_segment (output_bfd, osec);
- return ! (elf_tdata (output_bfd)->phdr[seg].p_flags & PF_W);
+ return (seg != (unsigned) -1
+ && ! (elf_tdata (output_bfd)->phdr[seg].p_flags & PF_W));
}
/* Generate the initial contents of a local function descriptor, along
--
Alan Modra
Australia Development Lab, IBM