This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: stripping debug info & local symbols
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 4 Jun 2008 23:50:08 +0930
- Subject: Re: stripping debug info & local symbols
- References: <48454535.5050309@codesourcery.com> <48455DCA.4020101@codesourcery.com> <20080603160011.GJ10726@bubble.grove.modra.org> <484644A1.8000905@codesourcery.com>
On Wed, Jun 04, 2008 at 08:30:41AM +0100, Nathan Sidwell wrote:
> Alan Modra wrote:
> >On Tue, Jun 03, 2008 at 04:05:46PM +0100, Nathan Sidwell wrote:
> >>Nathan Sidwell wrote:
> >>>I'm trying to fix a bug where objcopy -g is breaking relocations in a
> >>>relocatable vxworks executable. The executable is generated by a
> >>>non-gnu linker. It contains the following reloc and symbol table entry:
> >>A little detective work fingers
> >>http://sourceware.org/ml/binutils/2006-05/msg00458.html
> >
> >It's late here and my brain is about to shut down, but this patch of
> >mine does look suspicious. I can't think why I decided that
> >ignore_section_sym should test symbol value, except that was what
> >elf_map_symbols was doing before in the first loop I touched. (There
> >is nothing in the ELF spec that says a section symbol should have zero
> >value.)
>
> Thanks for the speedy response. I remove the sym->value != 0 test from
> ignore_section_sym, and it did fix my problem. It didn't appear to break
> any i86-linux testcase either.
I think this is what we want. elf_map_symbols is supposed to create
an array of sections symbols suitable for use in gas relocs, so we
need to keep the sym->value == 0 test in the loop that tries to use
existing symbols.
* elf.c (ignore_section_sym): Don't test section sym value here.
(elf_map_symbols): Instead check zero value here as was done prior
to 2006-05-26 change.
> I'm not sure how to create a testcase for this though, any suggestions?
Nope..
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.447
diff -u -p -r1.447 elf.c
--- bfd/elf.c 29 May 2008 07:07:20 -0000 1.447
+++ bfd/elf.c 4 Jun 2008 13:14:22 -0000
@@ -3078,17 +3078,15 @@ sym_is_global (bfd *abfd, asymbol *sym)
}
/* Don't output section symbols for sections that are not going to be
- output. Also, don't output section symbols for reloc and other
- special sections. */
+ output. */
static bfd_boolean
ignore_section_sym (bfd *abfd, asymbol *sym)
{
return ((sym->flags & BSF_SECTION_SYM) != 0
- && (sym->value != 0
- || (sym->section->owner != abfd
- && (sym->section->output_section->owner != abfd
- || sym->section->output_offset != 0))));
+ && !(sym->section->owner == abfd
+ || (sym->section->output_section->owner == abfd
+ && sym->section->output_offset == 0)));
}
static bfd_boolean
@@ -3131,6 +3129,7 @@ elf_map_symbols (bfd *abfd)
asymbol *sym = syms[idx];
if ((sym->flags & BSF_SECTION_SYM) != 0
+ && sym->value == 0
&& !ignore_section_sym (abfd, sym))
{
asection *sec = sym->section;
--
Alan Modra
Australia Development Lab, IBM