aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2005-04-15 16:37:47 +0000
committerJulian Brown <julian@codesourcery.com>2005-04-15 16:37:47 +0000
commit33bfe77466aaf8e59a3b8c4d99797ad8c8c646fc (patch)
tree89af961c8b8867fdfbd45aafd6e2aa743b773443 /bfd
parentac559f4a6daae06b15dbcaeaa9c383a91e9e3e41 (diff)
downloadgdb-33bfe77466aaf8e59a3b8c4d99797ad8c8c646fc.zip
gdb-33bfe77466aaf8e59a3b8c4d99797ad8c8c646fc.tar.gz
gdb-33bfe77466aaf8e59a3b8c4d99797ad8c8c646fc.tar.bz2
* bfd/bfd-in.h (bfd_elf32_arm_set_target_relocs): Update prototype.
* bfd/bfd-in2.h: Regenerate. * bfd/elf32-arm.c (elf32_arm_link_hash_table): New field, 'use_blx'. (elf32_arm_link_hash_table_create): Initialise fix_v4bx, use_blx. (bfd_elf32_arm_set_target_relocs): Handle use_blx. (elf32_arm_final_link_relocate): Use Thumb BLX for R_ARM_THM_PC22 relocations if requested to. (allocate_dynrelocs): Don't count size of omitted Thumb stubs based on use_blx rather than symbian_p. (elf32_arm_finish_dynamic_symbol): Don't output Thumb PLT stubs if use_blx is in effect. (elf32_arm_symbian_link_hash_table_create): Enable use_blx by default for SymbianOS. * ld/ld.texinfo: Document --use-blx. * ld/emultempl/armelf.em (use_blx): New variable. (arm_elf_create_output_section_statements): Communicate value of use_blx to bfd. (PARSE_AND_LIST_PROLOGUE): Add OPTION_USE_BLX. (PARSE_AND_LIST_OPTIONS): Add --use-blx option. (PARSE_AND_LIST_ARGS_CASES): Add OPTION_USE_BLX case.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog16
-rw-r--r--bfd/bfd-in.h2
-rw-r--r--bfd/bfd-in2.h2
-rw-r--r--bfd/elf32-arm.c36
4 files changed, 47 insertions, 9 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 35ac02d..2ec4601 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,19 @@
+2004-04-15 Julian Brown <julian@codesourcery.com>
+
+ * bfd-in.h (bfd_elf32_arm_set_target_relocs): Update prototype.
+ * bfd-in2.h: Regenerate.
+ * elf32-arm.c (elf32_arm_link_hash_table): New field, 'use_blx'.
+ (elf32_arm_link_hash_table_create): Initialise fix_v4bx, use_blx.
+ (bfd_elf32_arm_set_target_relocs): Handle use_blx.
+ (elf32_arm_final_link_relocate): Use Thumb BLX for R_ARM_THM_PC22
+ relocations if requested to.
+ (allocate_dynrelocs): Don't count size of omitted Thumb stubs based on
+ use_blx rather than symbian_p.
+ (elf32_arm_finish_dynamic_symbol): Don't output Thumb PLT stubs if
+ use_blx is in effect.
+ (elf32_arm_symbian_link_hash_table_create): Enable use_blx by default
+ for SymbianOS.
+
2005-04-15 Nick Clifton <nickc@redhat.com>
* coffgen.c (coff_print_symbol): Use fprintf_vma to print vma
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index a3dedb5..90e123d9 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -816,7 +816,7 @@ extern bfd_boolean bfd_elf32_arm_process_before_allocation
(bfd *, struct bfd_link_info *, int);
void bfd_elf32_arm_set_target_relocs
- (struct bfd_link_info *, int, char *, int);
+ (struct bfd_link_info *, int, char *, int, int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index bed224d..1e373f2 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -823,7 +823,7 @@ extern bfd_boolean bfd_elf32_arm_process_before_allocation
(bfd *, struct bfd_link_info *, int);
void bfd_elf32_arm_set_target_relocs
- (struct bfd_link_info *, int, char *, int);
+ (struct bfd_link_info *, int, char *, int, int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index a46713d..ef31740 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -1324,6 +1324,9 @@ struct elf32_arm_link_hash_table
/* Nonzero to fix BX instructions for ARMv4 targets. */
int fix_v4bx;
+ /* Nonzero if the ARM/Thumb BLX instructions are available for use. */
+ int use_blx;
+
/* The number of bytes in the initial entry in the PLT. */
bfd_size_type plt_header_size;
@@ -1559,6 +1562,8 @@ elf32_arm_link_hash_table_create (bfd *abfd)
ret->plt_header_size = 20;
ret->plt_entry_size = 12;
#endif
+ ret->fix_v4bx = 0;
+ ret->use_blx = 0;
ret->symbian_p = 0;
ret->use_rel = 1;
ret->sym_sec.abfd = NULL;
@@ -2125,7 +2130,8 @@ void
bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info,
int target1_is_rel,
char * target2_type,
- int fix_v4bx)
+ int fix_v4bx,
+ int use_blx)
{
struct elf32_arm_link_hash_table *globals;
@@ -2144,6 +2150,7 @@ bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info,
target2_type);
}
globals->fix_v4bx = fix_v4bx;
+ globals->use_blx |= use_blx;
}
#endif
@@ -2893,6 +2900,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
bfd_vma check;
bfd_signed_vma signed_check;
+ bfd_boolean thumb_plt_call = FALSE;
/* Need to refetch the addend and squish the two 11 bit pieces
together. */
@@ -2942,8 +2950,19 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
value = (splt->output_section->vma
+ splt->output_offset
+ h->plt.offset);
- /* Target the Thumb stub before the ARM PLT entry. */
- value -= 4;
+ if (globals->use_blx)
+ {
+ /* If the Thumb BLX instruction is available, convert the
+ BL to a BLX instruction to call the ARM-mode PLT entry. */
+ if ((lower_insn & (0x3 << 11)) == 0x3 << 11)
+ {
+ lower_insn = (lower_insn & ~(0x3 << 11)) | 0x1 << 11;
+ thumb_plt_call = TRUE;
+ }
+ }
+ else
+ /* Target the Thumb stub before the ARM PLT entry. */
+ value -= PLT_THUMB_STUB_SIZE;
*unresolved_reloc_p = FALSE;
}
@@ -2967,8 +2986,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
overflow = TRUE;
#ifndef OLD_ARM_ABI
- if (r_type == R_ARM_THM_XPC22
- && ((lower_insn & 0x1800) == 0x0800))
+ if ((r_type == R_ARM_THM_XPC22
+ && ((lower_insn & 0x1800) == 0x0800))
+ || thumb_plt_call)
/* For a BLX instruction, make sure that the relocation is rounded up
to a word boundary. This follows the semantics of the instruction
which specifies that bit 1 of the target address will come from bit
@@ -5059,7 +5079,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
/* If we will insert a Thumb trampoline before this PLT, leave room
for it. */
- if (!htab->symbian_p && eh->plt_thumb_refcount > 0)
+ if (!htab->use_blx && eh->plt_thumb_refcount > 0)
{
h->plt.offset += PLT_THUMB_STUB_SIZE;
s->size += PLT_THUMB_STUB_SIZE;
@@ -5632,7 +5652,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info,
BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
- if (eh->plt_thumb_refcount > 0)
+ if (!htab->use_blx && eh->plt_thumb_refcount > 0)
{
bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[0],
splt->contents + h->plt.offset - 4);
@@ -6505,6 +6525,8 @@ elf32_arm_symbian_link_hash_table_create (bfd *abfd)
/* The PLT entries are each three instructions. */
htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry);
htab->symbian_p = 1;
+ /* Symbian uses armv5t or above, so use_blx is always true. */
+ htab->use_blx = 1;
htab->root.is_relocatable_executable = 1;
}
return ret;