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]

[rfc] eh-frame clobbers memory


On Alpha, and I presume other 64-bit targets, we're expanding the
size of the eh-frame section and overwriting the buffer allocated.
This can be seen in a gcc build for sure, and perhaps one of the
ld testsuite cases.

The eh-frame expansion is in this case pointless, and should be
fixed.  But since we legitimately have some cases in which we 
should be growing the size (e.g. recoding as pic), the buffer
overflow should be as well.

I *think* the following is all we need.  At least I can build
gcc with this installed...


r~



	* elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Reallocate
	contents if the section size grew.

Index: elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.47
diff -u -p -d -r1.47 elf-eh-frame.c
--- elf-eh-frame.c	4 May 2005 15:53:07 -0000	1.47
+++ elf-eh-frame.c	22 May 2005 10:08:15 -0000
@@ -994,6 +994,9 @@ _bfd_elf_write_section_eh_frame (bfd *ab
     return bfd_set_section_contents (abfd, sec->output_section, contents,
 				     sec->output_offset, sec->size);
 
+  if (sec->size > sec->rawsize)
+    contents = bfd_realloc (contents, sec->size);
+
   ptr_size = (get_elf_backend_data (abfd)
 	      ->elf_backend_eh_frame_address_size (abfd, sec));
   BFD_ASSERT (ptr_size != 0);


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