aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog35
-rw-r--r--gold/gc.h25
-rw-r--r--gold/icf.cc8
-rw-r--r--gold/icf.h10
-rw-r--r--gold/object.h4
-rw-r--r--gold/output.cc2
-rw-r--r--gold/output.h2
-rw-r--r--gold/plugin.cc8
-rw-r--r--gold/powerpc.cc12
-rw-r--r--gold/symtab.cc7
-rw-r--r--gold/symtab.h2
-rw-r--r--gold/target.h8
12 files changed, 80 insertions, 43 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index c32afc6..758e8aa 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,38 @@
+2015-04-29 Cary Coutant <cary@google.com>
+ Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
+
+ * gc.h (Garbage_collection::is_section_garbage): Change Object*
+ to Relobj*.
+ (Garbage_collection::add_reference): Likewise.
+ (Garbage_collection::gc_process_relocs): Likewise. Don't push
+ object/shndx pair onto *secvec for dynamic objects. Don't follow
+ relocations pointing to dynamic objects for GC.
+ * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*.
+ (Icf::unfold_section): Likewise.
+ (Icf::is_section_folded): Likewise.
+ (Icf::get_folded_section): Likewise.
+ * icf.h: (Icf::get_folded_section): Likewise.
+ (Icf::unfold_section): Likewise.
+ (Icf::is_section_folded): Likewise.
+ (Icf::section_has_function_pointers): Likewise.
+ (Icf::set_section_has_function_pointers): Likewise.
+ * object.h (Section_id): Likewise.
+ (Const_section_id): Likewise.
+ * output.cc (Output_section::update_section_layout): Likewise.
+ * output.h: (Output_section_lookup_maps::find_relaxed_input_section):
+ Likewise.
+ * plugin.cc (update_section_order): Likewise.
+ (unique_segment_for_sections): Likewise.
+ * powerpc.cc (Powerpc_relobj::add_reference): Likewise.
+ (Target_powerpc::do_gc_add_reference): Likewise.
+ (Target_powerpc::gc_process_relocs): Likewise.
+ (Target_powerpc::do_gc_add_reference): Likewise.
+ * symtab.cc (Symbol_table::is_section_folded): Likewise.
+ (Symbol_table::gc_mark_symbol): Likewise.
+ * symtab.h: (Symbol_table::is_section_folded): Likewise.
+ * target.h: (Sized_target::gc_add_reference): Likewise.
+ (Sized_target::do_gc_add_reference): Likewise.
+
2015-04-29 Nick Clifton <nickc@redhat.com>
* po/fi.po: Updated Finnish translation.
diff --git a/gold/gc.h b/gold/gc.h
index bf4023d..c43fcbe 100644
--- a/gold/gc.h
+++ b/gold/gc.h
@@ -87,7 +87,7 @@ class Garbage_collection
do_transitive_closure();
bool
- is_section_garbage(Object* obj, unsigned int shndx)
+ is_section_garbage(Relobj* obj, unsigned int shndx)
{ return (this->referenced_list().find(Section_id(obj, shndx))
== this->referenced_list().end()); }
@@ -103,8 +103,8 @@ class Garbage_collection
// Add a reference from the SRC_SHNDX-th section of SRC_OBJECT to
// DST_SHNDX-th section of DST_OBJECT.
void
- add_reference(Object* src_object, unsigned int src_shndx,
- Object* dst_object, unsigned int dst_shndx)
+ add_reference(Relobj* src_object, unsigned int src_shndx,
+ Relobj* dst_object, unsigned int dst_shndx)
{
Section_id src_id(src_object, src_shndx);
Section_id dst_id(dst_object, dst_shndx);
@@ -229,7 +229,7 @@ gc_process_relocs(
unsigned int r_type = elfcpp::elf_r_type<size>(r_info);
typename elfcpp::Elf_types<size>::Elf_Swxword addend =
Reloc_types<sh_type, size, big_endian>::get_reloc_addend_noerror(&reloc);
- Object* dst_obj;
+ Relobj* dst_obj;
unsigned int dst_indx;
typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
Address dst_off;
@@ -249,7 +249,7 @@ gc_process_relocs(
{
Address symvalue = dst_off - addend;
if (is_ordinary)
- (*secvec).push_back(Section_id(dst_obj, dst_indx));
+ (*secvec).push_back(Section_id(src_obj, dst_indx));
else
(*secvec).push_back(Section_id(NULL, 0));
(*symvec).push_back(NULL);
@@ -289,9 +289,10 @@ gc_process_relocs(
dst_obj = NULL;
dst_indx = 0;
bool is_ordinary = false;
- if (gsym->source() == Symbol::FROM_OBJECT)
+ if (gsym->source() == Symbol::FROM_OBJECT
+ && !gsym->object()->is_dynamic())
{
- dst_obj = gsym->object();
+ dst_obj = static_cast<Relobj*>(gsym->object());
dst_indx = gsym->shndx(&is_ordinary);
}
dst_off = static_cast<const Sized_symbol<size>*>(gsym)->value();
@@ -301,7 +302,7 @@ gc_process_relocs(
// of a function pointer being taken.
if (gsym->source() == Symbol::FROM_OBJECT
&& check_section_for_function_pointers
- && gsym->type() != elfcpp::STT_OBJECT
+ && dst_obj != NULL
&& (!is_ordinary
|| scan.global_reloc_may_be_function_pointer(
symtab, NULL, NULL, src_obj, src_indx, NULL, reloc,
@@ -324,7 +325,7 @@ gc_process_relocs(
if (is_icf_tracked)
{
Address symvalue = dst_off - addend;
- if (is_ordinary && gsym->source() == Symbol::FROM_OBJECT)
+ if (is_ordinary && dst_obj != NULL)
(*secvec).push_back(Section_id(dst_obj, dst_indx));
else
(*secvec).push_back(Section_id(NULL, 0));
@@ -340,7 +341,7 @@ gc_process_relocs(
src_obj));
}
- if (gsym->source() != Symbol::FROM_OBJECT)
+ if (dst_obj == NULL)
continue;
if (!is_ordinary)
continue;
@@ -349,8 +350,8 @@ gc_process_relocs(
{
symtab->gc()->add_reference(src_obj, src_indx, dst_obj, dst_indx);
parameters->sized_target<size, big_endian>()
- ->gc_add_reference(symtab, src_obj, src_indx,
- dst_obj, dst_indx, dst_off);
+ ->gc_add_reference(symtab, src_obj, src_indx, dst_obj, dst_indx,
+ dst_off);
if (cident_section_name != NULL)
{
Garbage_collection::Cident_section_map::iterator ele =
diff --git a/gold/icf.cc b/gold/icf.cc
index 8de6386..96b7f2d 100644
--- a/gold/icf.cc
+++ b/gold/icf.cc
@@ -787,7 +787,7 @@ Icf::find_identical_sections(const Input_objects* input_objects,
else if (sym->source() == Symbol::FROM_OBJECT
&& !sym->object()->is_dynamic())
{
- Object* obj = sym->object();
+ Relobj* obj = static_cast<Relobj*>(sym->object());
bool is_ordinary;
unsigned int shndx = sym->shndx(&is_ordinary);
if (is_ordinary)
@@ -804,7 +804,7 @@ Icf::find_identical_sections(const Input_objects* input_objects,
// Unfolds the section denoted by OBJ and SHNDX if folded.
void
-Icf::unfold_section(Object* obj, unsigned int shndx)
+Icf::unfold_section(Relobj* obj, unsigned int shndx)
{
Section_id secn(obj, shndx);
Uniq_secn_id_map::iterator it = this->section_id_.find(secn);
@@ -821,7 +821,7 @@ Icf::unfold_section(Object* obj, unsigned int shndx)
// is different from this section.
bool
-Icf::is_section_folded(Object* obj, unsigned int shndx)
+Icf::is_section_folded(Relobj* obj, unsigned int shndx)
{
Section_id secn(obj, shndx);
Uniq_secn_id_map::iterator it = this->section_id_.find(secn);
@@ -835,7 +835,7 @@ Icf::is_section_folded(Object* obj, unsigned int shndx)
// This function returns the folded section for the given section.
Section_id
-Icf::get_folded_section(Object* dup_obj, unsigned int dup_shndx)
+Icf::get_folded_section(Relobj* dup_obj, unsigned int dup_shndx)
{
Section_id dup_secn(dup_obj, dup_shndx);
Uniq_secn_id_map::iterator it = this->section_id_.find(dup_secn);
diff --git a/gold/icf.h b/gold/icf.h
index d343fa5..7faf816 100644
--- a/gold/icf.h
+++ b/gold/icf.h
@@ -74,7 +74,7 @@ class Icf
// Returns the kept folded identical section corresponding to
// dup_obj and dup_shndx.
Section_id
- get_folded_section(Object* dup_obj, unsigned int dup_shndx);
+ get_folded_section(Relobj* dup_obj, unsigned int dup_shndx);
// Forms groups of identical sections where the first member
// of each group is the kept section during folding.
@@ -95,17 +95,17 @@ class Icf
// Unfolds the section denoted by OBJ and SHNDX if folded.
void
- unfold_section(Object* obj, unsigned int shndx);
+ unfold_section(Relobj* obj, unsigned int shndx);
// Returns the kept section corresponding to the
// given section.
bool
- is_section_folded(Object* obj, unsigned int shndx);
+ is_section_folded(Relobj* obj, unsigned int shndx);
// Given an object and a section index, this returns true if the
// pointer of the function defined in this section is taken.
bool
- section_has_function_pointers(Object* obj, unsigned int shndx)
+ section_has_function_pointers(Relobj* obj, unsigned int shndx)
{
return (this->fptr_section_id_.find(Section_id(obj, shndx))
!= this->fptr_section_id_.end());
@@ -114,7 +114,7 @@ class Icf
// Records that a pointer of the function defined in this section
// is taken.
void
- set_section_has_function_pointers(Object* obj, unsigned int shndx)
+ set_section_has_function_pointers(Relobj* obj, unsigned int shndx)
{
this->fptr_section_id_.insert(Section_id(obj, shndx));
}
diff --git a/gold/object.h b/gold/object.h
index fc93abd..a3d5d0e 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -2863,11 +2863,11 @@ struct Relocate_info
// This is used to represent a section in an object and is used as the
// key type for various section maps.
-typedef std::pair<Object*, unsigned int> Section_id;
+typedef std::pair<Relobj*, unsigned int> Section_id;
// This is similar to Section_id but is used when the section
// pointers are const.
-typedef std::pair<const Object*, unsigned int> Const_section_id;
+typedef std::pair<const Relobj*, unsigned int> Const_section_id;
// The hash value is based on the address of an object in memory during
// linking. It is okay to use this for looking up sections but never use
diff --git a/gold/output.cc b/gold/output.cc
index f34a7d8..5cc3629 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -3503,7 +3503,7 @@ Output_section::update_section_layout(
if (p->is_input_section()
|| p->is_relaxed_input_section())
{
- Object* obj = (p->is_input_section()
+ Relobj* obj = (p->is_input_section()
? p->relobj()
: p->relaxed_input_section()->relobj());
unsigned int shndx = p->shndx();
diff --git a/gold/output.h b/gold/output.h
index 318af36..be72965 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -2904,7 +2904,7 @@ class Output_section_lookup_maps
// Find a relaxed input section of OBJECT with index SHNDX.
Output_relaxed_input_section*
- find_relaxed_input_section(const Object* object, unsigned int shndx) const
+ find_relaxed_input_section(const Relobj* object, unsigned int shndx) const
{
gold_assert(this->is_valid_);
Relaxed_input_sections_by_id::const_iterator p =
diff --git a/gold/plugin.cc b/gold/plugin.cc
index 68da8e3..1588f34 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -1731,10 +1731,10 @@ update_section_order(const struct ld_plugin_section* section_list,
{
Object* obj = parameters->options().plugins()->get_elf_object(
section_list[i].handle);
- if (obj == NULL)
+ if (obj == NULL || obj->is_dynamic())
return LDPS_BAD_HANDLE;
unsigned int shndx = section_list[i].shndx;
- Section_id secn_id(obj, shndx);
+ Section_id secn_id(static_cast<Relobj*>(obj), shndx);
(*order_map)[secn_id] = i + 1;
}
@@ -1800,10 +1800,10 @@ unique_segment_for_sections(const char* segment_name,
{
Object* obj = parameters->options().plugins()->get_elf_object(
section_list[i].handle);
- if (obj == NULL)
+ if (obj == NULL || obj->is_dynamic())
return LDPS_BAD_HANDLE;
unsigned int shndx = section_list[i].shndx;
- Const_section_id secn_id(obj, shndx);
+ Const_section_id secn_id(static_cast<Relobj*>(obj), shndx);
layout->insert_section_segment_map(secn_id, s);
}
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 9a0bd9d..3e9fe81 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -212,7 +212,7 @@ public:
// Add a reference from SRC_OBJ, SRC_INDX to this object's .opd
// section at DST_OFF.
void
- add_reference(Object* src_obj,
+ add_reference(Relobj* src_obj,
unsigned int src_indx,
typename elfcpp::Elf_types<size>::Elf_Addr dst_off)
{
@@ -780,9 +780,9 @@ class Target_powerpc : public Sized_target<size, big_endian>
// section of a function descriptor.
void
do_gc_add_reference(Symbol_table* symtab,
- Object* src_obj,
+ Relobj* src_obj,
unsigned int src_shndx,
- Object* dst_obj,
+ Relobj* dst_obj,
unsigned int dst_shndx,
Address dst_off) const;
@@ -6347,7 +6347,7 @@ Target_powerpc<size, big_endian>::gc_process_relocs(
typename Powerpc_relobj<size, big_endian>::Section_refs::iterator s;
for (s = p->second.begin(); s != p->second.end(); ++s)
{
- Object* src_obj = s->first;
+ Relobj* src_obj = s->first;
unsigned int src_indx = s->second;
symtab->gc()->add_reference(src_obj, src_indx,
ppc_object, dst_indx);
@@ -6384,9 +6384,9 @@ template<int size, bool big_endian>
void
Target_powerpc<size, big_endian>::do_gc_add_reference(
Symbol_table* symtab,
- Object* src_obj,
+ Relobj* src_obj,
unsigned int src_shndx,
- Object* dst_obj,
+ Relobj* dst_obj,
unsigned int dst_shndx,
Address dst_off) const
{
diff --git a/gold/symtab.cc b/gold/symtab.cc
index d2ed352..925296a 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -585,7 +585,7 @@ Symbol_table::Symbol_table_eq::operator()(const Symbol_table_key& k1,
}
bool
-Symbol_table::is_section_folded(Object* obj, unsigned int shndx) const
+Symbol_table::is_section_folded(Relobj* obj, unsigned int shndx) const
{
return (parameters->options().icf_enabled()
&& this->icf_->is_section_folded(obj, shndx));
@@ -650,10 +650,11 @@ Symbol_table::gc_mark_symbol(Symbol* sym)
// Add the object and section to the work list.
bool is_ordinary;
unsigned int shndx = sym->shndx(&is_ordinary);
- if (is_ordinary && shndx != elfcpp::SHN_UNDEF)
+ if (is_ordinary && shndx != elfcpp::SHN_UNDEF && !sym->object()->is_dynamic())
{
gold_assert(this->gc_!= NULL);
- this->gc_->worklist().push_back(Section_id(sym->object(), shndx));
+ Relobj* relobj = static_cast<Relobj*>(sym->object());
+ this->gc_->worklist().push_back(Section_id(relobj, shndx));
}
parameters->target().gc_mark_symbol(this, sym);
}
diff --git a/gold/symtab.h b/gold/symtab.h
index 6f47c5e..f6c0ac6 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -1372,7 +1372,7 @@ class Symbol_table
// Returns true if ICF determined that this is a duplicate section.
bool
- is_section_folded(Object* obj, unsigned int shndx) const;
+ is_section_folded(Relobj* obj, unsigned int shndx) const;
void
set_gc(Garbage_collection* gc)
diff --git a/gold/target.h b/gold/target.h
index 95bc57e..dfbc5ee 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -1056,9 +1056,9 @@ class Sized_target : public Target
// and DST_OFF.
void
gc_add_reference(Symbol_table* symtab,
- Object* src_obj,
+ Relobj* src_obj,
unsigned int src_shndx,
- Object* dst_obj,
+ Relobj* dst_obj,
unsigned int dst_shndx,
typename elfcpp::Elf_types<size>::Elf_Addr dst_off) const
{
@@ -1080,8 +1080,8 @@ class Sized_target : public Target
// Handle target specific gc actions when adding a gc reference.
virtual void
- do_gc_add_reference(Symbol_table*, Object*, unsigned int,
- Object*, unsigned int,
+ do_gc_add_reference(Symbol_table*, Relobj*, unsigned int,
+ Relobj*, unsigned int,
typename elfcpp::Elf_types<size>::Elf_Addr) const
{ }