This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Mapping symbols for interworking glue.
- From: Paul Brook <paul at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Tue, 22 May 2007 18:17:51 +0100
- Subject: Mapping symbols for interworking glue.
The attached patch adds mapping symbols for linker generated ARM/Thumb
interworking glue. Due to problems creating multiple symbols with the same
name this uses the same trick as for the PLT.
Tested on arm-none-eabi.
Applied to CVS head.
Paul
2007-05-22 Paul Brook <paul@codesourcery.com>
ld/testsuite/
* ld-arm/arm-pic-veneer.d: Update expected output.
* ld-arm/arm-call.d: Ditto.
bfd/
* elf32-arm.c (output_arch_syminfo): Replace plt_shndx and plt_offset
with sec and sec_shndx.
(elf32_arm_ouput_plt_map_sym): Use them.
(elf32_arm_output_arch_local_syms): Output mapping symbols for
interworking glue.
Index: ld/testsuite/ld-arm/arm-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/arm-pic-veneer.d (revision 171910)
+++ ld/testsuite/ld-arm/arm-pic-veneer.d (working copy)
@@ -14,4 +14,4 @@ Disassembly of section .text:
8008: e59fc004 ldr ip, \[pc, #4\] ; 8014 <__foo_from_arm\+0xc>
800c: e08cc00f add ip, ip, pc
8010: e12fff1c bx ip
- 8014: fffffff1 undefined instruction 0xfffffff1
+ 8014: fffffff1 .word 0xfffffff1
Index: ld/testsuite/ld-arm/arm-call.d
===================================================================
--- ld/testsuite/ld-arm/arm-call.d (revision 171910)
+++ ld/testsuite/ld-arm/arm-call.d (working copy)
@@ -49,8 +49,8 @@ Disassembly of section .text:
0000805c <__t1_from_arm>:
805c: e51ff004 ldr pc, \[pc, #-4\] ; 8060 <__t1_from_arm\+0x4>
- 8060: 00008041 andeq r8, r0, r1, asr #32
+ 8060: 00008041 .word 0x00008041
00008064 <__t2_from_arm>:
8064: e51ff004 ldr pc, \[pc, #-4\] ; 8068 <__t2_from_arm\+0x4>
- 8068: 00008043 andeq r8, r0, r3, asr #32
+ 8068: 00008043 .word 0x00008043
Index: bfd/elf32-arm.c
===================================================================
--- bfd/elf32-arm.c (revision 171910)
+++ bfd/elf32-arm.c (working copy)
@@ -10048,8 +10048,8 @@ typedef struct
{
void *finfo;
struct bfd_link_info *info;
- int plt_shndx;
- bfd_vma plt_offset;
+ asection *sec;
+ int sec_shndx;
bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *);
} output_arch_syminfo;
@@ -10074,12 +10074,14 @@ elf32_arm_ouput_plt_map_sym (output_arch
Elf_Internal_Sym sym;
htab = elf32_arm_hash_table (osi->info);
- sym.st_value = osi->plt_offset + offset;
+ sym.st_value = osi->sec->output_section->vma
+ + osi->sec->output_offset
+ + offset;
sym.st_size = 0;
sym.st_other = 0;
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
- sym.st_shndx = osi->plt_shndx;
- if (!osi->func (osi->finfo, names[type], &sym, htab->splt, NULL))
+ sym.st_shndx = osi->sec_shndx;
+ if (!osi->func (osi->finfo, names[type], &sym, osi->sec, NULL))
return FALSE;
return TRUE;
}
@@ -10163,7 +10165,7 @@ elf32_arm_output_plt_map (struct elf_lin
}
-/* Output mapping symbols for the PLT. */
+/* Output mapping symbols for linker generated sections. */
static bfd_boolean
elf32_arm_output_arch_local_syms (bfd *output_bfd,
@@ -10175,19 +10177,63 @@ elf32_arm_output_arch_local_syms (bfd *o
{
output_arch_syminfo osi;
struct elf32_arm_link_hash_table *htab;
+ bfd_vma offset;
+ bfd_size_type size;
htab = elf32_arm_hash_table (info);
- if (!htab->splt || htab->splt->size == 0)
- return TRUE;
-
check_use_blx(htab);
+
osi.finfo = finfo;
osi.info = info;
osi.func = func;
- osi.plt_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
- htab->splt->output_section);
- osi.plt_offset = htab->splt->output_section->vma;
+
+ /* ARM->Thumb glue. */
+ if (htab->arm_glue_size > 0)
+ {
+ osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
+ ARM2THUMB_GLUE_SECTION_NAME);
+
+ osi.sec_shndx = _bfd_elf_section_from_bfd_section
+ (output_bfd, osi.sec->output_section);
+ if (info->shared || htab->root.is_relocatable_executable
+ || htab->pic_veneer)
+ size = ARM2THUMB_PIC_GLUE_SIZE;
+ else if (htab->use_blx)
+ size = ARM2THUMB_V5_STATIC_GLUE_SIZE;
+ else
+ size = ARM2THUMB_STATIC_GLUE_SIZE;
+ for (offset = 0; offset < htab->arm_glue_size; offset += size)
+ {
+ elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset);
+ elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, offset + size - 4);
+ }
+ }
+
+ /* Thumb->ARM glue. */
+ if (htab->thumb_glue_size > 0)
+ {
+ osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
+ THUMB2ARM_GLUE_SECTION_NAME);
+
+ osi.sec_shndx = _bfd_elf_section_from_bfd_section
+ (output_bfd, osi.sec->output_section);
+ size = THUMB2ARM_GLUE_SIZE;
+
+ for (offset = 0; offset < htab->thumb_glue_size; offset += size)
+ {
+ elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_THUMB, offset);
+ elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset + 4);
+ }
+ }
+
+ /* Finally, output mapping symbols for the PLT. */
+ if (!htab->splt || htab->splt->size == 0)
+ return TRUE;
+
+ osi.sec_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
+ htab->splt->output_section);
+ osi.sec = htab->splt;
/* Output mapping symbols for the plt header. SymbianOS does not have a
plt header. */
if (htab->vxworks_p)