This is the mail archive of the binutils@sourceware.org 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]

[PATCH] HPPA/BFD: Fix no-.data DT_HP_LOAD_MAP segfault


Hi,

 This change fixes a 64-bit HPPA linker crash when a dynamic ELF output 
object is requested, but there's no .data section output, typically 
because of the use of the /DISCARD/ linker script keyword.  I gather the 
section is used for some statically allocated data area defined by the ABI 
and pointed to by the HP_LOAD_MAP dynamic tag.  As such I suppose such 
binaries are not ABI compliant, but the linker shouldn't crash regardless, 
so I propose the following simple fix that makes the linker fail with: 
"final link failed: Nonrepresentable section on output" instead.

 I found the problem reproducible with the hppa64-linux-gnu and 
hppa64-hp-hpux11.23 targets.

 OK to apply?  I revealed this in some unrelated testing so based on that 
I suppose I can cook up a test case to cover this specifically if that 
would help.  Alternatively please feel free to propose a better fix.

2013-07-27  Maciej W. Rozycki  <macro@linux-mips.org>

	* elf64-hppa.c (elf64_hppa_finish_dynamic_sections)
	<DT_HP_LOAD_MAP>: Return unsuccessfully if there's no `.data'
	section.

  Maciej

binutils-2.23.52-20130506-ld-hp-load-map.patch
Index: binutils/bfd/elf64-hppa.c
===================================================================
--- binutils.orig/bfd/elf64-hppa.c
+++ binutils/bfd/elf64-hppa.c
@@ -2524,6 +2524,8 @@ elf64_hppa_finish_dynamic_sections (bfd 
 		 area at the start of the .data section.  So all we have to
 		 to is find the start of the .data section.  */
 	      s = bfd_get_section_by_name (output_bfd, ".data");
+	      if (!s)
+		return FALSE;
 	      dyn.d_un.d_ptr = s->vma;
 	      bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
 	      break;


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