aboutsummaryrefslogtreecommitdiff
path: root/gold/object.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-03-03 19:31:54 +0000
committerIan Lance Taylor <ian@airs.com>2010-03-03 19:31:54 +0000
commitd3bbad62650d8da0396b2df5308271efc7fdb317 (patch)
treef92ee0062cef565cb8575aff98486d7cd09b5a66 /gold/object.cc
parente8f781e22753a21b7d4d5afd6c4217e711b8da80 (diff)
downloadgdb-d3bbad62650d8da0396b2df5308271efc7fdb317.zip
gdb-d3bbad62650d8da0396b2df5308271efc7fdb317.tar.gz
gdb-d3bbad62650d8da0396b2df5308271efc7fdb317.tar.bz2
* 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.
Diffstat (limited to 'gold/object.cc')
-rw-r--r--gold/object.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/gold/object.cc b/gold/object.cc
index 85353cf..73bf370 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -1591,7 +1591,7 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
++dyncount;
}
- if (discard_all)
+ if (discard_all && lv.may_be_discarded_from_output_symtab())
{
lv.set_no_output_symtab_entry();
continue;
@@ -1612,6 +1612,7 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
if (discard_locals
&& sym.get_st_type() != elfcpp::STT_FILE
&& !lv.needs_output_dynsym_entry()
+ && lv.may_be_discarded_from_output_symtab()
&& parameters->target().is_local_label_name(name))
{
lv.set_no_output_symtab_entry();
@@ -1774,7 +1775,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index,
+ lv.input_value());
}
- if (lv.needs_output_symtab_entry())
+ if (!lv.is_output_symtab_index_set())
{
lv.set_output_symtab_index(index);
++index;
@@ -1937,16 +1938,16 @@ Sized_relobj<size, big_endian>::write_local_symbols(
st_shndx = out_sections[st_shndx]->out_shndx();
if (st_shndx >= elfcpp::SHN_LORESERVE)
{
- if (lv.needs_output_symtab_entry() && !strip_all)
+ if (lv.has_output_symtab_entry())
symtab_xindex->add(lv.output_symtab_index(), st_shndx);
- if (lv.needs_output_dynsym_entry())
+ if (lv.has_output_dynsym_entry())
dynsym_xindex->add(lv.output_dynsym_index(), st_shndx);
st_shndx = elfcpp::SHN_XINDEX;
}
}
// Write the symbol to the output symbol table.
- if (!strip_all && lv.needs_output_symtab_entry())
+ if (lv.has_output_symtab_entry())
{
elfcpp::Sym_write<size, big_endian> osym(ov);
@@ -1963,7 +1964,7 @@ Sized_relobj<size, big_endian>::write_local_symbols(
}
// Write the symbol to the output dynamic symbol table.
- if (lv.needs_output_dynsym_entry())
+ if (lv.has_output_dynsym_entry())
{
gold_assert(dyn_ov < dyn_oview + dyn_output_size);
elfcpp::Sym_write<size, big_endian> osym(dyn_ov);