summaryrefslogtreecommitdiff
path: root/gold/object.h
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.h
parente8f781e22753a21b7d4d5afd6c4217e711b8da80 (diff)
* 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.h')
-rw-r--r--gold/object.h69
1 files changed, 61 insertions, 8 deletions
diff --git a/gold/object.h b/gold/object.h
index 1be5471b4b..59da7c1c5f 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -1087,17 +1087,39 @@ class Symbol_value
input_value() const
{ return this->u_.value; }
- // Return whether this symbol should go into the output symbol
+ // Return whether we have set the index in the output symbol table
+ // yet.
+ bool
+ is_output_symtab_index_set() const
+ {
+ return (this->output_symtab_index_ != 0
+ && this->output_symtab_index_ != -2U);
+ }
+
+ // Return whether this symbol may be discarded from the normal
+ // symbol table.
+ bool
+ may_be_discarded_from_output_symtab() const
+ {
+ gold_assert(!this->is_output_symtab_index_set());
+ return this->output_symtab_index_ != -2U;
+ }
+
+ // Return whether this symbol has an entry in the output symbol
// table.
bool
- needs_output_symtab_entry() const
- { return this->output_symtab_index_ != -1U; }
+ has_output_symtab_entry() const
+ {
+ gold_assert(this->is_output_symtab_index_set());
+ return this->output_symtab_index_ != -1U;
+ }
// Return the index in the output symbol table.
unsigned int
output_symtab_index() const
{
- gold_assert(this->output_symtab_index_ != 0);
+ gold_assert(this->is_output_symtab_index_set()
+ && this->output_symtab_index_ != -1U);
return this->output_symtab_index_;
}
@@ -1105,7 +1127,8 @@ class Symbol_value
void
set_output_symtab_index(unsigned int i)
{
- gold_assert(this->output_symtab_index_ == 0);
+ gold_assert(!this->is_output_symtab_index_set());
+ gold_assert(i != 0 && i != -1U && i != -2U);
this->output_symtab_index_ = i;
}
@@ -1118,6 +1141,15 @@ class Symbol_value
this->output_symtab_index_ = -1U;
}
+ // Record that this symbol must go into the output symbol table,
+ // because it there is a relocation that uses it.
+ void
+ set_must_have_output_symtab_entry()
+ {
+ gold_assert(!this->is_output_symtab_index_set());
+ this->output_symtab_index_ = -2U;
+ }
+
// Set the index in the output dynamic symbol table.
void
set_needs_output_dynsym_entry()
@@ -1126,7 +1158,7 @@ class Symbol_value
this->output_dynsym_index_ = 0;
}
- // Return whether this symbol should go into the output symbol
+ // Return whether this symbol should go into the dynamic symbol
// table.
bool
needs_output_dynsym_entry() const
@@ -1134,11 +1166,21 @@ class Symbol_value
return this->output_dynsym_index_ != -1U;
}
+ // Return whether this symbol has an entry in the dynamic symbol
+ // table.
+ bool
+ has_output_dynsym_entry() const
+ {
+ gold_assert(this->output_dynsym_index_ != 0);
+ return this->output_dynsym_index_ != -1U;
+ }
+
// Record that this symbol should go into the dynamic symbol table.
void
set_output_dynsym_index(unsigned int i)
{
gold_assert(this->output_dynsym_index_ == 0);
+ gold_assert(i != 0 && i != -1U);
this->output_dynsym_index_ = i;
}
@@ -1195,10 +1237,13 @@ class Symbol_value
private:
// The index of this local symbol in the output symbol table. This
- // will be -1 if the symbol should not go into the symbol table.
+ // will be 0 if no value has been assigned yet, and the symbol may
+ // be omitted. This will be -1U if the symbol should not go into
+ // the symbol table. This will be -2U if the symbol must go into
+ // the symbol table, but no index has been assigned yet.
unsigned int output_symtab_index_;
// The index of this local symbol in the dynamic symbol table. This
- // will be -1 if the symbol should not go into the symbol table.
+ // will be -1U if the symbol should not go into the symbol table.
unsigned int output_dynsym_index_;
// The section index in the input file in which this symbol is
// defined.
@@ -1421,6 +1466,14 @@ class Sized_relobj : public Relobj
return this->local_values_[sym].input_shndx(is_ordinary);
}
+ // Record that local symbol SYM must be in the output symbol table.
+ void
+ set_must_have_output_symtab_entry(unsigned int sym)
+ {
+ gold_assert(sym < this->local_values_.size());
+ this->local_values_[sym].set_must_have_output_symtab_entry();
+ }
+
// Record that local symbol SYM needs a dynamic symbol entry.
void
set_needs_output_dynsym_entry(unsigned int sym)