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]

[PATCH] Fix -Ttext -z combreloc (was Re: Not enough room for program headers (problem with 2.11.92.0.5))


Hi!

On Wed, Oct 17, 2001 at 09:16:36AM -0700, H . J . Lu wrote:
> On Wed, Oct 17, 2001 at 06:11:08PM +0200, Jakub Jelinek wrote:
> > > Don't use -z combreloc in this case. That is one reason why I didn't
> > > turn on -z combreloc by default in my binutils. It should only be done
> > > when it makes senses and is safe. It looks like no one should turn on
> > > -z combreloc by default unless everything is worked out.
> > 
> > Can I get a copy of misc.o (or misc.i)?
> > -z combreloc really should be the default, the speed advantages are huge, so
> > if there is some issue with it, I'd like to debug it.
> > 
> 
> See misc.i in
> 
> http://sources.redhat.com/ml/bug-gnu-utils/2001-10/msg00194.html

What happens is that _bfd_strip_section_from_output was not ever stripping
output .rel.dyn section, because 2 different sections in dynobj had it as
their output_section (.rel.text and .rel.data). As
_bfd_strip_section_from_output doesn't change the input sections in any way,
when calling it on .rel.text it wasn't stripped because .rel.data pointed to
it too (that's correct), but when calling it on .rel.data, it wasn't
stripped because .rel.text pointed to it too (but .rel.text shouldn't count
as reference since _bfd_strip_section_from_output was called on it already).
Here are 2 alternative patches, the first one uses SEC_EXCLUDE flag to mark
input section's whose output was stripped, the second one makes a copy of
the output section. Setting s->output_section to bfd_abs_section_ptr doesn't
work, it is too late.
Ok to commit the first one (provided you think I can abuse SEC_EXCLUDE flag
for this - make check passed)?

	Jakub
2001-10-17  Jakub Jelinek  <jakub@redhat.com>

	* section.c (_bfd_strip_section_from_output): Don't count
	SEC_EXCLUDE sections as references.  Set SEC_EXCLUDE.

--- bfd/section.c.jj	Thu Oct 11 12:38:15 2001
+++ bfd/section.c	Wed Oct 17 20:16:24 2001
@@ -1250,7 +1250,8 @@ _bfd_strip_section_from_output (info, s)
 	  asection *is;
 	  for (is = abfd->sections; is != NULL; is = is->next)
 	    {
-	      if (is != s && is->output_section == os)
+	      if (is != s && is->output_section == os
+		  && (is->flags & SEC_EXCLUDE) == 0)
 		break;
 	    }
 	  if (is != NULL)
@@ -1273,4 +1274,6 @@ _bfd_strip_section_from_output (info, s)
 	    break;
 	  }
     }
+
+  s->flags |= SEC_EXCLUDE;
 }
2001-10-17  Jakub Jelinek  <jakub@redhat.com>

	* section.c (_bfd_strip_section_from_output): Strip output section
	from output even if it has multiple different input sections and
	_bfd_strip_section_from_output has been called for all of them.

--- bfd/section.c.jj	Thu Oct 11 12:38:15 2001
+++ bfd/section.c	Wed Oct 17 20:06:55 2001
@@ -1257,7 +1257,24 @@ _bfd_strip_section_from_output (info, s)
 	    break;
 	}
       if (abfd != NULL)
-	keep_os = true;
+	{
+	  struct asection *newos;
+
+	  newos = (asection *) bfd_zalloc (os->owner,
+					   (bfd_size_type) sizeof (asection));
+	  if (newos != NULL)
+	    {
+	      /* If os has more than one input section, change s's output
+		 section so that it doesn't count in possible next
+		 _bfd_strip_section_from_output invocation.
+		 It is too late to set it bfd_abs_section_ptr though,
+		 so point it to os's copy which will not be linked in
+		 os->owner's section list.  */
+	      memcpy (newos, os, sizeof (asection));
+	      s->output_section = newos;
+	    }
+	  keep_os = true;
+	}
     }
 
   /* If the output section is empty, remove it too.  Careful about sections

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