/* BFD back-end for ARM COFF files.
- Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
PARAMS ((bfd *, struct coff_final_link_info *));
static boolean coff_arm_final_link_postscript
PARAMS ((bfd *, struct coff_final_link_info *));
+static void arm_emit_base_file_entry
+ PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma));
/* The linker script knows the section names for placement.
The entry_names are used to do simple name mangling on the stubs.
Given a function name, and its type, the stub can be found. The
- name can be changed. The only requirement is the %s be present.
- */
+ name can be changed. The only requirement is the %s be present. */
#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t"
#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb"
#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm"
/* Used by the assembler. */
+
static bfd_reloc_status_type
coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
error_message)
#endif
static reloc_howto_type aoutarm_std_reloc_howto[] =
-{
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+ {
#ifdef ARM_WINCE
- EMPTY_HOWTO (-1),
- HOWTO (ARM_32,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
- HOWTO (ARM_RVA32,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_RVA32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
- HOWTO (ARM_26,
- 2,
- 2,
- 24,
- true,
- 0,
- complain_overflow_signed,
- aoutarm_fix_pcrel_26 ,
- "ARM_26",
- false,
- 0x00ffffff,
- 0x00ffffff,
- PCRELOFFSET),
- HOWTO (ARM_THUMB12,
- 1,
- 1,
- 11,
- true,
- 0,
- complain_overflow_signed,
- coff_thumb_pcrel_12 ,
- "ARM_THUMB12",
- false,
- 0x000007ff,
- 0x000007ff,
- PCRELOFFSET),
- HOWTO (ARM_26D,
- 2,
- 2,
- 24,
- false,
- 0,
- complain_overflow_dont,
- aoutarm_fix_pcrel_26_done,
- "ARM_26D",
- true,
- 0x00ffffff,
- 0x0,
- false),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- EMPTY_HOWTO (-1),
- HOWTO (ARM_SECTION,
- 0,
- 1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- PCRELOFFSET),
- HOWTO (ARM_SECREL,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
+ EMPTY_HOWTO (-1),
+ HOWTO (ARM_32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_RVA32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_RVA32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_26,
+ 2,
+ 2,
+ 24,
+ true,
+ 0,
+ complain_overflow_signed,
+ aoutarm_fix_pcrel_26 ,
+ "ARM_26",
+ false,
+ 0x00ffffff,
+ 0x00ffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_THUMB12,
+ 1,
+ 1,
+ 11,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_12 ,
+ "ARM_THUMB12",
+ false,
+ 0x000007ff,
+ 0x000007ff,
+ PCRELOFFSET),
+ HOWTO (ARM_26D,
+ 2,
+ 2,
+ 24,
+ false,
+ 0,
+ complain_overflow_dont,
+ aoutarm_fix_pcrel_26_done,
+ "ARM_26D",
+ true,
+ 0x00ffffff,
+ 0x0,
+ false),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ EMPTY_HOWTO (-1),
+ HOWTO (ARM_SECTION,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ PCRELOFFSET),
+ HOWTO (ARM_SECREL,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
#else /* not ARM_WINCE */
- HOWTO(ARM_8, /* type */
- 0, /* rightshift */
- 0, /* size */
- 8, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_arm_reloc, /* special_function */
- "ARM_8", /* name */
- true, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
- PCRELOFFSET /* pcrel_offset */),
- HOWTO(ARM_16,
- 0,
- 1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- PCRELOFFSET),
- HOWTO(ARM_32,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
- HOWTO(ARM_26,
- 2,
- 2,
- 24,
- true,
- 0,
- complain_overflow_signed,
- aoutarm_fix_pcrel_26 ,
- "ARM_26",
- false,
- 0x00ffffff,
- 0x00ffffff,
- PCRELOFFSET),
- HOWTO(ARM_DISP8,
- 0,
- 0,
- 8,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "ARM_DISP8",
- true,
- 0x000000ff,
- 0x000000ff,
- true),
- HOWTO( ARM_DISP16,
- 0,
- 1,
- 16,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "ARM_DISP16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- true),
- HOWTO( ARM_DISP32,
- 0,
- 2,
- 32,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "ARM_DISP32",
- true,
- 0xffffffff,
- 0xffffffff,
- true),
- HOWTO( ARM_26D,
- 2,
- 2,
- 24,
- false,
- 0,
- complain_overflow_dont,
- aoutarm_fix_pcrel_26_done,
- "ARM_26D",
- true,
- 0x00ffffff,
- 0x0,
- false),
- /* 8 is unused */
- EMPTY_HOWTO (-1),
- HOWTO( ARM_NEG16,
- 0,
- -1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_NEG16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- false),
- HOWTO( ARM_NEG32,
- 0,
- -2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_NEG32",
- true,
- 0xffffffff,
- 0xffffffff,
- false),
- HOWTO( ARM_RVA32,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "ARM_RVA32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
- HOWTO( ARM_THUMB9,
- 1,
- 1,
- 8,
- true,
- 0,
- complain_overflow_signed,
- coff_thumb_pcrel_9 ,
- "ARM_THUMB9",
- false,
- 0x000000ff,
- 0x000000ff,
- PCRELOFFSET),
- HOWTO( ARM_THUMB12,
- 1,
- 1,
- 11,
- true,
- 0,
- complain_overflow_signed,
- coff_thumb_pcrel_12 ,
- "ARM_THUMB12",
- false,
- 0x000007ff,
- 0x000007ff,
- PCRELOFFSET),
- HOWTO( ARM_THUMB23,
- 1,
- 2,
- 22,
- true,
- 0,
- complain_overflow_signed,
- coff_thumb_pcrel_23 ,
- "ARM_THUMB23",
- false,
- 0x07ff07ff,
- 0x07ff07ff,
- PCRELOFFSET)
+ HOWTO (ARM_8, /* type */
+ 0, /* rightshift */
+ 0, /* size */
+ 8, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_arm_reloc, /* special_function */
+ "ARM_8", /* name */
+ true, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ PCRELOFFSET /* pcrel_offset */),
+ HOWTO (ARM_16,
+ 0,
+ 1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ PCRELOFFSET),
+ HOWTO (ARM_32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_26,
+ 2,
+ 2,
+ 24,
+ true,
+ 0,
+ complain_overflow_signed,
+ aoutarm_fix_pcrel_26 ,
+ "ARM_26",
+ false,
+ 0x00ffffff,
+ 0x00ffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_DISP8,
+ 0,
+ 0,
+ 8,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP8",
+ true,
+ 0x000000ff,
+ 0x000000ff,
+ true),
+ HOWTO (ARM_DISP16,
+ 0,
+ 1,
+ 16,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ true),
+ HOWTO (ARM_DISP32,
+ 0,
+ 2,
+ 32,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_arm_reloc,
+ "ARM_DISP32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ true),
+ HOWTO (ARM_26D,
+ 2,
+ 2,
+ 24,
+ false,
+ 0,
+ complain_overflow_dont,
+ aoutarm_fix_pcrel_26_done,
+ "ARM_26D",
+ true,
+ 0x00ffffff,
+ 0x0,
+ false),
+ /* 8 is unused */
+ EMPTY_HOWTO (-1),
+ HOWTO (ARM_NEG16,
+ 0,
+ -1,
+ 16,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_NEG16",
+ true,
+ 0x0000ffff,
+ 0x0000ffff,
+ false),
+ HOWTO (ARM_NEG32,
+ 0,
+ -2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_NEG32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ false),
+ HOWTO (ARM_RVA32,
+ 0,
+ 2,
+ 32,
+ false,
+ 0,
+ complain_overflow_bitfield,
+ coff_arm_reloc,
+ "ARM_RVA32",
+ true,
+ 0xffffffff,
+ 0xffffffff,
+ PCRELOFFSET),
+ HOWTO (ARM_THUMB9,
+ 1,
+ 1,
+ 8,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_9 ,
+ "ARM_THUMB9",
+ false,
+ 0x000000ff,
+ 0x000000ff,
+ PCRELOFFSET),
+ HOWTO (ARM_THUMB12,
+ 1,
+ 1,
+ 11,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_12 ,
+ "ARM_THUMB12",
+ false,
+ 0x000007ff,
+ 0x000007ff,
+ PCRELOFFSET),
+ HOWTO (ARM_THUMB23,
+ 1,
+ 2,
+ 22,
+ true,
+ 0,
+ complain_overflow_signed,
+ coff_thumb_pcrel_23 ,
+ "ARM_THUMB23",
+ false,
+ 0x07ff07ff,
+ 0x07ff07ff,
+ PCRELOFFSET)
#endif /* not ARM_WINCE */
-};
+ };
#define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto)
#ifdef COFF_WITH_PE
+static boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
/* Return true if this relocation should
appear in the output .reloc section. */
return howto;
}
+
/* Used by the assembler. */
static bfd_reloc_status_type
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
bfd_reloc_status_type flag = bfd_reloc_ok;
- /* If this is an undefined symbol, return error */
+ /* If this is an undefined symbol, return error. */
if (symbol->section == &bfd_und_section
&& (symbol->flags & BSF_WEAK) == 0)
return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
return bfd_reloc_continue;
relocation = (target & 0x00ffffff) << 2;
- relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+ relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend. */
relocation += symbol->value;
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
if (relocation & 3)
return bfd_reloc_overflow;
- /* Check for overflow */
+ /* Check for overflow. */
if (relocation & 0x02000000)
{
if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
abort ();
}
- /* If this is an undefined symbol, return error */
+ /* If this is an undefined symbol, return error. */
if (symbol->section == &bfd_und_section
&& (symbol->flags & BSF_WEAK) == 0)
return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
abort ();
}
- relocation = (relocation ^ signbit) - signbit; /* Sign extend */
+ relocation = (relocation ^ signbit) - signbit; /* Sign extend. */
relocation += symbol->value;
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
if (relocation & 1)
return bfd_reloc_overflow;
- /* Check for overflow */
+ /* Check for overflow. */
if (relocation & signbit)
{
if ((relocation & ~offmsk) != ~offmsk)
Strictly this is only necessary if we are doing a partial relocation. */
reloc_entry->howto = & aoutarm_std_reloc_howto [ARM_26D];
- /* TODO: We should possibly have DONE entries for the THUMB PCREL relocations */
+ /* TODO: We should possibly have DONE entries for the THUMB PCREL relocations. */
return flag;
}
case 32:
code = BFD_RELOC_32;
break;
- default: return (CONST struct reloc_howto_struct *) 0;
+ default:
+ return (CONST struct reloc_howto_struct *) 0;
}
switch (code)
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH9, ARM_THUMB9);
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12);
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23);
+ ASTD (BFD_RELOC_THUMB_PCREL_BLX, ARM_THUMB23);
#endif
default: return (CONST struct reloc_howto_struct *) 0;
}
This allows us to store global data here without actually creating any
global variables, which is a no-no in the BFD world. */
struct coff_arm_link_hash_table
-{
- /* The original coff_link_hash_table structure. MUST be first field. */
- struct coff_link_hash_table root;
+ {
+ /* The original coff_link_hash_table structure. MUST be first field. */
+ struct coff_link_hash_table root;
- /* The size in bytes of the section containg the Thumb-to-ARM glue. */
- long int thumb_glue_size;
+ /* The size in bytes of the section containg the Thumb-to-ARM glue. */
+ long int thumb_glue_size;
- /* The size in bytes of the section containg the ARM-to-Thumb glue. */
- long int arm_glue_size;
+ /* The size in bytes of the section containg the ARM-to-Thumb glue. */
+ long int arm_glue_size;
- /* An arbitary input BFD chosen to hold the glue sections. */
- bfd * bfd_of_glue_owner;
+ /* An arbitary input BFD chosen to hold the glue sections. */
+ bfd * bfd_of_glue_owner;
- /* Support interworking with old, non-interworking aware ARM code. */
- int support_old_code;
+ /* Support interworking with old, non-interworking aware ARM code. */
+ int support_old_code;
};
/* Get the ARM coff linker hash table from a link_info structure. */
+ input_section->output_offset
+ input_section->output_section->vma;
- if (coff_data(output_bfd)->pe)
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
- fwrite (&addr, 1, sizeof (addr), (FILE *) info->base_file);
+ if (coff_data (output_bfd)->pe)
+ addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
+ fwrite (& addr, 1, sizeof (addr), (FILE *) info->base_file);
}
\f
moves the computed address into the PC, so it must be the second one
in the sequence. The problem, however is that whilst little endian code
stores the instructions in HI then LOW order, big endian code does the
- reverse. nickc@cygnus.com */
+ reverse. nickc@cygnus.com. */
#define LOW_HI_ORDER 0xF800F000
#define HI_LOW_ORDER 0xF000F800
else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER)
br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits;
else
- abort (); /* error - not a valid branch instruction form */
-
- /* FIXME: abort is probably not the right call. krk@cygnus.com */
+ /* FIXME: the BFD library should never abort - it should return an error status. */
+ abort (); /* Error - not a valid branch instruction form. */
return br_insn;
}
-
\f
static struct coff_link_hash_entry *
find_thumb_glue (info, name, input_bfd)
{
if (info->relocateable)
continue;
-#if 0 /* We must not ignore the symbol value. If the symbol is
- within the same section, the relocation should have already
- been fixed, but if it is not, we'll be handed a reloc into
- the beginning of the symbol's section, so we must not cancel
- out the symbol's value, otherwise we'll be adding it in
- twice. */
+ /* FIXME - it is not clear which targets need this next test
+ and which do not. It is known that it is needed for the
+ VxWorks and EPOC-PE targets, but it is also known that it
+ was supressed for other ARM targets. This ought to be
+ sorted out one day. */
+#ifdef ARM_COFF_BUGFIX
+ /* We must not ignore the symbol value. If the symbol is
+ within the same section, the relocation should have already
+ been fixed, but if it is not, we'll be handed a reloc into
+ the beginning of the symbol's section, so we must not cancel
+ out the symbol's value, otherwise we'll be adding it in
+ twice. */
if (sym != NULL && sym->n_scnum != 0)
addend += sym->n_value;
#endif
if ( h->class == C_THUMBSTATFUNC
|| h->class == C_THUMBEXTFUNC)
{
- /* Arm code calling a Thumb function */
+ /* Arm code calling a Thumb function. */
unsigned long int tmp;
long int my_offset;
asection * s;
}
#ifndef ARM_WINCE
- /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12 */
+ /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12. */
else if (howto->type == ARM_THUMB23)
{
if ( h->class == C_EXT
s->contents + my_offset + 2);
ret_offset =
- ((bfd_signed_vma) h_val) /* Address of destination of the stub */
+ ((bfd_signed_vma) h_val) /* Address of destination of the stub. */
- ((bfd_signed_vma)
(s->output_offset /* Offset from the start of the current section to the start of the stubs. */
+ my_offset /* Offset of the start of this stub from the start of the stubs. */
BFD_ASSERT (size == 4);
- /* howto->pc_relative should be TRUE for type 14 BRANCH23 */
+ /* howto->pc_relative should be TRUE for type 14 BRANCH23. */
relocation -= (input_section->output_section->vma
+ input_section->output_offset);
- /* howto->pcrel_offset should be TRUE for type 14 BRANCH23 */
+ /* howto->pcrel_offset should be TRUE for type 14 BRANCH23. */
relocation -= address;
/* No need to negate the relocation with BRANCH23. */
/* howto->complain_on_overflow == complain_overflow_signed for BRANCH23. */
/* howto->rightshift == 1 */
- /* Drop unwanted bits from the value we are relocating to. */
+ /* Drop unwanted bits from the value we are relocating to. */
check = relocation >> howto->rightshift;
/* If this is a signed value, the rightshift just dropped
/* Get the value from the object file. */
if (bfd_big_endian (input_bfd))
- {
- add = (((x) & 0x07ff0000) >> 4) | (((x) & 0x7ff) << 1);
- }
+ add = (((x) & 0x07ff0000) >> 4) | (((x) & 0x7ff) << 1);
else
- {
- add = ((((x) & 0x7ff) << 12) | (((x) & 0x07ff0000) >> 15));
- }
+ add = ((((x) & 0x7ff) << 12) | (((x) & 0x07ff0000) >> 15));
/* Get the value from the object file with an appropriate sign.
The expression involving howto->src_mask isolates the upper
can not get the upper bit, but that does not matter since
signed_add needs no adjustment to become negative in that
case. */
-
signed_add = add;
if ((add & (((~ src_mask) >> 1) & src_mask)) != 0)
signed_add -= (((~ src_mask) >> 1) & src_mask) << 1;
+ /* howto->bitpos == 0 */
/* Add the value from the object file, shifted so that it is a
straight number. */
- /* howto->bitpos == 0 */
-
signed_check += signed_add;
- relocation += signed_add;
+ relocation += signed_add;
BFD_ASSERT (howto->complain_on_overflow == complain_overflow_signed);
|| signed_check < reloc_signed_min)
overflow = true;
- /* Put RELOCATION into the correct bits: */
-
+ /* For the BLX(1) instruction remove bit 0 of the adjusted offset.
+ Bit 0 can only be set if the upper insn is at a half-word boundary,
+ since the destination address, an ARM instruction, must always be
+ on a word boundary. The semantics of the BLX (1) instruction,
+ however, are that bit 0 in the offset must always be 0, and the
+ corresponding bit 1 in the target address will be set from bit
+ 1 of the source address. */
+ if ((x & 0x18000000) == 0x08000000)
+ relocation &= ~0x2;
+
+ /* Put the relocation into the correct bits. */
if (bfd_big_endian (input_bfd))
- {
- relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000));
- }
+ relocation = (((relocation & 0xffe) >> 1) | ((relocation << 4) & 0x07ff0000));
else
- {
- relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff));
- }
+ relocation = (((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff));
- /* Add RELOCATION to the correct bits of X: */
+ /* Add the relocation to the correct bits of X. */
x = ((x & ~howto->dst_mask) | relocation);
- /* Put the relocated value back in the object file: */
+ /* Put the relocated value back in the object file. */
bfd_put_32 (input_bfd, x, location);
rstat = overflow ? bfd_reloc_overflow : bfd_reloc_ok;
/* Target vectors. */
CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED, EXTRA_S_FLAGS, TARGET_UNDERSCORE, & TARGET_BIG_SYM)
CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED, EXTRA_S_FLAGS, TARGET_UNDERSCORE, & TARGET_LITTLE_SYM)
-