This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: SEC_NEVER_LOAD cleanup
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Alan Modra <amodra at gmail dot com>
- Date: Fri, 15 Oct 2010 21:54:18 +0100
- Subject: Re: SEC_NEVER_LOAD cleanup
- References: <20100916000335.GS16874@bubble.grove.modra.org>
Hi Alan,
On 16/09/2010 01:03, Alan Modra wrote:
> This gets rid of SEC_NEVER_LOAD in ELF code, curing these failures:
> I spent quite a lot of time going through changes related to
> SEC_NEVER_LOAD. Testcases in various bug reports behave reasonably
> after this patch, and I think the COFF support should work too but I'm
> less sure of this since I don't have any reason to use COFF/ECOFF/PE
> myself.
> bfd/
> * elf.c (bfd_elf_get_default_section_type): Don't test SEC_NEVER_LOAD.
> * elflink.c (elf_link_input_bfd): Likewise.
> ld/
> * ld.texinfo (NOLOAD): Do not erroneously state that contents will
> appear in output file.
> * ldlang.c (lang_add_section): Clear SEC_HAS_CONTENTS on noload
> unless SEC_COFF_SHARED_LIBRARY.
> (map_input_to_output_sections): Don't set SEC_HAS_CONTENTS for noload
> output sections.
> (lang_size_sections_1): Don't test SEC_NEVER_LOAD when deciding
> to update dot in region. Ditto when setting SEC_ALLOC if dot
> advanced due to assignment.
> * ldwrite.c (build_link_order): Don't test SEC_NEVER_LOAD.
This patch causes a failure building the cygwin dll:
> GNU ld (GNU Binutils) 2.20.51.20100916
> Creating library file: cygdll.a
> /gnu/binutils/git.repo/obj/ld/.libs/ld-new: BFD (GNU Binutils) 2.20.51.20100916
> assertion fail /gnu/binutils/git.repo/binutils/bfd/linker.c:2678
> /gnu/binutils/git.repo/obj/ld/.libs/ld-new: final link failed: Section has no contents
Which appears to be from here:
> static bfd_boolean
> default_data_link_order (bfd *abfd,
> struct bfd_link_info *info ATTRIBUTE_UNUSED,
> asection *sec,
> struct bfd_link_order *link_order)
> {
> bfd_size_type size;
> size_t fill_size;
> bfd_byte *fill;
> file_ptr loc;
> bfd_boolean result;
>
> BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
That's triggered by the ".gnu_debuglink_overlay" section. It has flags =
512 - SEC_NEVER_LOAD is set and nothing else. It's getting added to the link
via a bit of custom linker script in the cygwin dll build system that looks
like so:
> .gnu_debuglink_overlay ALIGN(__section_alignment__) (NOLOAD):
> {
> BYTE(0) /* c */
> BYTE(0) /* y */
> BYTE(0) /* g */
> BYTE(0) /* w */
> BYTE(0) /* i */
> BYTE(0) /* n */
> BYTE(0) /* 1 */
> BYTE(0) /* . */
> BYTE(0) /* d */
> BYTE(0) /* b */
> BYTE(0) /* g */
> BYTE(0) /* \0 */
> LONG(0) /* checksum */
> }
I think (haven't checked yet) that this looks like a consequence of the
ldlang.c changes. Any thoughts on how to fix it?
cheers,
DaveK