2010-02-20 Sriraman Tallam <tmsriram@google.com>
* gc.h (gc_process_relocs): Change vectors to point to the new list. Add reloc offset information. * icf.cc (get_section_contents): Change iterators to point to the new vectors. Add reloc offset information to the contents. * icf.h (Icf::Sections_reachable_info): New typedef. (Icf::Sections_reachable_list): New typedef. (Icf::Offset_info): New typedef. (Icf::Reloc_info): New struct typedef. (Icf::Reloc_info_list): New typedef. (Icf::symbol_reloc_list): Delete method. (Icf::addend_reloc_list): Delete method. (Icf::section_reloc_list): Delete method. (Icf::reloc_info_list): New method. (Icf::reloc_info_list_): New member.
This commit is contained in:
parent
307d2493b8
commit
b487ad64e5
@ -1,3 +1,20 @@
|
||||
2010-02-20 Sriraman Tallam <tmsriram@google.com>
|
||||
|
||||
* gc.h (gc_process_relocs): Change vectors to point to the new list.
|
||||
Add reloc offset information.
|
||||
* icf.cc (get_section_contents): Change iterators to point to the new
|
||||
vectors. Add reloc offset information to the contents.
|
||||
* icf.h (Icf::Sections_reachable_info): New typedef.
|
||||
(Icf::Sections_reachable_list): New typedef.
|
||||
(Icf::Offset_info): New typedef.
|
||||
(Icf::Reloc_info): New struct typedef.
|
||||
(Icf::Reloc_info_list): New typedef.
|
||||
(Icf::symbol_reloc_list): Delete method.
|
||||
(Icf::addend_reloc_list): Delete method.
|
||||
(Icf::section_reloc_list): Delete method.
|
||||
(Icf::reloc_info_list): New method.
|
||||
(Icf::reloc_info_list_): New member.
|
||||
|
||||
2010-02-19 Doug Kwan <dougkwan@google.com>
|
||||
|
||||
* arm-reloc.def: Mark R_ARM_TLS_GD32, R_ARM_TLS_LDM32,
|
||||
|
22
gold/gc.h
22
gold/gc.h
@ -181,9 +181,10 @@ gc_process_relocs(
|
||||
const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
|
||||
const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
|
||||
|
||||
std::vector<Section_id>* secvec = NULL;
|
||||
std::vector<Symbol*>* symvec = NULL;
|
||||
std::vector<std::pair<long long, long long> >* addendvec = NULL;
|
||||
Icf::Sections_reachable_info* secvec = NULL;
|
||||
Icf::Symbol_info* symvec = NULL;
|
||||
Icf::Addend_info* addendvec = NULL;
|
||||
Icf::Offset_info* offsetvec = NULL;
|
||||
bool is_icf_tracked = false;
|
||||
const char* cident_section_name = NULL;
|
||||
|
||||
@ -198,9 +199,12 @@ gc_process_relocs(
|
||||
{
|
||||
is_icf_tracked = true;
|
||||
Section_id src_id(src_obj, src_indx);
|
||||
secvec = &symtab->icf()->section_reloc_list()[src_id];
|
||||
symvec = &symtab->icf()->symbol_reloc_list()[src_id];
|
||||
addendvec = &symtab->icf()->addend_reloc_list()[src_id];
|
||||
Icf::Reloc_info* reloc_info =
|
||||
&symtab->icf()->reloc_info_list()[src_id];
|
||||
secvec = &reloc_info->section_info;
|
||||
symvec = &reloc_info->symbol_info;
|
||||
addendvec = &reloc_info->addend_info;
|
||||
offsetvec = &reloc_info->offset_info;
|
||||
}
|
||||
|
||||
check_section_for_function_pointers =
|
||||
@ -236,6 +240,9 @@ gc_process_relocs(
|
||||
long long symvalue = static_cast<long long>(lsym.get_st_value());
|
||||
(*addendvec).push_back(std::make_pair(symvalue,
|
||||
static_cast<long long>(addend)));
|
||||
uint64_t reloc_offset =
|
||||
convert_to_section_size_type(reloc.get_r_offset());
|
||||
(*offsetvec).push_back(reloc_offset);
|
||||
}
|
||||
|
||||
// When doing safe folding, check to see if this relocation is that
|
||||
@ -301,6 +308,9 @@ gc_process_relocs(
|
||||
static_cast<long long>(sized_gsym->value());
|
||||
(*addendvec).push_back(std::make_pair(symvalue,
|
||||
static_cast<long long>(addend)));
|
||||
uint64_t reloc_offset =
|
||||
convert_to_section_size_type(reloc.get_r_offset());
|
||||
(*offsetvec).push_back(reloc_offset);
|
||||
}
|
||||
}
|
||||
if (parameters->options().gc_sections())
|
||||
|
37
gold/icf.cc
37
gold/icf.cc
@ -248,39 +248,38 @@ get_section_contents(bool first_iteration,
|
||||
if (num_tracked_relocs)
|
||||
*num_tracked_relocs = 0;
|
||||
|
||||
Icf::Section_list& seclist = symtab->icf()->section_reloc_list();
|
||||
Icf::Symbol_list& symlist = symtab->icf()->symbol_reloc_list();
|
||||
Icf::Addend_list& addendlist = symtab->icf()->addend_reloc_list();
|
||||
Icf::Reloc_info_list& reloc_info_list =
|
||||
symtab->icf()->reloc_info_list();
|
||||
|
||||
Icf::Section_list::iterator it_seclist = seclist.find(secn);
|
||||
Icf::Symbol_list::iterator it_symlist = symlist.find(secn);
|
||||
Icf::Addend_list::iterator it_addendlist = addendlist.find(secn);
|
||||
Icf::Reloc_info_list::iterator it_reloc_info_list =
|
||||
reloc_info_list.find(secn);
|
||||
|
||||
buffer.clear();
|
||||
icf_reloc_buffer.clear();
|
||||
|
||||
// Process relocs and put them into the buffer.
|
||||
|
||||
if (it_seclist != seclist.end())
|
||||
if (it_reloc_info_list != reloc_info_list.end())
|
||||
{
|
||||
gold_assert(it_symlist != symlist.end());
|
||||
gold_assert(it_addendlist != addendlist.end());
|
||||
Icf::Sections_reachable_list v = it_seclist->second;
|
||||
Icf::Symbol_info s = it_symlist->second;
|
||||
Icf::Addend_info a = it_addendlist->second;
|
||||
Icf::Sections_reachable_list::iterator it_v = v.begin();
|
||||
Icf::Sections_reachable_info v =
|
||||
(it_reloc_info_list->second).section_info;
|
||||
Icf::Symbol_info s = (it_reloc_info_list->second).symbol_info;
|
||||
Icf::Addend_info a = (it_reloc_info_list->second).addend_info;
|
||||
Icf::Offset_info o = (it_reloc_info_list->second).offset_info;
|
||||
Icf::Sections_reachable_info::iterator it_v = v.begin();
|
||||
Icf::Symbol_info::iterator it_s = s.begin();
|
||||
Icf::Addend_info::iterator it_a = a.begin();
|
||||
Icf::Offset_info::iterator it_o = o.begin();
|
||||
|
||||
for (; it_v != v.end(); ++it_v, ++it_s, ++it_a)
|
||||
for (; it_v != v.end(); ++it_v, ++it_s, ++it_a, ++it_o)
|
||||
{
|
||||
// ADDEND_STR stores the symbol value and addend, each
|
||||
// atmost 16 hex digits long. it_v points to a pair
|
||||
// ADDEND_STR stores the symbol value and addend and offset,
|
||||
// each atmost 16 hex digits long. it_a points to a pair
|
||||
// where first is the symbol value and second is the
|
||||
// addend.
|
||||
char addend_str[34];
|
||||
snprintf(addend_str, sizeof(addend_str), "%llx %llx",
|
||||
(*it_a).first, (*it_a).second);
|
||||
char addend_str[50];
|
||||
snprintf(addend_str, sizeof(addend_str), "%llx %llx %lux",
|
||||
(*it_a).first, (*it_a).second, (*it_o));
|
||||
Section_id reloc_secn(it_v->first, it_v->second);
|
||||
|
||||
// If this reloc turns back and points to the same section,
|
||||
|
53
gold/icf.h
53
gold/icf.h
@ -39,25 +39,34 @@ class Symbol_table;
|
||||
class Icf
|
||||
{
|
||||
public:
|
||||
typedef std::vector<Section_id> Sections_reachable_list;
|
||||
typedef std::vector<Section_id> Sections_reachable_info;
|
||||
typedef std::vector<Symbol*> Symbol_info;
|
||||
typedef std::vector<std::pair<long long, long long> > Addend_info;
|
||||
typedef Unordered_map<Section_id,
|
||||
Sections_reachable_list,
|
||||
Section_id_hash> Section_list;
|
||||
typedef Unordered_map<Section_id, Symbol_info, Section_id_hash> Symbol_list;
|
||||
typedef Unordered_map<Section_id, Addend_info, Section_id_hash> Addend_list;
|
||||
typedef std::vector<uint64_t> Offset_info;
|
||||
typedef Unordered_map<Section_id,
|
||||
unsigned int,
|
||||
Section_id_hash> Uniq_secn_id_map;
|
||||
typedef Unordered_set<Section_id, Section_id_hash> Secn_fptr_taken_set;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// This stores the section corresponding to the reloc.
|
||||
Sections_reachable_info section_info;
|
||||
// This stores the symbol corresponding to the reloc.
|
||||
Symbol_info symbol_info;
|
||||
// This stores the symbol value and the addend for a reloc.
|
||||
Addend_info addend_info;
|
||||
Offset_info offset_info;
|
||||
} Reloc_info;
|
||||
|
||||
typedef Unordered_map<Section_id, Reloc_info,
|
||||
Section_id_hash> Reloc_info_list;
|
||||
|
||||
Icf()
|
||||
: id_section_(), section_id_(), kept_section_id_(),
|
||||
fptr_section_id_(),
|
||||
num_tracked_relocs(NULL), icf_ready_(false),
|
||||
section_reloc_list_(), symbol_reloc_list_(),
|
||||
addend_reloc_list_()
|
||||
reloc_info_list_()
|
||||
{ }
|
||||
|
||||
// Returns the kept folded identical section corresponding to
|
||||
@ -121,23 +130,10 @@ class Icf
|
||||
&& !is_prefix_of(".eh_frame", section_name.c_str()));
|
||||
}
|
||||
|
||||
// Returns a map of a section to a list of all sections referenced
|
||||
// by its relocations.
|
||||
Section_list&
|
||||
section_reloc_list()
|
||||
{ return this->section_reloc_list_; }
|
||||
|
||||
// Returns a map of a section to a list of all symbols referenced
|
||||
// by its relocations.
|
||||
Symbol_list&
|
||||
symbol_reloc_list()
|
||||
{ return this->symbol_reloc_list_; }
|
||||
|
||||
// Returns a maps of a section to a list of symbol values and addends
|
||||
// of its relocations.
|
||||
Addend_list&
|
||||
addend_reloc_list()
|
||||
{ return this->addend_reloc_list_; }
|
||||
// Returns a map of a section to info (Reloc_info) about its relocations.
|
||||
Reloc_info_list&
|
||||
reloc_info_list()
|
||||
{ return this->reloc_info_list_; }
|
||||
|
||||
// Returns a mapping of each section to a unique integer.
|
||||
Uniq_secn_id_map&
|
||||
@ -161,11 +157,8 @@ class Icf
|
||||
unsigned int* num_tracked_relocs;
|
||||
// Flag to indicate if ICF has been run.
|
||||
bool icf_ready_;
|
||||
|
||||
// These lists are populated by gc_process_relocs in gc.h.
|
||||
Section_list section_reloc_list_;
|
||||
Symbol_list symbol_reloc_list_;
|
||||
Addend_list addend_reloc_list_;
|
||||
// This list is populated by gc_process_relocs in gc.h.
|
||||
Reloc_info_list reloc_info_list_;
|
||||
};
|
||||
|
||||
// This function returns true if this section corresponds to a function that
|
||||
|
Loading…
x
Reference in New Issue
Block a user