This is the mail archive of the binutils@sourceware.org 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: PATCH: ld/2411: ELF linker fails to create executable with more than 64k sections


On Fri, Mar 03, 2006 at 02:43:51PM +1030, Alan Modra wrote:
> On Thu, Mar 02, 2006 at 03:21:25PM -0800, H. J. Lu wrote:
> > The ELF gABI doesn't support more than 64k sections in DSO and
> > executable when there are dynamic symbols. This patch checks that.
> 
> I think you should put this check in bfd_elf_final_link rather than in
> map_sections_to_segments, before the first call to
> elf_link_output_extsym.  That puts it close to the code that outputs
> dynamic section syms.
> 
> > +	(_("%B: Too many sections: %d (< %d)"),
> > +	 abfd, bfd_count_sections (abfd), SHN_LORESERVE);
> 
> Typo.
> 

Here is the updated patch.


H.J.
---
2006-03-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/2411
	* elflink.c (bfd_elf_final_link): Check if the number of output
	sections is allowed.

--- bfd/elflink.c.64k	2006-03-02 14:16:50.000000000 -0800
+++ bfd/elflink.c	2006-03-03 09:03:46.000000000 -0800
@@ -8263,6 +8263,18 @@ bfd_elf_final_link (bfd *abfd, struct bf
 	}
     }
 
+  if (elf_hash_table (info)->dynsymcount != 0
+      && bfd_count_sections (abfd) >= SHN_LORESERVE)
+    {
+      /* The gABI doesn't support dynamic symbols and more than 64K
+	output sections at the same time.  */
+      (*_bfd_error_handler)
+	(_("%B: Too many sections: %d (>= %d)"),
+	 abfd, bfd_count_sections (abfd), SHN_LORESERVE);
+      bfd_set_error (bfd_error_nonrepresentable_section);
+      goto error_return;
+    }
+
   /* Output any global symbols that got converted to local in a
      version script or due to symbol visibility.  We do this in a
      separate step since ELF requires all local symbols to appear


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