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]

Re: Patch: Zero out the allocated dynamic content space.


Hi Guys,

  Time for an executive decision.  I agree with Ian that we really
  ought to fix the underlying problem, but given that:

    a) we all very busy

    b) half the ports already the bfd_zalloc method to get around this
       problem
  
    c) even those ports that do it right call bfd_zalloc, just in case
       a bug creeps in

  I have decided to apply H.J.'s patch along with Alan's suggestion of
  adding a comment to remind us that one day we really ought to clean
  this code up.  (Or more probably,one day we will move over to a
  libelf based linker and can abandon this code).

   I am reproducing the modified patch below.  I will use H.J's
   ChangeLog entry.

Cheers
	Nick


Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src//src/bfd/elf32-i386.c,v
retrieving revision 1.15
diff -p -r1.15 elf32-i386.c
*** elf32-i386.c	2000/07/20 03:21:59	1.15
--- elf32-i386.c	2000/08/21 23:34:52
*************** elf_i386_size_dynamic_sections (output_b
*** 1198,1204 ****
  	}
  
        /* Allocate memory for the section contents.  */
!       s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
        if (s->contents == NULL && s->_raw_size != 0)
  	return false;
      }
--- 1198,1209 ----
  	}
  
        /* Allocate memory for the section contents.  */
!       /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
! 	 Unused entries should be reclaimed before the section's contents
! 	 are written out, but at the moment this does not happen.  Thus in
! 	 order to prevent writing out garbage, we initialise the section's
! 	 contents to zero.  */
!       s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
        if (s->contents == NULL && s->_raw_size != 0)
  	return false;
      }

Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src//src/bfd/elf32-m68k.c,v
retrieving revision 1.15
diff -p -r1.15 elf32-m68k.c
*** elf32-m68k.c	2000/07/20 03:21:59	1.15
--- elf32-m68k.c	2000/08/21 23:34:52
*************** elf_m68k_size_dynamic_sections (output_b
*** 1267,1273 ****
  	}
  
        /* Allocate memory for the section contents.  */
!       s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
        if (s->contents == NULL && s->_raw_size != 0)
  	return false;
      }
--- 1267,1278 ----
  	}
  
        /* Allocate memory for the section contents.  */
!       /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
! 	 Unused entries should be reclaimed before the section's contents
! 	 are written out, but at the moment this does not happen.  Thus in
! 	 order to prevent writing out garbage, we initialise the section's
! 	 contents to zero.  */
!       s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
        if (s->contents == NULL && s->_raw_size != 0)
  	return false;
      }

Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src//src/bfd/elf64-hppa.c,v
retrieving revision 1.4
diff -p -r1.4 elf64-hppa.c
*** elf64-hppa.c	2000/07/20 03:21:59	1.4
--- elf64-hppa.c	2000/08/21 23:34:53
*************** elf64_hppa_size_dynamic_sections (output
*** 1740,1746 ****
  	 been allocated already.  */
        if (s->contents == NULL)
  	{
! 	  s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
  	  if (s->contents == NULL && s->_raw_size != 0)
  	    return false;
  	}
--- 1740,1751 ----
  	 been allocated already.  */
        if (s->contents == NULL)
  	{
! 	  /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
! 	     Unused entries should be reclaimed before the section's contents
! 	     are written out, but at the moment this does not happen.  Thus in
! 	     order to prevent writing out garbage, we initialise the section's
! 	     contents to zero.  */
! 	  s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
  	  if (s->contents == NULL && s->_raw_size != 0)
  	    return false;
  	}


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