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]

[PATCH] TILEPro/BFD: Correct private object data allocation


 While browsing sources for code reuse I've noticed the TILEPro BFD 
defines its own version of ELF private object data with an extra structure 
member beyond the generic elf_obj_tdata structure.  However it does not 
override the generic bfd_elf_make_object data allocator that only 
guarantees to get elf_obj_tdata worth of memory space.  As a result any 
accesses made to the extra member are out of range and have unpredictable 
semantics, although this may be masked on some systems by extra padding 
provided by malloc(3).

 Anyway, this needs to be fixed, here's my proposal.  No regressions for 
tilepro-elf (obviously my host system must have enough padding there).  
OK to apply?

2012-11-29  Maciej W. Rozycki  <>

	* elf32-tilepro.c (tilepro_elf_mkobject): New function.
	(bfd_elf32_mkobject): New macro.


Index: binutils-fsf-trunk-quilt/bfd/elf32-tilepro.c
--- binutils-fsf-trunk-quilt.orig/bfd/elf32-tilepro.c	2012-11-29 01:52:35.000000000 +0000
+++ binutils-fsf-trunk-quilt/bfd/elf32-tilepro.c	2012-11-29 11:37:52.721797273 +0000
@@ -737,6 +737,16 @@ struct _bfd_tilepro_elf_obj_tdata
    && elf_tdata (bfd) != NULL				\
    && elf_object_id (bfd) == TILEPRO_ELF_DATA)
+/* Allocate TILEPro ELF private object data.  */
+static bfd_boolean
+tilepro_elf_mkobject (bfd *abfd)
+  return bfd_elf_allocate_object (abfd,
+				  sizeof (struct _bfd_tilepro_elf_obj_tdata),
 #include "elf/common.h"
 #include "elf/internal.h"
@@ -4008,6 +4018,8 @@ tilepro_additional_program_headers (bfd 
 #define elf_backend_grok_psinfo              tilepro_elf_grok_psinfo
 #define elf_backend_additional_program_headers tilepro_additional_program_headers
+#define bfd_elf32_mkobject		     tilepro_elf_mkobject
 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_can_gc_sections 1

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