fix mmix ld testsuite failures

Alan Modra amodra@bigpond.net.au
Wed Aug 17 13:31:00 GMT 2005


This patch fixes the majority of failing mmix ld tests, by ensuring that
special sections are not removed by the zero size section stripping
code.  I'm unsure as to the correct fix for the single remaining
failure, bpo-10, which is due to a zero size .text being stripped.
.text seems to be special on mmix, so I'm wondering whether it should
always be kept?

	* elf64-mmix.c (mmix_elf_add_symbol_hook): Mark reg section
	SEC_LINKER_CREATED.
	(mmix_elf_final_link): Check that section hasn't already been
	removed before removing.
	* mmo.c (mmo_scan): Mark reg contents section SEC_LINKER_CREATED.
	(mmo_canonicalize_symtab): Likewise for reg section.

Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.46
diff -u -p -r1.46 elf64-mmix.c
--- bfd/elf64-mmix.c	20 Jun 2005 18:12:08 -0000	1.46
+++ bfd/elf64-mmix.c	17 Aug 2005 13:19:58 -0000
@@ -2184,7 +2184,10 @@ mmix_elf_add_symbol_hook (abfd, info, sy
      bfd_vma *valp ATTRIBUTE_UNUSED;
 {
   if (sym->st_shndx == SHN_REGISTER)
-    *secp = bfd_make_section_old_way (abfd, MMIX_REG_SECTION_NAME);
+    {
+      *secp = bfd_make_section_old_way (abfd, MMIX_REG_SECTION_NAME);
+      (*secp)->flags |= SEC_LINKER_CREATED;
+    }
   else if ((*namep)[0] == '_' && (*namep)[1] == '_' && (*namep)[2] == '.'
 	   && strncmp (*namep, MMIX_LOC_SECTION_START_SYMBOL_PREFIX,
 		       strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)) == 0)
@@ -2261,9 +2264,12 @@ mmix_elf_final_link (abfd, info)
       if (bfd_get_section_flags (abfd, reg_section) & SEC_HAS_CONTENTS)
 	_bfd_abort (__FILE__, __LINE__, _("Register section has contents\n"));
 
-      /* Really remove the section.  */
-      bfd_section_list_remove (abfd, reg_section);
-      --abfd->section_count;
+      /* Really remove the section, if it hasn't already been done.  */
+      if (!bfd_section_removed_from_list (abfd, reg_section))
+	{
+	  bfd_section_list_remove (abfd, reg_section);
+	  --abfd->section_count;
+	}
     }
 
   if (! bfd_elf_final_link (abfd, info))
Index: bfd/mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.28
diff -u -p -r1.28 mmo.c
--- bfd/mmo.c	23 May 2005 17:44:55 -0000	1.28
+++ bfd/mmo.c	17 Aug 2005 13:19:59 -0000
@@ -1853,6 +1853,7 @@ mmo_scan (bfd *abfd)
 		    rsec
 		      = bfd_make_section_old_way (abfd,
 						  MMIX_REG_CONTENTS_SECTION_NAME);
+		    rsec->flags |= SEC_LINKER_CREATED;
 		    rsec->vma = z * 8;
 		    loc = mmo_get_loc (rsec, z * 8, (255 - z) * 8);
 		    bfd_put_64 (abfd, first_octa, loc);
@@ -2146,6 +2147,7 @@ mmo_canonicalize_symtab (bfd *abfd, asym
 	    {
 	      c->section
 		= bfd_make_section_old_way (abfd, MMIX_REG_SECTION_NAME);
+	      c->section->flags |= SEC_LINKER_CREATED;
 	    }
 	  else
 	    {

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list