[GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects

Ian Lance Taylor iant@google.com
Wed Mar 3 19:34:00 GMT 2010


Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> 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.

Thanks.  I decided to do this somewhat differently, to try to make the
use of the output_symtab functions and values slightly more coherent.

Sorry for the delay.

Ian


2010-03-03  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
	    Ian Lance Taylor  <iant@google.com>

	* target-reloc.h (relocate_section): Check the symbol table index
	for -1U before setting the local symbol index.
	(scan_relocatable_relocs): If copying the relocation, record that
	the local symbol is required.
	* object.h (Symbol_value::is_output_symtab_index_set): New
	function.
	(Symbol_value::may_be_discarded_from_output_symtab): New
	function.
	(Symbol_value::has_output_symtab_entry): New function.
	(Symbol_value::needs_output_symtab_entry): Remove.
	(Symbol_value::output_symtab_index): Make sure the symbol index is
	set.
	(Symbol_value::set_output_symtab_index): Make sure the symbol
	index is not set.  Make sure the new index is valid.
	(Symbol_value::set_must_have_output_symtab_entry): New function.
	(Symbol_value::has_output_dynsym_entry): New function.
	(Symbol_value::set_output_dynsym_index): Make sure the new index
	is valid.
	(Sized_relobj::set_must_have_output_symtab_entry): New function.
	* object.cc (Sized_relobj::do_count_local_symbols): Only discard a
	local symbol if permitted.
	(Sized_relobj::do_finalize_local_symbols): Call
	is_output_symtab_index_set rather than needs_output_symtab_entry.
	(Sized_relobj::write_local_symbols): Call has_output_symtab_entry
	rather than needs_output_symtab_entry.  Call
	has_output_dynsym_entry rather than needs_output_dynsym_entry.
	* arm.cc (Arm_relobj::update_output_local_symbol_count): Call
	is_output_symtab_index_set rather than needs_output_symtab_entry.
	* testsuite/discard_locals_relocatable_test.c: New file.
	* testsuite/discard_locals_test.sh: Test -r.
	* testsuite/Makefile.am (check_DATA): Add
	discard_locals_relocatable_test1.syms,
	discard_local_relocatable_test2.syms.
	(MOSTLYCLEANFILES): Likewise.  Also add
	discard_locals_relocatable_test1.lout and
	discard_locals_relocatable_test2.out.
	(discard_locals_relocatable_test1.syms): New target.
	(discard_locals_relocatable_test.o): New target.
	(discard_locals_relocatable_test1.out): New target.
	(discard_locals_relocatable_test2.syms): New target.
	(discard_locals_relocatable_test2.out): New target.
	(various): Add missing ../ld-new dependencies.
	* testsuite/Makefile.in: Rebuild.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 16897 bytes
Desc: discard
URL: <https://sourceware.org/pipermail/binutils/attachments/20100303/faf3d1fb/attachment.bin>


More information about the Binutils mailing list