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: link script updates for .jcr


On Sun, Aug 12, 2001 at 01:23:27PM -0700, Richard Henderson wrote:
> There is an orphan section placement bug that is causing
> gcc.dg/special/gcsec-1.c to fail with a linker abort about
> too many segment headers.

The sequence of events goes something like this:

1) lang_place_orphans calls ldemul_place_orphan (ldlang.c:3746) for
crtbegin.o:.jcr, which has been garbage collected, so SEC_EXCLUDE is set.
elf32.em:place_orphan returns false in this situation, signifying that it
hasn't handled the section.  Bug number one, we should return true.

2) That leads to the generic code at ldlang.c:3750 creating an
output_section_statement for .jcr.  Rather useless since it doesn't have
a bfd_section because wild_doit also tests SEC_EXCLUDE.

3) ldemul_place_orphan is called again, this time for crtend.o:.jcr,
which hasn't been garbage collected.  We don't hit the wild_doit at
elf32.em:1087 because os->bfd_section is NULL.  Bug number two, we
shouldn't care if os->bfd_section is NULL.  Later, elf32.em:1197
_doesn't_ create an output_section_statement, because there's already
an existing one created by (2).  That means no statements have been
tacked onto `add', so the code at the end of ..place_orphan doesn't
shuffle output_section_statements and we end up with .jcr at the head
of the list.  Net result is we need another segment to map this section,
as we now have data, text, data.


I'll check in the following after running the testsuite.

	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Return
	`true' for SEC_EXCLUDE sections so that the generic code doesn't
	needlessly create an output_section_statement.  Treat a correctly
	named output_section_statement with NULL bfd_section as compatible.

-- 
Alan Modra

Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.53
diff -u -p -r1.53 elf32.em
--- elf32.em	2001/08/09 14:44:18	1.53
+++ elf32.em	2001/08/13 10:40:42
@@ -1079,11 +1079,12 @@ gld${EMULATION_NAME}_place_orphan (file,
       os = lang_output_section_find (secname);
 
       if (os != NULL
-	  && os->bfd_section != NULL
-	  && ((s->flags ^ os->bfd_section->flags)
-	      & (SEC_LOAD | SEC_ALLOC)) == 0)
+	  && (os->bfd_section == NULL
+	      || ((s->flags ^ os->bfd_section->flags)
+		  & (SEC_LOAD | SEC_ALLOC)) == 0))
 	{
-	  /* We have already placed a section with this name.  */
+	  /* We already have an output section statement with this
+	     name, and its bfd section, if any, has compatible flags.  */
 	  wild_doit (&os->children, s, os, file);
 	  return true;
 	}
@@ -1112,7 +1113,7 @@ gld${EMULATION_NAME}_place_orphan (file,
 (hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL)
 
   if (s->flags & SEC_EXCLUDE)
-    return false;
+    return true;
 
   place = NULL;
   if ((s->flags & SEC_ALLOC) == 0)


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