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]
Other format: [Raw text]

Re: LD patch to silence warnings about removed sections


Alan Modra <amodra@bigpond.net.au> writes:
> > + 	    /* The section might have been removed after its statement was
> > + 	       added.  For example, ldemul_before_allocation can remove
> > + 	       dynamic sections if they turn out not to be needed.  */
> > + 	    if ((bfd_get_section_flags (output_bfd, os->bfd_section)
> > + 		 & SEC_EXCLUDE) != 0)
> > + 	      break;
> > + 
> 
> Hmm, this will break "ld -r".  eg. for objects containing ELF
> SHT_GROUP sections, and probably other cases.  Please test
> !link_info.relocateable too.  OK with that change.

Thanks.  For the record, here's what I checked in, after retesting
on mips64-elf.

Richard


[bfd/]
	* section.c (_bfd_strip_section_from_output): Set SEC_EXCLUDE
	for removed output sections.

[ld/]
	* ldlang.c (lang_size_sections_1): Skip removed output sections.

[ld/testsuite/]
	* ld-mips-elf/region1a.s,
	* ld-mips-elf/region1b.s,
	* ld-mips-elf/region1.t,
	* ld-mips-elf/region1.d: New test.
	* ld-mips-elf/mips-elf.exp: Run it.

Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.47
diff -c -d -p -r1.47 section.c
*** bfd/section.c	5 Jun 2002 03:43:11 -0000	1.47
--- bfd/section.c	10 Jun 2002 16:00:46 -0000
*************** _bfd_strip_section_from_output (info, s)
*** 1368,1373 ****
--- 1368,1374 ----
  	if (*spp == os)
  	  {
  	    bfd_section_list_remove (os->owner, spp);
+ 	    os->flags |= SEC_EXCLUDE;
  	    os->owner->section_count--;
  	    break;
  	  }
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.89
diff -c -d -p -r1.89 ldlang.c
*** ld/ldlang.c	4 Jun 2002 01:07:29 -0000	1.89
--- ld/ldlang.c	10 Jun 2002 16:00:46 -0000
*************** lang_size_sections_1 (s, output_section_
*** 2907,2912 ****
--- 2907,2920 ----
  	      /* This section was never actually created.  */
  	      break;
  
+ 	    /* The section might have been removed after its statement was
+ 	       added.  For example, ldemul_before_allocation can remove
+ 	       dynamic sections if they turn out not to be needed.  */
+ 	    if (!link_info.relocateable
+ 		&& (bfd_get_section_flags (output_bfd, os->bfd_section)
+ 		    & SEC_EXCLUDE) != 0)
+ 	      break;
+ 
  	    /* If this is a COFF shared library section, use the size and
  	       address from the input section.  FIXME: This is COFF
  	       specific; it would be cleaner if there were some other way
Index: ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v
retrieving revision 1.2
diff -c -d -p -r1.2 mips-elf.exp
*** ld/testsuite/ld-mips-elf/mips-elf.exp	30 Jan 2002 02:20:13 -0000	1.2
--- ld/testsuite/ld-mips-elf/mips-elf.exp	10 Jun 2002 16:00:46 -0000
*************** if { [istarget mips*-*-*] } then {
*** 38,42 ****
--- 38,44 ----
  	# Check generation of embedded relocs section.
  	run_dump_test "emrelocs-eb"
  	run_dump_test "emrelocs-el"
+ 
+ 	run_dump_test "region1"
      }
  }
*** /dev/null	Tue Nov 14 21:44:43 2000
--- ld/testsuite/ld-mips-elf/region1a.s	Fri Jun  7 16:35:46 2002
***************
*** 0 ****
--- 1,3 ----
+ 	.text
+ 	.global foo
+ foo:	.4byte	1
*** /dev/null	Tue Nov 14 21:44:43 2000
--- ld/testsuite/ld-mips-elf/region1b.s	Fri Jun  7 16:36:29 2002
***************
*** 0 ****
--- 1,2 ----
+ 	.data
+ 	.4byte	foo
*** /dev/null	Tue Nov 14 21:44:43 2000
--- ld/testsuite/ld-mips-elf/region1.d	Fri Jun  7 16:36:08 2002
***************
*** 0 ****
--- 1,11 ----
+ # as: -mabi=eabi -mips1 -G0
+ # source: region1a.s
+ # source: region1b.s
+ # ld: -T region1.t
+ # name: MIPS region1
+ # objdump: --headers
+ #...
+   0 \.text +0+004 +0+10000 .*
+ #...
+   1 \.data +0+004 +0+20000 .*
+ #pass
*** /dev/null	Tue Nov 14 21:44:43 2000
--- ld/testsuite/ld-mips-elf/region1.t	Fri Jun  7 16:37:23 2002
***************
*** 0 ****
--- 1,12 ----
+ MEMORY
+ {
+   TEXTMEM : ORIGIN = 0x10000, LENGTH = 32K
+   DATAMEM : ORIGIN = 0x20000, LENGTH = 32K
+ }
+ 
+ SECTIONS
+ {
+   .text : { *(.text) } > TEXTMEM
+   .data : { *(.data) } > DATAMEM
+   .bss  : { *(.bss)  } > DATAMEM
+ }


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