diff options
author | Doug Kwan <dougkwan@google.com> | 2010-02-22 06:26:07 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2010-02-22 06:26:07 +0000 |
commit | 2a2b6d42b1a946cfaff8819925cdd15bee44d015 (patch) | |
tree | c434f4f73a93b26045882f05cb1b75f5e468f578 /gold/arm.cc | |
parent | 109af718c00cca36ea5c141464bfb51fbac068ce (diff) | |
download | gdb-2a2b6d42b1a946cfaff8819925cdd15bee44d015.zip gdb-2a2b6d42b1a946cfaff8819925cdd15bee44d015.tar.gz gdb-2a2b6d42b1a946cfaff8819925cdd15bee44d015.tar.bz2 |
2010-02-21 Doug Kwan <dougkwan@google.com>
* arm.cc (Arm_relocate_functions::arm_branch_common): Fix bug in
handling of the maximum backward branch offset.
(Arm_relocate_functions::thumb_branch_common): Ditto.
* testsuite/Makefile.am (check_SCRIPTS): Add arm_branch_in_range.sh.
(check_DATA): Add arm_bl_in_range.stdout, arm_bl_out_of_range.stdout
thumb_bl_in_range.stdout, thumb_bl_out_of_range.stdout,
thumb2_bl_in_range.stdout and thumb2_bl_out_of_range.stdout.
(arm_bl_in_range.stdout, arm_bl_in_range, arm_bl_in_range.o,
arm_bl_out_of_range.stdout, arm_bl_out_of_range,
arm_bl_out_of_range.o, thumb_bl_in_range.stdout, thumb_bl_in_range,
thumb_bl_in_range.o, thumb_bl_out_of_range.stdout,
thumb_bl_out_of_range thumb_bl_out_of_range.o,
thumb2_bl_in_range.stdout, thumb2_bl_in_range, thumb2_bl_in_range.o
thumb2_bl_out_of_range.stdout, thumb2_bl_out_of_range,
thumb2_bl_out_of_range.o): New rules.
(MOSTLYCLEANFILES): Add arm_bl_in_range, arm_bl_out_of_range,
thumb_bl_in_range, thumb_bl_out_of_range, thumb2_bl_in_range and
thumb2_bl_out_of_range
* testsuite/Makefile.in: Regenerate.
* testsuite/arm_bl_in_range.s: New file.
* testsuite/arm_bl_out_of_range.s: Ditto.
* testsuite/arm_branch_in_range.sh: Ditto.
* testsuite/arm_branch_range.t: Ditto.
* testsuite/thumb2_branch_range.t: Ditto.
* testsuite/thumb_bl_in_range.s: Ditto.
* testsuite/thumb_bl_out_of_range.s: Ditto.
* testsuite/thumb_branch_range.t: Ditto.
Diffstat (limited to 'gold/arm.cc')
-rw-r--r-- | gold/arm.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gold/arm.cc b/gold/arm.cc index 6348470..bc5557a 100644 --- a/gold/arm.cc +++ b/gold/arm.cc @@ -3547,12 +3547,14 @@ Arm_relocate_functions<big_endian>::arm_branch_common( // to switch mode. bool may_use_blx = arm_target->may_use_blx(); Reloc_stub* stub = NULL; - if ((branch_offset > ARM_MAX_FWD_BRANCH_OFFSET) - || (branch_offset < ARM_MAX_BWD_BRANCH_OFFSET) + if (utils::has_overflow<26>(branch_offset) || ((thumb_bit != 0) && !(may_use_blx && r_type == elfcpp::R_ARM_CALL))) { + Valtype unadjusted_branch_target = psymval->value(object, 0); + Stub_type stub_type = - Reloc_stub::stub_type_for_reloc(r_type, address, branch_target, + Reloc_stub::stub_type_for_reloc(r_type, address, + unadjusted_branch_target, (thumb_bit != 0)); if (stub_type != arm_stub_none) { @@ -3566,8 +3568,7 @@ Arm_relocate_functions<big_endian>::arm_branch_common( thumb_bit = stub->stub_template()->entry_in_thumb_mode() ? 1 : 0; branch_target = stub_table->address() + stub->offset() + addend; branch_offset = branch_target - address; - gold_assert((branch_offset <= ARM_MAX_FWD_BRANCH_OFFSET) - && (branch_offset >= ARM_MAX_BWD_BRANCH_OFFSET)); + gold_assert(!utils::has_overflow<26>(branch_offset)); } } @@ -3675,19 +3676,19 @@ Arm_relocate_functions<big_endian>::thumb_branch_common( // to switch mode. bool may_use_blx = arm_target->may_use_blx(); bool thumb2 = arm_target->using_thumb2(); - if ((!thumb2 - && (branch_offset > THM_MAX_FWD_BRANCH_OFFSET - || (branch_offset < THM_MAX_BWD_BRANCH_OFFSET))) - || (thumb2 - && (branch_offset > THM2_MAX_FWD_BRANCH_OFFSET - || (branch_offset < THM2_MAX_BWD_BRANCH_OFFSET))) + if ((!thumb2 && utils::has_overflow<23>(branch_offset)) + || (thumb2 && utils::has_overflow<25>(branch_offset)) || ((thumb_bit == 0) && (((r_type == elfcpp::R_ARM_THM_CALL) && !may_use_blx) || r_type == elfcpp::R_ARM_THM_JUMP24))) { + Arm_address unadjusted_branch_target = psymval->value(object, 0); + Stub_type stub_type = - Reloc_stub::stub_type_for_reloc(r_type, address, branch_target, + Reloc_stub::stub_type_for_reloc(r_type, address, + unadjusted_branch_target, (thumb_bit != 0)); + if (stub_type != arm_stub_none) { Stub_table<big_endian>* stub_table = |