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]

[RFA:] _bfd_strip_section_from_output to handle s->output_section == NULL


In elf32-cris.c, I can get a .rela.got with no output section
while linking statically against a lib.a compiled -fpic.  Other
ports don't get that because they don't strip empty output
sections as aggressively; they typically have an empty .rela.got
section in the output in this case.

The question is, should _bfd_strip_section_from_output handle
being called with s->output_section being NULL?

It could be seen as a prerequisite for calling
_bfd_strip_section_from_output that `s' *has* an output_section,
and that the caller is responsible for checking, as exemplified
in this patch (not committed).

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.6
diff -p -c -r1.6 elf32-cris.c
*** elf32-cris.c	2001/04/17 12:32:30	1.6
--- elf32-cris.c	2001/05/10 02:37:29
*************** elf_cris_size_dynamic_sections (output_b
*** 2793,2799 ****
  
        if (strip)
  	{
! 	  _bfd_strip_section_from_output (info, s);
  	  continue;
  	}
  
--- 2793,2803 ----
  
        if (strip)
  	{
! 	  /* The output section might never have been created, and
! 	     _bfd_strip_section_from_output does not handle that.
! 	     FIXME: Perhaps it should.  */
! 	  if (s->output_section)
! 	    _bfd_strip_section_from_output (info, s);
  	  continue;
  	}

Handling an empty output_section seems a bit better to me,
though.  Ok to commit?

2001-05-10  Hans-Peter Nilsson  <hp@axis.com>

	* section.c (_bfd_strip_section_from_output): Handle NULL
	output_section.

Index: section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.31
diff -p -c -r1.31 section.c
*** section.c	2001/04/14 14:23:31	1.31
--- section.c	2001/05/10 02:56:46
*************** _bfd_strip_section_from_output (info, s)
*** 1217,1222 ****
--- 1238,1248 ----
       orders have not yet been set up.  So why are we checking them? --
       Ian */
    os = s->output_section;
+ 
+   /* It might already have been stripped, or was never created.  */
+   if (os == NULL)
+     return;
+ 
    for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next)
      if (p->type == bfd_indirect_link_order
  	&& p->u.indirect.section == s)

  
brgds, H-P


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