This is the mail archive of the binutils@sources.redhat.com 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]

elf tdata allocation error


This fixes an embarrassing error in allocation of an input bfd's tdata
for those targets that extend elf_obj_tdata.  The problem is that
xxx_elf_mkobject is only called on output bfd's, fixed by the following.

	* elfcode.h (elf_object_p): Allocate tdata via _bfd_set_format.
	* elfcore.h (elf_core_file_p): Likewise.
	* section.c (bfd_section_init): Remove prototype.

Index: bfd/elfcode.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcode.h,v
retrieving revision 1.45
diff -u -p -r1.45 elfcode.h
--- bfd/elfcode.h	4 Jul 2003 01:50:11 -0000	1.45
+++ bfd/elfcode.h	8 Jul 2003 07:05:54 -0000
@@ -570,17 +570,15 @@ elf_object_p (abfd)
       goto got_wrong_format_error;
     }
 
+  if (!bfd_preserve_save (abfd, &preserve))
+    goto got_no_match;
+
   /* Allocate an instance of the elf_obj_tdata structure and hook it up to
      the tdata pointer in the bfd.  */
 
-  amt = sizeof (struct elf_obj_tdata);
-  preserve.marker = bfd_zalloc (abfd, amt);
-  if (preserve.marker == NULL)
+  if (! (*abfd->xvec->_bfd_set_format[bfd_object]) (abfd))
     goto got_no_match;
-  if (!bfd_preserve_save (abfd, &preserve))
-    goto got_no_match;
-
-  elf_tdata (abfd) = preserve.marker;
+  preserve.marker = elf_tdata (abfd);
 
   /* Now that we know the byte order, swap in the rest of the header */
   i_ehdrp = elf_elfheader (abfd);
Index: bfd/elfcore.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcore.h,v
retrieving revision 1.17
diff -u -p -r1.17 elfcore.h
--- bfd/elfcore.h	14 Feb 2003 09:21:21 -0000	1.17
+++ bfd/elfcore.h	8 Jul 2003 07:05:54 -0000
@@ -122,15 +122,13 @@ elf_core_file_p (abfd)
       goto wrong;
     }
 
-  /* Give abfd an elf_obj_tdata.  */
-  amt = sizeof (struct elf_obj_tdata);
-  preserve.marker = bfd_zalloc (abfd, amt);
-  if (preserve.marker == NULL)
-    goto fail;
   if (!bfd_preserve_save (abfd, &preserve))
     goto fail;
 
-  elf_tdata (abfd) = preserve.marker;
+  /* Give abfd an elf_obj_tdata.  */
+  if (! (*abfd->xvec->_bfd_set_format[bfd_core]) (abfd))
+    goto fail;
+  preserve.marker = elf_tdata (abfd);
 
   /* Swap in the rest of the header, now that we have the byte order.  */
   i_ehdrp = elf_elfheader (abfd);
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.58
diff -u -p -r1.58 section.c
--- bfd/section.c	4 Jul 2003 04:14:56 -0000	1.58
+++ bfd/section.c	8 Jul 2003 07:05:56 -0000
@@ -705,8 +705,6 @@ bfd_section_hash_newfunc (struct bfd_has
 
 /* Initializes a new section.  NEWSECT->NAME is already set.  */
 
-static asection *bfd_section_init PARAMS ((bfd *, asection *));
-
 static asection *
 bfd_section_init (bfd *abfd, asection *newsect)
 {

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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