This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] linker regression fix
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Jan Beulich <JBeulich at novell dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 24 Oct 2005 10:31:32 +0930
- Subject: Re: [PATCH] linker regression fix
- References: <43591527.76F0.0078.0@novell.com>
On Fri, Oct 21, 2005 at 04:19:51PM +0200, Jan Beulich wrote:
> The patch in http://sourceware.org/ml/binutils/2005-04/msg00325.html
> causes local absolute symbols, including .file ones, to be removed
> from the linker output. This patch tries to adjust this.
Hmm, I think HJ's patch ought to be rewritten as follows. I've also
fixed a segfault which will occur on symbols with unknown reserved
section indices, by simply dropping such symbols. Jan, please commit
your new ld test.
* elflink.c (elf_link_input_bfd): Don't use linker_mark and
SEC_EXCLUDE to test for sections dropped from output. Instead,
use bfd_section_removed_from_list on normal sections. Don't
attempt to handle symbols with unknown reserved section indices.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.194
diff -u -p -r1.194 elflink.c
--- bfd/elflink.c 28 Sep 2005 14:52:02 -0000 1.194
+++ bfd/elflink.c 24 Oct 2005 00:48:12 -0000
@@ -6827,8 +6827,10 @@ elf_link_input_bfd (struct elf_final_lin
isec = bfd_com_section_ptr;
else
{
- /* Who knows? */
- isec = NULL;
+ /* Don't attempt to output symbols with st_shnx in the
+ reserved range other than SHN_ABS and SHN_COMMON. */
+ *ppsection = NULL;
+ continue;
}
*ppsection = isec;
@@ -6859,20 +6861,12 @@ elf_link_input_bfd (struct elf_final_lin
continue;
/* If this symbol is defined in a section which we are
- discarding, we don't need to keep it, but note that
- linker_mark is only reliable for sections that have contents.
- For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
- as well as linker_mark. */
- if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
+ discarding, we don't need to keep it. */
+ if (isym->st_shndx != SHN_UNDEF
+ && (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
&& (isec == NULL
- || (! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
- || (! finfo->info->relocatable
- && (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))
+ || bfd_section_removed_from_list (output_bfd,
+ isec->output_section)))
continue;
/* Get the name of the symbol. */
--
Alan Modra
IBM OzLabs - Linux Technology Centre