From a6d1ef576a49bde0b6813e02e354f9172ba94077 Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Wed, 25 Nov 2009 08:08:45 +0000 Subject: [PATCH] 2009-11-25 Doug Kwan Revert: 2009-11-25 Doug Kwan * arm.cc (Target_arm::Target_arm): Move method definition outside of class definition. Add code to handle --target1-rel, --target1-abs and --target2= options. (Target_arm::get_reloc_reloc_type): Change method to be non-static and const. (Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data member declaration. (Target_arm::Scan::local, Target_arm::Scan::global, Target_arm::Relocate::relocate, Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust call to Target_arm::get_real_reloc_type. (Target_arm::get_real_reloc_type): Use command line options to determine real types of R_ARM_TARGET1 and R_ARM_TARGET2. * options.h (--target1-rel, --target1-abs, --target2): New ARM-only options. --- gold/ChangeLog | 22 ++++++++++++++ gold/arm.cc | 81 ++++++++++++-------------------------------------- gold/options.h | 11 ------- 3 files changed, 41 insertions(+), 73 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index c82ba7c053e..9415a231ec7 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,25 @@ +2009-11-25 Doug Kwan + + Revert: + + 2009-11-25 Doug Kwan + + * arm.cc (Target_arm::Target_arm): Move method definition + outside of class definition. Add code to handle + --target1-rel, --target1-abs and --target2= options. + (Target_arm::get_reloc_reloc_type): Change method to be + non-static and const. + (Target_arm::target1_is_rel_, Target_arm::target2_reloc_): + New data member declaration. + (Target_arm::Scan::local, Target_arm::Scan::global, + Target_arm::Relocate::relocate, + Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): + Adjust call to Target_arm::get_real_reloc_type. + (Target_arm::get_real_reloc_type): Use command line options + to determine real types of R_ARM_TARGET1 and R_ARM_TARGET2. + * options.h (--target1-rel, --target1-abs, --target2): New + ARM-only options. + 2009-11-25 Doug Kwan * arm.cc (Target_arm::Target_arm): Move method definition outside of diff --git a/gold/arm.cc b/gold/arm.cc index d8e274e894e..3ea98de853c 100644 --- a/gold/arm.cc +++ b/gold/arm.cc @@ -1142,7 +1142,14 @@ class Target_arm : public Sized_target<32, big_endian> // When were are relocating a stub, we pass this as the relocation number. static const size_t fake_relnum_for_stubs = static_cast(-1); - Target_arm(); + Target_arm() + : Sized_target<32, big_endian>(&arm_info), + got_(NULL), plt_(NULL), got_plt_(NULL), rel_dyn_(NULL), + copy_relocs_(elfcpp::R_ARM_COPY), dynbss_(NULL), stub_tables_(), + stub_factory_(Stub_factory::get_instance()), + may_use_blx_(true), should_force_pic_veneer_(false), + arm_input_section_map_() + { } // Whether we can use BLX. bool @@ -1291,8 +1298,8 @@ class Target_arm : public Sized_target<32, big_endian> } // Map platform-specific reloc types - unsigned int - get_real_reloc_type (unsigned int r_type) const; + static unsigned int + get_real_reloc_type (unsigned int r_type); // // Methods to support stub-generations. @@ -1624,11 +1631,6 @@ class Target_arm : public Sized_target<32, big_endian> Stub_table_list stub_tables_; // Stub factory. const Stub_factory &stub_factory_; - // Whether R_ARM_TARGET1 maps to R_ARM_REL32 or R_ARM_ABS32. - bool target1_is_rel_; - // What R_ARM_TARGET2 maps to. It should be one of R_ARM_REL32, R_ARM_ABS32 - // and R_ARM_GOT_PREL. - unsigned int target2_reloc_; // Whether we can use BLX. bool may_use_blx_; // Whether we force PIC branch veneers. @@ -2308,51 +2310,6 @@ Arm_relocate_functions::arm_branch_common( ? This::STATUS_OVERFLOW : This::STATUS_OKAY); } -template -Target_arm::Target_arm() - : Sized_target<32, big_endian>(&arm_info), - got_(NULL), plt_(NULL), got_plt_(NULL), rel_dyn_(NULL), - copy_relocs_(elfcpp::R_ARM_COPY), dynbss_(NULL), stub_tables_(), - stub_factory_(Stub_factory::get_instance()), target1_is_rel_(false), - may_use_blx_(true), should_force_pic_veneer_(false), - arm_input_section_map_() -{ - // FIXME: This is not strictly compatible with ld, which allows both - // --target1-abs and --target-rel to be given. - if (parameters->options().user_set_target1_abs() - && parameters->options().user_set_target1_rel()) - { - gold_error(_("Cannot use both --target1-abs and --target1-rel.")); - } - else if (parameters->options().user_set_target1_rel()) - this->target1_is_rel_ = true; - else if (parameters->options().user_set_target1_abs()) - this->target1_is_rel_ = false; - - if (parameters->options().user_set_target2()) - { - if (strcmp(parameters->options().target2(), "rel") == 0) - this->target2_reloc_ = elfcpp::R_ARM_REL32; - else if (strcmp(parameters->options().target2(), "abs") == 0) - this->target2_reloc_ = elfcpp::R_ARM_ABS32; - else if (strcmp(parameters->options().target2(), "got-rel") == 0) - this->target2_reloc_ = elfcpp::R_ARM_GOT_PREL; - else - gold_unreachable(); - } - else - { - // Default values for R_ARM_TARGET2: - // - // R_ARM_REL32 (arm*-*-elf, arm*-*-eabi) - // R_ARM_ABS32 (arm*-*-symbianelf) - // R_ARM_GOT_PREL (arm*-*-linux, arm*-*-*bsd) - - // This is the default value for EABI. - this->target2_reloc_ = elfcpp::R_ARM_REL32; - } -} - // Relocate THUMB long branches. This handles relocation types // R_ARM_THM_CALL, R_ARM_THM_JUMP24 and R_ARM_THM_XPC22. // If IS_WEAK_UNDEFINED_WITH_PLT is true. The target symbol is weakly @@ -4209,7 +4166,7 @@ Target_arm::Scan::local(Symbol_table* symtab, unsigned int r_type, const elfcpp::Sym<32, big_endian>&) { - r_type = target->get_real_reloc_type(r_type); + r_type = get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -4336,7 +4293,7 @@ Target_arm::Scan::global(Symbol_table* symtab, unsigned int r_type, Symbol* gsym) { - r_type = target->get_real_reloc_type(r_type); + r_type = get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -4748,7 +4705,7 @@ Target_arm::Relocate::relocate( { typedef Arm_relocate_functions Arm_relocate_functions; - r_type = target->get_real_reloc_type(r_type); + r_type = get_real_reloc_type(r_type); const Arm_relobj* object = Arm_relobj::as_arm_relobj(relinfo->object); @@ -5213,9 +5170,7 @@ Target_arm::Relocatable_size_for_reloc::get_size_for_reloc( unsigned int r_type, Relobj* object) { - const Target_arm* arm_target = - Target_arm::default_target(); - r_type = arm_target->get_real_reloc_type(r_type); + r_type = get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -5360,15 +5315,17 @@ Target_arm::do_dynsym_value(const Symbol* gsym) const // template unsigned int -Target_arm::get_real_reloc_type (unsigned int r_type) const +Target_arm::get_real_reloc_type (unsigned int r_type) { switch (r_type) { case elfcpp::R_ARM_TARGET1: - return this->target1_is_rel_? elfcpp::R_ARM_REL32 : elfcpp::R_ARM_ABS32; + // This is either R_ARM_ABS32 or R_ARM_REL32; + return elfcpp::R_ARM_ABS32; case elfcpp::R_ARM_TARGET2: - return this->target2_reloc_; + // This can be any reloc type but ususally is R_ARM_GOT_PREL + return elfcpp::R_ARM_GOT_PREL; default: return r_type; diff --git a/gold/options.h b/gold/options.h index e17735aaaf4..399c3015c71 100644 --- a/gold/options.h +++ b/gold/options.h @@ -884,17 +884,6 @@ class General_options DEFINE_string(sysroot, options::TWO_DASHES, '\0', "", N_("Set target system root directory"), N_("DIR")); - DEFINE_bool(target1_rel, options::TWO_DASHES, '\0', false, - N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_REL32"), - NULL); - DEFINE_bool(target1_abs, options::TWO_DASHES, '\0', false, - N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_ABS32"), - NULL); - DEFINE_enum(target2, options::TWO_DASHES, '\0', "default", - N_("(ARM only) Set R_ARM_TARGET2 relocation type"), - N_("[default, rel, abs, got-rel"), - {"default", "rel", "abs", "got-rel"}); - DEFINE_bool(trace, options::TWO_DASHES, 't', false, N_("Print the name of each input file"), NULL); -- 2.30.2