From: Doug Kwan Date: Wed, 13 Jan 2010 02:00:39 +0000 (+0000) Subject: 2010-01-12 Doug Kwan X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=20138696beff2774d82f6fa26ca65a16af3c3e58;p=binutils-gdb.git 2010-01-12 Doug Kwan * arm.cc (Arm_relobj::mapping_symbols_info_): New data member. (Arm_relobj::Mapping_symbol_position, Arm_reloj::Mapping_symbol_position_less, Arm_relobj::Mapping_symbols_info): New types. (Target_arm::is_mapping_symbol_name): New method definition. (Arm_relobj::do_count_local_symbols): Save information about mapping symbols. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 7ef8f504cca..b0b13397d4a 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,13 @@ +2010-01-12 Doug Kwan + + * arm.cc (Arm_relobj::mapping_symbols_info_): New data member. + (Arm_relobj::Mapping_symbol_position, + Arm_reloj::Mapping_symbol_position_less, + Arm_relobj::Mapping_symbols_info): New types. + (Target_arm::is_mapping_symbol_name): New method definition. + (Arm_relobj::do_count_local_symbols): Save information about mapping + symbols. + 2010-01-11 Doug Kwan * arm.cc (Arm_relocate_functions::thumb32_branch_offset, diff --git a/gold/arm.cc b/gold/arm.cc index a91df6c33b6..401f04d5dce 100644 --- a/gold/arm.cc +++ b/gold/arm.cc @@ -1069,7 +1069,8 @@ class Arm_relobj : public Sized_relobj<32, big_endian> const typename elfcpp::Ehdr<32, big_endian>& ehdr) : Sized_relobj<32, big_endian>(name, input_file, offset, ehdr), stub_tables_(), local_symbol_is_thumb_function_(), - attributes_section_data_(NULL), section_has_cortex_a8_workaround_(NULL) + attributes_section_data_(NULL), mapping_symbols_info_(), + section_has_cortex_a8_workaround_(NULL) { } ~Arm_relobj() @@ -1133,6 +1134,26 @@ class Arm_relobj : public Sized_relobj<32, big_endian> attributes_section_data() const { return this->attributes_section_data_; } + // Mapping symbol location. + typedef std::pair Mapping_symbol_position; + + // Functor for STL container. + struct Mapping_symbol_position_less + { + bool + operator()(const Mapping_symbol_position& p1, + const Mapping_symbol_position& p2) const + { + return (p1.first < p2.first + || (p1.first == p2.first && p1.second < p2.second)); + } + }; + + // We only care about the first character of a mapping symbol, so + // we only store that instead of the whole symbol name. + typedef std::map Mapping_symbols_info; + // Whether a section contains any Cortex-A8 workaround. bool section_has_cortex_a8_workaround(unsigned int shndx) const @@ -1193,6 +1214,8 @@ class Arm_relobj : public Sized_relobj<32, big_endian> elfcpp::Elf_Word processor_specific_flags_; // Object attributes if there is an .ARM.attributes section or NULL. Attributes_section_data* attributes_section_data_; + // Mapping symbols information. + Mapping_symbols_info mapping_symbols_info_; // Bitmap to indicate sections with Cortex-A8 workaround or NULL. std::vector* section_has_cortex_a8_workaround_; }; @@ -1579,6 +1602,16 @@ class Target_arm : public Sized_target<32, big_endian> static bool reloc_uses_thumb_bit(unsigned int r_type); + // Whether NAME belongs to a mapping symbol. + static bool + is_mapping_symbol_name(const char* name) + { + return (name + && name[0] == '$' + && (name[1] == 'a' || name[1] == 't' || name[1] == 'd') + && (name[2] == '\0' || name[2] == '.')); + } + protected: // Make an ELF object. Object* @@ -4209,6 +4242,27 @@ Arm_relobj::do_count_local_symbols( const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(), locsize, true, true); + // For mapping symbol processing, we need to read the symbol names. + unsigned int strtab_shndx = this->adjust_shndx(symtabshdr.get_sh_link()); + if (strtab_shndx >= this->shnum()) + { + this->error(_("invalid symbol table name index: %u"), strtab_shndx); + return; + } + + elfcpp::Shdr<32, big_endian> + strtabshdr(this, this->elf_file()->section_header(strtab_shndx)); + if (strtabshdr.get_sh_type() != elfcpp::SHT_STRTAB) + { + this->error(_("symbol table name section has wrong type: %u"), + static_cast(strtabshdr.get_sh_type())); + return; + } + const char* pnames = + reinterpret_cast(this->get_view(strtabshdr.get_sh_offset(), + strtabshdr.get_sh_size(), + false, false)); + // Loop over the local symbols and mark any local symbols pointing // to THUMB functions. @@ -4223,6 +4277,17 @@ Arm_relobj::do_count_local_symbols( Symbol_value<32>& lv((*plocal_values)[i]); Arm_address input_value = lv.input_value(); + // Check to see if this is a mapping symbol. + const char* sym_name = pnames + sym.get_st_name(); + if (Target_arm::is_mapping_symbol_name(sym_name)) + { + unsigned int input_shndx = sym.get_st_shndx(); + + // Strip of LSB in case this is a THUMB symbol. + Mapping_symbol_position msp(input_shndx, input_value & ~1U); + this->mapping_symbols_info_[msp] = sym_name[1]; + } + if (st_type == elfcpp::STT_ARM_TFUNC || (st_type == elfcpp::STT_FUNC && ((input_value & 1) != 0))) {