This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][GOLD] Handle bit-1 of THUMB BLX target address correctly.
- From: Ian Lance Taylor <iant at google dot com>
- To: Doug Kwan (éæå) <dougkwan at google dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Mon, 22 Mar 2010 15:41:46 -0700
- Subject: Re: [PATCH][GOLD] Handle bit-1 of THUMB BLX target address correctly.
- References: <498552561003221416g75fd2265rd18af1515bc77041@mail.gmail.com>
"Doug Kwan (éæå)" <dougkwan@google.com> writes:
> 2010-03-22 Doug Kwan <dougkwan@google.com>
>
> * arm.cc (Arm_relocate_functions::abs8,
> Arm_relocate_functions::abs16): Use correct check for overflow
> specified in the ARM ELF specs.
> (Arm_relocate_functions): thumb_branch_common. Handle bit 1 of branch
> target of a BLX instruction specially.
> (Reloc_stub::stub_type_for_reloc): Ditto.
> (Relocate::relocate): Use symbolic names instead of numeric relocation
> codes to report error.
> (Target_arm::do_relox): Reduce default stub-group size for Cortex-A8
> workaround.
> * testsuite/Makefile.am (check_DATA): add thumb_blx_in_range.stdout,
> thumb_blx_out_of_range.stdout, thumb2_blx_in_range.stdout and
> thumb2_blx_out_of_range.stdout
> (thumb_bl_out_of_range, thumb_bl_out_of_range.o,
> thumb2_bl_out_of_range, thumb2_bl_out_of_range.o): Fix dependenices.
> (thumb_blx_in_range.stdout, thumb_blx_in_range, thumb_blx_in_range.o,
> thumb_blx_out_of_range.stdout, thumb_blx_out_of_range,
> thumb_blx_out_of_range.o, thumb2_blx_in_range.stdout,
> thumb2_blx_in_range, thumb2_blx_in_range.o,
> thumb2_blx_out_of_range.stdout, thumb2_blx_out_of_range,
> thumb2_blx_out_of_range.o): New rules.
> (MOSTLYCLEANFILES): Add thumb_blx_in_range, thumb_blx_out_of_range,
> thumb2_blx_in_range and thumb2_blx_out_of_range.
> * testsuite/Makefile.in: Regenerate.
> * arm_branch_in_range.sh: Add tests for THUMB BLX.
> * testsuite/thumb_blx_in_range.s: New file.
> * testsuite/thumb_blx_out_of_range.s: New file.
> @@ -4225,10 +4240,15 @@ Reloc_stub::stub_type_for_reloc(
> thumb_only = little_endian_target->using_thumb_only();
> }
>
> - int64_t branch_offset = (int64_t)destination - location;
> -
> + int64_t branch_offset;
> if (r_type == elfcpp::R_ARM_THM_CALL || r_type == elfcpp::R_ARM_THM_JUMP24)
> {
> + // For THUMB BLX instruction, bit 1 of target comes from bit 1 of the
> + // base address (instruction address + 4).
> + if ((r_type == elfcpp::R_ARM_THM_CALL) && may_use_blx && !target_is_thumb)
> + destination = utils::bit_select(destination, location, 0x2);
> + branch_offset = (int64_t)destination - location;
Use static_cast<int64_t> here.
> @@ -4309,6 +4329,7 @@ Reloc_stub::stub_type_for_reloc(
> || r_type == elfcpp::R_ARM_JUMP24
> || r_type == elfcpp::R_ARM_PLT32)
> {
> + branch_offset = (int64_t)destination - location;
Here too.
This is OK with those changes.
Thanks.
Ian