/* 32-bit ELF support for ARM
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008 Free Software Foundation, Inc.
+ 2008, 2009 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
/* Helper function to scan code for sequences which might trigger the Cortex-A8
branch/TLB erratum. Fill in the table described by A8_FIXES_P,
- NUM_A8_FIXES_P, A8_FIX_TABLE_SIZE_P. Return 1 if an error occurs, 0
+ NUM_A8_FIXES_P, A8_FIX_TABLE_SIZE_P. Returns true if an error occurs, false
otherwise. */
-static int
-cortex_a8_erratum_scan (bfd *input_bfd, struct bfd_link_info *info,
+static bfd_boolean
+cortex_a8_erratum_scan (bfd *input_bfd,
+ struct bfd_link_info *info,
struct a8_erratum_fix **a8_fixes_p,
unsigned int *num_a8_fixes_p,
unsigned int *a8_fix_table_size_p,
if (elf_section_data (section)->this_hdr.contents != NULL)
contents = elf_section_data (section)->this_hdr.contents;
else if (! bfd_malloc_and_get_section (input_bfd, section, &contents))
- return 1;
+ return TRUE;
sec_data = elf32_arm_section_data (section);
* The branch target is in the same 4KB region as the
first half of the branch.
* The instruction before the branch is a 32-bit
- length non-branch instruction.
- */
-
+ length non-branch instruction. */
for (i = span_start; i < span_end;)
{
unsigned int insn = bfd_getl16 (&contents[i]);
is_32bit_branch = is_b || is_bl || is_blx || is_bcc;
- if (((base_vma + i) & 0xfff) == 0xffe && insn_32bit
- && is_32bit_branch && last_was_32bit && !last_was_branch)
+ 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;
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)
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;
}
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;
*num_a8_fixes_p = num_a8_fixes;
*a8_fix_table_size_p = a8_fix_table_size;
- return 0;
+ return FALSE;
}
/* Determine and set the size of the stub section for a final link.