This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

64-bit host failures, sh

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

	* 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]