Another proposed bfd/elf.c change

Alan Modra alan@linuxcare.com.au
Mon May 8 17:26:00 GMT 2000


This little patch is aimed at fixing the mips simple objcopy test
failure.  mips is unusual in that it puts both rel and rela sections into
a .o (why?), thus target_sect (eg. .text) below gets use_rela_p set
depending on which of the rel and rela sections came last.

The only problem with this fix as far as I can see is if an object file
has one reloc section of a different type than the default for the target,
and it happens to be empty.

Comments?  Safe to commit?  Who is the mips maintainer anyway?

Regards, Alan Modra


Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf.c
--- elf.c	2000/05/05 18:12:53	1.30
+++ elf.c	2000/05/08 23:52:18
@@ -1354,8 +1354,9 @@ bfd_section_from_shdr (abfd, shindex)
 	target_sect->rel_filepos = hdr->sh_offset;
 	/* In the section to which the relocations apply, mark whether
 	   its relocations are of the REL or RELA variety.  */
-	elf_section_data (target_sect)->use_rela_p 
-	  = (hdr->sh_type == SHT_RELA);
+	if (hdr->sh_size != 0)
+	  elf_section_data (target_sect)->use_rela_p
+	    = (hdr->sh_type == SHT_RELA);
 	abfd->flags |= HAS_RELOC;
 	return true;
       }

-- 
Linuxcare.  Support for the Revolution.



More information about the Binutils mailing list