From: Doug Kwan Date: Wed, 25 Nov 2009 04:32:36 +0000 (+0000) Subject: 2009-11-25 Doug Kwan X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50aeb7d4316c838b8d3d41c2191a7ec2a0874f49;p=binutils-gdb.git 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. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 041c9e6317d..c82ba7c053e 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,21 @@ +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::may_use_thumb2_nop): New method definition. diff --git a/gold/arm.cc b/gold/arm.cc index 3ea98de853c..d8e274e894e 100644 --- a/gold/arm.cc +++ b/gold/arm.cc @@ -1142,14 +1142,7 @@ 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() - : 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_() - { } + Target_arm(); // Whether we can use BLX. bool @@ -1298,8 +1291,8 @@ class Target_arm : public Sized_target<32, big_endian> } // Map platform-specific reloc types - static unsigned int - get_real_reloc_type (unsigned int r_type); + unsigned int + get_real_reloc_type (unsigned int r_type) const; // // Methods to support stub-generations. @@ -1631,6 +1624,11 @@ 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. @@ -2310,6 +2308,51 @@ 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 @@ -4166,7 +4209,7 @@ Target_arm::Scan::local(Symbol_table* symtab, unsigned int r_type, const elfcpp::Sym<32, big_endian>&) { - r_type = get_real_reloc_type(r_type); + r_type = target->get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -4293,7 +4336,7 @@ Target_arm::Scan::global(Symbol_table* symtab, unsigned int r_type, Symbol* gsym) { - r_type = get_real_reloc_type(r_type); + r_type = target->get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -4705,7 +4748,7 @@ Target_arm::Relocate::relocate( { typedef Arm_relocate_functions Arm_relocate_functions; - r_type = get_real_reloc_type(r_type); + r_type = target->get_real_reloc_type(r_type); const Arm_relobj* object = Arm_relobj::as_arm_relobj(relinfo->object); @@ -5170,7 +5213,9 @@ Target_arm::Relocatable_size_for_reloc::get_size_for_reloc( unsigned int r_type, Relobj* object) { - r_type = get_real_reloc_type(r_type); + const Target_arm* arm_target = + Target_arm::default_target(); + r_type = arm_target->get_real_reloc_type(r_type); switch (r_type) { case elfcpp::R_ARM_NONE: @@ -5315,17 +5360,15 @@ Target_arm::do_dynsym_value(const Symbol* gsym) const // template unsigned int -Target_arm::get_real_reloc_type (unsigned int r_type) +Target_arm::get_real_reloc_type (unsigned int r_type) const { switch (r_type) { case elfcpp::R_ARM_TARGET1: - // This is either R_ARM_ABS32 or R_ARM_REL32; - return elfcpp::R_ARM_ABS32; + return this->target1_is_rel_? elfcpp::R_ARM_REL32 : elfcpp::R_ARM_ABS32; case elfcpp::R_ARM_TARGET2: - // This can be any reloc type but ususally is R_ARM_GOT_PREL - return elfcpp::R_ARM_GOT_PREL; + return this->target2_reloc_; default: return r_type; diff --git a/gold/options.h b/gold/options.h index 399c3015c71..e17735aaaf4 100644 --- a/gold/options.h +++ b/gold/options.h @@ -884,6 +884,17 @@ 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);