[PATCH][ARM]. Fix a 64-bit portability bug in cortex_a8_erratum_scan.
Doug Kwan (關振德)
dougkwan@google.com
Fri Jun 12 00:41:00 GMT 2009
This patch fixes a 64-bit portability bug in the cortex-a8 erratum
workaround code that causes the test-case cortex-a8-fix-blx to fail on
an x86_64 host. I tested this patch on both 32-bit and 64-bit builds
of an arm-none-eabi binutils on an x86_64-unknown-linux-gnu host. All
the linker test-cases passed.
-Doug
2009-06-11 Doug Kwan <dougkwan@google.com>
* elf32-arm.c (cortex_a8_erratum_scan): Change type of offset
to bfd_signed_vma. Cast all constant operands which are used
in offset related expressions to bfd_signed_vma type.
-------------- next part --------------
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.196
diff -u -u -p -r1.196 elf32-arm.c
--- bfd/elf32-arm.c 22 May 2009 11:58:44 -0000 1.196
+++ bfd/elf32-arm.c 12 Jun 2009 00:30:17 -0000
@@ -3981,7 +3981,7 @@ cortex_a8_erratum_scan (bfd *input_bfd,
if (((base_vma + i) & 0xfff) == 0xffe && insn_32bit
&& is_32bit_branch && last_was_32bit && !last_was_branch)
{
- bfd_vma offset;
+ bfd_signed_vma offset;
bfd_boolean force_target_arm = FALSE;
bfd_boolean force_target_thumb = FALSE;
bfd_vma target;
@@ -4030,7 +4030,7 @@ cortex_a8_erratum_scan (bfd *input_bfd,
offset |= (insn & 0x800) ? 0x80000 : 0;
offset |= (insn & 0x4000000) ? 0x100000 : 0;
if (offset & 0x100000)
- offset |= ~0xfffff;
+ offset |= ~((bfd_signed_vma) 0xfffff);
stub_type = arm_stub_a8_veneer_b_cond;
}
else if (is_b || is_bl || is_blx)
@@ -4047,10 +4047,10 @@ cortex_a8_erratum_scan (bfd *input_bfd,
offset |= i1 << 23;
offset |= s << 24;
if (offset & 0x1000000)
- offset |= ~0xffffff;
+ offset |= ~((bfd_signed_vma) 0xffffff);
if (is_blx)
- offset &= ~3u;
+ offset &= ~((bfd_signed_vma) 3);
stub_type = is_blx ? arm_stub_a8_veneer_blx :
is_bl ? arm_stub_a8_veneer_bl : arm_stub_a8_veneer_b;
@@ -4083,14 +4083,15 @@ cortex_a8_erratum_scan (bfd *input_bfd,
}
if (is_blx)
- pc_for_insn &= ~3u;
+ pc_for_insn &= ~((bfd_vma) 3);
/* If we found a relocation, use the proper destination,
not the offset in the (unrelocated) instruction.
Note this is always done if we switched the stub type
above. */
if (found)
- offset = found->destination - pc_for_insn;
+ offset =
+ (bfd_signed_vma)(found->destination - pc_for_insn);
target = pc_for_insn + offset;
More information about the Binutils
mailing list