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: Empty section removal broke MIPS


On Wed, Apr 13, 2005 at 09:18:37AM -0700, H. J. Lu wrote:
> On Wed, Apr 13, 2005 at 10:53:29AM -0400, Daniel Jacobowitz wrote:
> > Assemble and link this with a mips64-linux toolchain:
> > 
> >         .section        .sbss
> >         .align  3
> >         .type   bar, @object
> >         .size   bar, 0
> > bar:
> >         .text
> >         .align  2
> >         .globl  __start
> >         .ent    __start
> >         .type   __start, @function
> > __start:
> >         j       $31
> >         .end    __start
> > 
> > You'll get "nonrepresentable section on output".  We try to output the local
> > symbol bar, even though we have removed its section.  This patch appears to
> > work; tested mips64-linux-gnu via the binutils testsuite and by booting a
> > kernel linked with the new linker (the previous linker could not build a UP
> > Linux kernel).
> > 
> 
> I was thinking to add a similar patch when I submitted:
> 
> http://sourceware.org/ml/binutils/2005-04/msg00244.html
> 
> But I don't have a testcase. This one also failed on i386.
> 
> 

I will check in this one as an obvious fix.


H.J.
--
bfd/

2005-04-13  Daniel Jacobowitz  <dan@codesourcery.com>

	* elflink.c (elf_link_input_bfd): Update check for removed
	sections.

ld/testsuite/

2005-04-13  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-elf/empty.d: New file.
	* ld-elf/empty.s: Likewise.

--- binutils/bfd/elflink.c.bss	2005-04-13 08:56:21.000000000 -0700
+++ binutils/bfd/elflink.c	2005-04-13 09:38:52.000000000 -0700
@@ -6950,6 +6950,11 @@ elf_link_input_bfd (struct elf_final_lin
 		  && (isec->flags & SEC_EXCLUDE) != 0)))
 	continue;
 
+      /* If the section is not in the output BFD's section list, it is not
+	 being output.  */
+      if (bfd_section_removed_from_list (output_bfd, isec->output_section))
+	continue;
+
       /* Get the name of the symbol.  */
       name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link,
 					      isym->st_name);
--- binutils/ld/testsuite/ld-elf/empty.d.bss	2005-04-13 09:23:49.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/empty.d	2005-04-13 09:37:20.000000000 -0700
@@ -0,0 +1,7 @@
+#source: empty.s
+#ld:
+#readelf: -s
+
+#...
+[ 	]+[0-9]+:[ 	]+[0-9a-f]+[ 	]+[0-9]+[ 	]+FUNC[	 ]+GLOBAL DEFAULT[ 	]+[1-9] _start
+#pass
--- binutils/ld/testsuite/ld-elf/empty.s.bss	2005-04-13 09:23:46.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/empty.s	2005-04-13 09:35:32.000000000 -0700
@@ -0,0 +1,10 @@
+	.section .bss
+bar:
+	.text
+	.type _start,"function"
+	.global _start
+_start:
+	.type __start,"function"
+	.global __start
+__start:
+	.long 0


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