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]

Fix .sbss problem with objcopy of MIPS prelinked binaries


This patch fixes a problem with objcopy applied to some prelinked
binaries on MIPS.

The prelinker sometimes need to convert BSS sections from NOBITS to
PROGBITS.  One case arising on MIPS is that .sbss is followed by .bss
and .sbss is converted to PROGBITS because the prelinker needs to
insert .dynbss (PROGBITS) at the start of the following .bss section.

The prelinked binary now has a PROGBITS section called .sbss (which is
entirely valid ELF; section names are not meant to be significant).
This binary is then copied with objcopy or strip.  objcopy converts
the .sbss section back to NOBITS, corrupting the binary (NOBITS
sections need to go together at the end of the segment).
_bfd_mips_elf_section_processing, run before writing out sections, is
at fault.  This patch removes the special .sbss handling in that
function, so fixing the problem.  The section remains in
_bfd_mips_elf_special_sections so the right flags should be set when
BFD creates it not from an input file, and if reading from an ELF
input file the flags should be taken from that input file, which is
the right thing to do.

Tested with no regressions with cross to mips-linux-gnu; also tested
(with this patch applied to a modified binutils version) that patched
binutils will still build a working glibc and pass GCC tests.  OK to
commit?

2009-02-03  Joseph Myers  <joseph@codesourcery.com>

	* elfxx-mips.c (_bfd_mips_elf_section_processing): Remove special
	.sbss handling.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.252
diff -u -p -r1.252 elfxx-mips.c
--- bfd/elfxx-mips.c	29 Jan 2009 16:35:03 -0000	1.252
+++ bfd/elfxx-mips.c	3 Feb 2009 15:26:30 -0000
@@ -6253,11 +6253,6 @@ _bfd_mips_elf_section_processing (bfd *a
 	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
 	  hdr->sh_type = SHT_PROGBITS;
 	}
-      else if (strcmp (name, ".sbss") == 0)
-	{
-	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
-	  hdr->sh_type = SHT_NOBITS;
-	}
       else if (strcmp (name, ".srdata") == 0)
 	{
 	  hdr->sh_flags |= SHF_ALLOC | SHF_MIPS_GPREL;

-- 
Joseph S. Myers
joseph@codesourcery.com


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