[GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects
Viktor Kutuzov
vkutuzov@accesssoftek.com
Thu Feb 25 00:02:00 GMT 2010
Ian,
please find attached updated patch, which fix the local symbol
discarding behavior for the relocatable output objects (when used the -r
and -X/-x linker options together). I've updated this patch and the unit
tests accordingly.
2010-02-24 Viktor Kutuzov (vkutuzov@accesssoftek.com)
* target-reloc.h (scan_relocatable_relocs): Marking needed local
symbols for the relocatable objects.
* object.h (Symbol_value<int>::set_output_symtab_index): Updated
assert to support a special index value (-2) for the needed local
symbols.
(Symbol_value<size>::set_no_output_symtab_entry): Likewise.
(Symbol_value<size>::set_needs_in_output_symtab): New method.
(Symbol_value<size>::needs_in_output_symtab): New method.
(Sized_relobj<size, big_endianl>::set_needs_in_output_symtab): New
method.
* object.cc (Sized_relobj<size,
big_endian>::do_count_local_symbols): prevent discarding needed local
symbols for the relocatable output objects.
(Sized_relobj<size, big_endian>::write_local_symbols): Likewise.
* testsuite/discard_locals_relocatable_test.c: New file.
* testsuite/discard_locals_test.sh: Updated with new test cases.
* testsuite/Makefile.am: Likewise.
* testsuite/Makefile.in: Likewise.
-Viktor.
On Wed, 2010-02-10 at 18:14 -0800, Ian Lance Taylor wrote:
> Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:
>
> > I'm trying to cross build llvm and llvm-gcc on Linux for ARM by using
> > GOLD as the linker. This has exposed some problems we have in GOLD.
> >
> > One of them related to the assert in the relocate_for_relocatable()
> > method (target-reloc.h, line 557):
> >
> > new_symndx = object->symtab_index(r_sym);
> > gold_assert(new_symndx != -1U);
> >
> > This assert gets triggered when the build links glibc with the -r -X
> > flags (remove local symbols).
> >
> > This happens because with the given -X option GOLD removes all local
> > symbols, including those which still needed to resolve static relocs
> > later.
> >
> > LD keeps that kind of local symbols in the symbol table even if -X
> > requested. I guess GOLD should do the same.
> >
> > Please find attached the patch that fixes this issue.
>
> Thanks, but this patch doesn't work. It fails the testsuite. The
> problem is that at the time your patch checks
> needs_output_symtab_entry, it will always return true.
> needs_output_symtab_entry will only return false if
> set_no_output_symtab_entry has been called, and that only happens at
> the end of the loop you patched.
>
> I think what we need to do here is mark the local symbol as
> appropriate in scan_relocatable_relocs. The use of the
> output_symtab_index_ field right now is a bit complicated. It is
> initialized to 0. In Sized_relobj::do_count_local_symbols we set the
> field to -1 if the symbol is not needed. In
> Sized_relobj::do_finalize_local_symbols, if the field is still 0, we
> set it to the index in the output file. Perhaps we should change that
> 0 == uninitialized, -1 == no index, -2 == needs index. Then
> do_finalize_local_symbols should never see 0.
>
> Ian
--
-Viktor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-gold-prevent_discard_needed_local_symbols-updated.patch
Type: text/x-patch
Size: 11471 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20100225/0a8e4cf2/attachment.bin>
More information about the Binutils
mailing list