From 01b84e25533166047340c41a33cc29153e536227 Mon Sep 17 00:00:00 2001 From: Vladimir Radosavljevic Date: Fri, 18 Mar 2016 14:54:35 -0700 Subject: [PATCH] Remove is_n64_ data member from Mips_relobj class. elfcpp/ * mips.h (abi_64): Remove. gold/ * mips.cc (Mips_relobj::is_n64_): Remove. (Target_mips::ei_class_): Likewise. (Mips_relobj::is_newabi): Call methods. (Mips_relobj::is_n64): Change checking for N64 ABI. (Target_mips::is_output_n64): Likewise. (Target_mips::merge_processor_specific_flags): Remove ei_class argument, and remove comparing ei_class. (Target_mips::do_adjust_elf_header): Remove setting EI_CLASS field of the ELF header. (Target_mips::do_finalize_sections): Don't pass ei_class argument to merge_processor_specific_flags. (Target_mips::elf_mips_abi_name): Remove ei_class argument, and change checking for N64 ABI. --- elfcpp/ChangeLog | 4 ++++ elfcpp/mips.h | 5 ----- gold/ChangeLog | 16 ++++++++++++++ gold/mips.cc | 67 +++++++++++++++++++------------------------------------- 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog index caccf3e..a469f86 100644 --- a/elfcpp/ChangeLog +++ b/elfcpp/ChangeLog @@ -1,3 +1,7 @@ +2016-03-18 Vladimir Radosavljevic + + * mips.h (abi_64): Remove. + 2016-01-12 H.J. Lu * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): Remove diff --git a/elfcpp/mips.h b/elfcpp/mips.h index 4172850..10137ec 100644 --- a/elfcpp/mips.h +++ b/elfcpp/mips.h @@ -339,11 +339,6 @@ bool abi_n32(elfcpp::Elf_Word e_flags) { return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; } -// Whether the ABI is N64. -bool -abi_64(unsigned char ei_class) -{ return ei_class == elfcpp::ELFCLASS64; } - // Whether the file has microMIPS code. bool is_micromips(elfcpp::Elf_Word e_flags) diff --git a/gold/ChangeLog b/gold/ChangeLog index e0728c7..c903192 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,19 @@ +2016-03-18 Vladimir Radosavljevic + + * mips.cc (Mips_relobj::is_n64_): Remove. + (Target_mips::ei_class_): Likewise. + (Mips_relobj::is_newabi): Call methods. + (Mips_relobj::is_n64): Change checking for N64 ABI. + (Target_mips::is_output_n64): Likewise. + (Target_mips::merge_processor_specific_flags): Remove ei_class + argument, and remove comparing ei_class. + (Target_mips::do_adjust_elf_header): Remove setting EI_CLASS field + of the ELF header. + (Target_mips::do_finalize_sections): Don't pass ei_class argument + to merge_processor_specific_flags. + (Target_mips::elf_mips_abi_name): Remove ei_class argument, and + change checking for N64 ABI. + 2016-03-17 Vladimir Radosavljevic * mips.cc (enum Special_relocation_symbol): New enum type. diff --git a/gold/mips.cc b/gold/mips.cc index bf80294..ffaad45 100644 --- a/gold/mips.cc +++ b/gold/mips.cc @@ -1537,7 +1537,6 @@ class Mips_relobj : public Sized_relobj_file { this->is_pic_ = (ehdr.get_e_flags() & elfcpp::EF_MIPS_PIC) != 0; this->is_n32_ = elfcpp::abi_n32(ehdr.get_e_flags()); - this->is_n64_ = elfcpp::abi_64(ehdr.get_e_ident()[elfcpp::EI_CLASS]); } ~Mips_relobj() @@ -1694,12 +1693,12 @@ class Mips_relobj : public Sized_relobj_file // Return whether the object uses N64 ABI. bool is_n64() const - { return this->is_n64_; } + { return size == 64; } // Return whether the object uses NewABI conventions. bool is_newabi() const - { return this->is_n32_ || this->is_n64_; } + { return this->is_n32() || this->is_n64(); } // Return Mips_got_info for this object. Mips_got_info* @@ -1848,8 +1847,6 @@ class Mips_relobj : public Sized_relobj_file bool is_pic_ : 1; // Whether the object uses N32 ABI. bool is_n32_ : 1; - // Whether the object uses N64 ABI. - bool is_n64_ : 1; // The Mips_got_info for this object. Mips_got_info* got_info_; @@ -3202,8 +3199,8 @@ class Target_mips : public Sized_target : Sized_target(info), got_(NULL), gp_(NULL), plt_(NULL), got_plt_(NULL), rel_dyn_(NULL), copy_relocs_(), dyn_relocs_(), la25_stub_(NULL), mips_mach_extensions_(), - mips_stubs_(NULL), ei_class_(0), mach_(0), layout_(NULL), - got16_addends_(), entry_symbol_is_compressed_(false), insn32_(false) + mips_stubs_(NULL), mach_(0), layout_(NULL), got16_addends_(), + entry_symbol_is_compressed_(false), insn32_(false) { this->add_machine_extensions(); } @@ -3485,14 +3482,10 @@ class Target_mips : public Sized_target return elfcpp::abi_n32(this->processor_specific_flags()); } - // Whether the output uses N64 ABI. This is valid only after - // merge_processor_specific_flags() is called. + // Whether the output uses N64 ABI. bool is_output_n64() const - { - gold_assert(this->are_processor_specific_flags_set()); - return elfcpp::abi_64(this->ei_class_); - } + { return size == 64; } // Whether the output uses NEWABI. This is valid only after // merge_processor_specific_flags() is called. @@ -3860,8 +3853,7 @@ class Target_mips : public Sized_target // Merge processor specific flags. void - merge_processor_specific_flags(const std::string&, elfcpp::Elf_Word, - unsigned char, bool); + merge_processor_specific_flags(const std::string&, elfcpp::Elf_Word, bool); // True if we are linking for CPUs that are faster if JAL is converted to BAL. static inline bool @@ -3940,7 +3932,7 @@ class Target_mips : public Sized_target set_gp(Layout*, Symbol_table*); const char* - elf_mips_abi_name(elfcpp::Elf_Word e_flags, unsigned char ei_class); + elf_mips_abi_name(elfcpp::Elf_Word e_flags); const char* elf_mips_mach_name(elfcpp::Elf_Word e_flags); @@ -4053,7 +4045,6 @@ class Target_mips : public Sized_target // .MIPS.stubs Mips_output_data_mips_stubs* mips_stubs_; - unsigned char ei_class_; unsigned int mach_; Layout* layout_; @@ -8352,14 +8343,12 @@ Target_mips::mips_mach_extends(unsigned int base, template void Target_mips::merge_processor_specific_flags( - const std::string& name, elfcpp::Elf_Word in_flags, - unsigned char in_ei_class, bool dyn_obj) + const std::string& name, elfcpp::Elf_Word in_flags, bool dyn_obj) { // If flags are not set yet, just copy them. if (!this->are_processor_specific_flags_set()) { this->set_processor_specific_flags(in_flags); - this->ei_class_ = in_ei_class; this->mach_ = this->elf_mips_mach(in_flags); return; } @@ -8441,19 +8430,16 @@ Target_mips::merge_processor_specific_flags( old_flags &= (~(elfcpp::EF_MIPS_ARCH | elfcpp::EF_MIPS_MACH | elfcpp::EF_MIPS_32BITMODE)); - // Compare ABIs. The 64-bit ABI does not use EF_MIPS_ABI. But, it does set - // EI_CLASS differently from any 32-bit ABI. - if ((new_flags & elfcpp::EF_MIPS_ABI) != (old_flags & elfcpp::EF_MIPS_ABI) - || (in_ei_class != this->ei_class_)) + // Compare ABIs. + if ((new_flags & elfcpp::EF_MIPS_ABI) != (old_flags & elfcpp::EF_MIPS_ABI)) { // Only error if both are set (to different values). - if (((new_flags & elfcpp::EF_MIPS_ABI) + if ((new_flags & elfcpp::EF_MIPS_ABI) && (old_flags & elfcpp::EF_MIPS_ABI)) - || (in_ei_class != this->ei_class_)) gold_error(_("%s: ABI mismatch: linking %s module with " "previous %s modules"), name.c_str(), - this->elf_mips_abi_name(in_flags, in_ei_class), - this->elf_mips_abi_name(merged_flags, this->ei_class_)); + this->elf_mips_abi_name(in_flags), + this->elf_mips_abi_name(merged_flags)); new_flags &= ~elfcpp::EF_MIPS_ABI; old_flags &= ~elfcpp::EF_MIPS_ABI; @@ -8501,16 +8487,13 @@ Target_mips::do_adjust_elf_header( { gold_assert(len == elfcpp::Elf_sizes::ehdr_size); - elfcpp::Ehdr ehdr(view); - unsigned char e_ident[elfcpp::EI_NIDENT]; - memcpy(e_ident, ehdr.get_e_ident(), elfcpp::EI_NIDENT); - - e_ident[elfcpp::EI_CLASS] = this->ei_class_; + if (!this->entry_symbol_is_compressed_) + return; + elfcpp::Ehdr ehdr(view); elfcpp::Ehdr_write oehdr(view); - oehdr.put_e_ident(e_ident); - if (this->entry_symbol_is_compressed_) - oehdr.put_e_entry(ehdr.get_e_entry() + 1); + + oehdr.put_e_entry(ehdr.get_e_entry() + 1); } // do_make_elf_object to override the same function in the base class. @@ -8625,7 +8608,6 @@ Target_mips::do_finalize_sections(Layout* layout, elfcpp::Ehdr ehdr(pehdr); elfcpp::Elf_Word in_flags = ehdr.get_e_flags(); - unsigned char ei_class = ehdr.get_e_ident()[elfcpp::EI_CLASS]; // If all input sections will be discarded, don't use this object // file for merging processor specific flags. bool should_merge_processor_specific_flags = false; @@ -8639,7 +8621,7 @@ Target_mips::do_finalize_sections(Layout* layout, if (should_merge_processor_specific_flags) this->merge_processor_specific_flags(relobj->name(), in_flags, - ei_class, false); + false); } } @@ -8657,10 +8639,8 @@ Target_mips::do_finalize_sections(Layout* layout, elfcpp::Ehdr ehdr(pehdr); elfcpp::Elf_Word in_flags = ehdr.get_e_flags(); - unsigned char ei_class = ehdr.get_e_ident()[elfcpp::EI_CLASS]; - this->merge_processor_specific_flags(dynobj->name(), in_flags, ei_class, - true); + this->merge_processor_specific_flags(dynobj->name(), in_flags, true); } // Merge .reginfo contents of input objects. @@ -11238,15 +11218,14 @@ Target_mips::Scan::unsupported_reloc_global( // Return printable name for ABI. template const char* -Target_mips::elf_mips_abi_name(elfcpp::Elf_Word e_flags, - unsigned char ei_class) +Target_mips::elf_mips_abi_name(elfcpp::Elf_Word e_flags) { switch (e_flags & elfcpp::EF_MIPS_ABI) { case 0: if ((e_flags & elfcpp::EF_MIPS_ABI2) != 0) return "N32"; - else if (elfcpp::abi_64(ei_class)) + else if (size == 64) return "64"; else return "none"; -- 2.7.4