* elf32-arm.c (arm_type_of_stub): Ignore STT_SECTION symbols.
(elf32_arm_stub_add_mapping_symbol): Remove.
(elf32_arm_add_stub): Don't generate mapping symbols. Change
prototype.
(elf32_arm_size_stubs): Use new elf32_arm_add_stub
prototype. Don't generate thumb to arm glue for calls.
(arm_map_one_stub): Define.
(elf32_arm_output_arch_local_syms): Generate mapping symbols for
long calls stubs.
ld/testsuite/
* ld-arm/farcall-arm-arm.s: Force function type on 'bar'.
* ld-arm/farcall-thumb-arm.s: Likewise.
* ld-arm/farcall-thumb-arm-blx.d: Fix encoding.
* ld-arm/farcall-thumb-arm.d: Likewise.
* ld-arm/farcall-thumb-arm-blx-pic-veneer.d: Likewise.
* ld-arm/arm-elf.exp (armelftests): Add farcall-mix, farcall-mix2,
farcall-group-default, farcall-group-size2, farcall-section Ignore
gas warnings in farcall-thumb-arm, farcall-thumb-arm-blx,
farcall-thumb-arm-blx-pic-veneer.
+2008-05-22 Christophe Lyon <christophe.lyon@st.com>
+
+ * elf32-arm.c (arm_type_of_stub): Ignore STT_SECTION symbols.
+ (elf32_arm_stub_add_mapping_symbol): Remove.
+ (elf32_arm_add_stub): Don't generate mapping symbols. Change
+ prototype.
+ (elf32_arm_size_stubs): Use new elf32_arm_add_stub
+ prototype. Don't generate thumb to arm glue for calls.
+ (arm_map_one_stub): Define.
+ (elf32_arm_output_arch_local_syms): Generate mapping symbols for
+ long calls stubs.
+
2008-05-21 Maxim Kuvyrkov <maxim@codesourcery.com>
Add multi-GOT support for m68k.
symbols with Arm stubs. */
struct elf_link_hash_entry *export_glue;
- /* A pointer to the most recently used stub hash entry against this
+ /* A pointer to the most recently used stub hash entry against this
symbol. */
- struct elf32_arm_stub_hash_entry *stub_cache;
+ struct elf32_arm_stub_hash_entry *stub_cache;
};
/* Traverse an arm ELF linker hash table. */
int thumb_only;
enum elf32_arm_stub_type stub_type = arm_stub_none;
+ /* We don't know the actual type of destination in case it is of
+ type STT_SECTION: give up */
+ if (st_type == STT_SECTION)
+ return stub_type;
+
globals = elf32_arm_hash_table (info);
thumb_only = using_thumb_only (globals);
return stub_entry;
}
-static void elf32_arm_stub_add_mapping_symbol (struct bfd_link_info * link_info,
- asection *stub_sec,
- char* name,
- bfd_vma val)
-{
- struct bfd_link_hash_entry * bh = NULL;
- struct elf_link_hash_entry * myh;
-
- _bfd_generic_link_add_one_symbol (link_info,
- stub_sec->owner, name,
- BSF_LOCAL, stub_sec, stub_sec->size + val,
- NULL, TRUE, FALSE, &bh);
-
- myh = (struct elf_link_hash_entry *) bh;
- myh->type = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
- myh->forced_local = 1;
-}
-
/* Add a new stub entry to the stub hash. Not all fields of the new
stub entry are initialised. */
static struct elf32_arm_stub_hash_entry *
elf32_arm_add_stub (const char *stub_name,
asection *section,
- struct elf32_arm_link_hash_table *htab,
- struct bfd_link_info * link_info,
- enum elf32_arm_stub_type stub_type)
+ struct elf32_arm_link_hash_table *htab)
{
asection *link_sec;
asection *stub_sec;
stub_entry->stub_offset = 0;
stub_entry->id_sec = link_sec;
- switch (stub_type)
- {
- case arm_stub_long_branch:
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$a", 0);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$d", 4);
- break;
- case arm_thumb_v4t_stub_long_branch:
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$a", 0);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$d", 8);
- break;
- case arm_thumb_thumb_stub_long_branch:
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$t", 0);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$d", 12);
- break;
- case arm_thumb_arm_v4t_stub_long_branch:
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$t", 0);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$a", 8);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$d", 16);
- break;
- case arm_stub_pic_long_branch:
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$a", 0);
- elf32_arm_stub_add_mapping_symbol (link_info, stub_sec, "$d", 8);
- break;
- default:
- BFD_FAIL ();
- }
-
return stub_entry;
}
continue;
}
- stub_entry = elf32_arm_add_stub (stub_name, section, htab, info, stub_type);
+ stub_entry = elf32_arm_add_stub (stub_name, section, htab);
if (stub_entry == NULL)
{
free (stub_name);
/* Convert BL to BLX. */
lower_insn = (lower_insn & ~0x1000) | 0x0800;
}
- else if (elf32_thumb_to_arm_stub
+ else if (r_type != R_ARM_THM_CALL) {
+ if (elf32_thumb_to_arm_stub
(info, sym_name, input_bfd, output_bfd, input_section,
hit_data, sym_sec, rel->r_offset, signed_addend, value,
error_message))
else
return bfd_reloc_dangerous;
}
+ }
else if (sym_flags == STT_ARM_TFUNC && globals->use_blx
&& r_type == R_ARM_THM_CALL)
{
}
+static bfd_boolean
+arm_map_one_stub (struct bfd_hash_entry *gen_entry,
+ PTR in_arg)
+{
+ struct elf32_arm_stub_hash_entry *stub_entry;
+ struct bfd_link_info *info;
+ struct elf32_arm_link_hash_table *htab;
+ asection *stub_sec;
+ bfd_vma addr;
+
+ /* Massage our args to the form they really have. */
+ stub_entry = (struct elf32_arm_stub_hash_entry *) gen_entry;
+
+ output_arch_syminfo *osi = (output_arch_syminfo *) in_arg;
+ info = osi->info;
+
+ htab = elf32_arm_hash_table (info);
+ stub_sec = stub_entry->stub_sec;
+
+ /* Ensure this stub is attached to the current section being
+ processed */
+ if (stub_sec != osi->sec)
+ return TRUE;
+
+ addr = (bfd_vma)stub_entry->stub_offset;
+
+ switch(stub_entry->stub_type) {
+ case arm_stub_long_branch:
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 4))
+ return FALSE;
+ break;
+ case arm_thumb_v4t_stub_long_branch:
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8))
+ return FALSE;
+ break;
+ case arm_thumb_thumb_stub_long_branch:
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 12))
+ return FALSE;
+ break;
+ case arm_thumb_arm_v4t_stub_long_branch:
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr + 8))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 16))
+ return FALSE;
+ break;
+ case arm_stub_pic_long_branch:
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+ return FALSE;
+ if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8))
+ return FALSE;
+ break;
+ default:
+ BFD_FAIL ();
+ }
+
+ return TRUE;
+}
+
/* Output mapping symbols for linker generated sections. */
static bfd_boolean
elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0);
}
+ /* Long calls stubs. */
+ if (htab->stub_bfd && htab->stub_bfd->sections) {
+ asection* stub_sec;
+ for (stub_sec = htab->stub_bfd->sections;
+ stub_sec != NULL;
+ stub_sec = stub_sec->next) {
+
+ /* Ignore non-stub sections */
+ if (!strstr(stub_sec->name, STUB_SUFFIX))
+ continue;
+
+ osi.sec = stub_sec;
+
+ osi.sec_shndx = _bfd_elf_section_from_bfd_section
+ (output_bfd, osi.sec->output_section);
+
+ bfd_hash_traverse (&htab->stub_hash_table, arm_map_one_stub, &osi);
+ }
+ }
+
/* Finally, output mapping symbols for the PLT. */
if (!htab->splt || htab->splt->size == 0)
return TRUE;
+2008-05-22 Christophe Lyon <christophe.lyon@st.com>
+
+ * ld-arm/farcall-arm-arm.s: Force function type on 'bar'.
+ * ld-arm/farcall-thumb-arm.s: Likewise.
+ * ld-arm/farcall-thumb-arm-blx.d: Fix encoding.
+ * ld-arm/farcall-thumb-arm.d: Likewise.
+ * ld-arm/farcall-thumb-arm-blx-pic-veneer.d: Likewise.
+ * ld-arm/arm-elf.exp (armelftests): Add farcall-mix, farcall-mix2,
+ farcall-group-default, farcall-group-size2, farcall-section Ignore
+ gas warnings in farcall-thumb-arm, farcall-thumb-arm-blx,
+ farcall-thumb-arm-blx-pic-veneer.
+
2008-05-21 Maxim Kuvyrkov <maxim@codesourcery.com>
* ld-m68k/got-12.s: New file.
{preempt-app.s}
{{readelf -Ds preempt-app.sym}}
"preempt-app"}
- {"jump19" "-static -T arm.ld" "" {jump19.s}
- {{objdump -dr jump19.d}}
- "jump19"}
- {"callweak" "-static -T arm.ld" "" {callweak.s}
- {{objdump -dr callweak.d}}
- "callweak"}
+ {"jump19" "-static -T arm.ld" "" {jump19.s}
+ {{objdump -dr jump19.d}}
+ "jump19"}
+ {"callweak" "-static -T arm.ld" "" {callweak.s}
+ {{objdump -dr callweak.d}}
+ "callweak"}
- {"ARMv4 interworking" "-static -T arm.ld --fix-v4bx-interworking" "--fix-v4bx -meabi=4" {armv4-bx.s}
- {{objdump -d armv4-bx.d}}
- "armv4-bx"}
- {"MOVW/MOVT and merged sections" "-T arm.ld" "" {movw-merge.s}
- {{objdump -dw movw-merge.d}}
- "movw-merge"}
- {"MOVW/MOVT against shared libraries" "tmpdir/arm-lib.so" "" {arm-app-movw.s}
- {{objdump -Rw arm-app.r}}
- "arm-app-movw"}
- {"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x40100c" "" {thumb2-bl-as-thumb1-bad.s}
- {{objdump -d thumb2-bl-as-thumb1-bad.d}}
- "thumb2-bl-as-thumb1-bad"}
- {"Thumb-2 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s}
- {{objdump -d thumb2-bl-bad.d}}
- "thumb2-bl-bad"}
+ {"ARMv4 interworking" "-static -T arm.ld --fix-v4bx-interworking" "--fix-v4bx -meabi=4" {armv4-bx.s}
+ {{objdump -d armv4-bx.d}}
+ "armv4-bx"}
+ {"MOVW/MOVT and merged sections" "-T arm.ld" "" {movw-merge.s}
+ {{objdump -dw movw-merge.d}}
+ "movw-merge"}
+ {"MOVW/MOVT against shared libraries" "tmpdir/arm-lib.so" "" {arm-app-movw.s}
+ {{objdump -Rw arm-app.r}}
+ "arm-app-movw"}
+ {"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x40100c" "" {thumb2-bl-as-thumb1-bad.s}
+ {{objdump -d thumb2-bl-as-thumb1-bad.d}}
+ "thumb2-bl-as-thumb1-bad"}
+ {"Thumb-2 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s}
+ {{objdump -d thumb2-bl-bad.d}}
+ "thumb2-bl-bad"}
- {"ARM-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001020" "" {farcall-arm-arm.s}
- {{objdump -d farcall-arm-arm.d}}
- "farcall-arm-arm"}
- {"ARM-ARM farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001020 --pic-veneer" "" {farcall-arm-arm.s}
- {{objdump -d farcall-arm-arm-pic-veneer.d}}
- "farcall-arm-arm-pic-veneer"}
- {"ARM-ARM farcall (BE8)" "-Ttext 0x1000 --section-start .foo=0x2001020 -EB --be8" "-EB" {farcall-arm-arm.s}
- {{objdump -d farcall-arm-arm-be8.d}}
- "farcall-arm-arm-be8"}
+ {"ARM-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001020" "" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm.d}}
+ "farcall-arm-arm"}
+ {"ARM-ARM farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001020 --pic-veneer" "" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm-pic-veneer.d}}
+ "farcall-arm-arm-pic-veneer"}
+ {"ARM-ARM farcall (BE8)" "-Ttext 0x1000 --section-start .foo=0x2001020 -EB --be8" "-EB" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm-be8.d}}
+ "farcall-arm-arm-be8"}
- {"ARM-Thumb farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-arm-thumb.s}
- {{objdump -d farcall-arm-thumb.d}}
- "farcall-arm-thumb"}
- {"ARM-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-arm-thumb.s}
- {{objdump -d farcall-arm-thumb-blx.d}}
- "farcall-arm-thumb-blx"}
- {"ARM-Thumb farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "" {farcall-arm-thumb.s}
- {{objdump -d farcall-arm-thumb-pic-veneer.d}}
- "farcall-arm-thumb-pic-veneer"}
- {"ARM-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-arm-thumb.s}
- {{objdump -d farcall-arm-thumb-blx-pic-veneer.d}}
- "farcall-arm-thumb-blx-pic-veneer"}
+ {"ARM-Thumb farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb.d}}
+ "farcall-arm-thumb"}
+ {"ARM-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-blx.d}}
+ "farcall-arm-thumb-blx"}
+ {"ARM-Thumb farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-pic-veneer.d}}
+ "farcall-arm-thumb-pic-veneer"}
+ {"ARM-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-blx-pic-veneer.d}}
+ "farcall-arm-thumb-blx-pic-veneer"}
- {"Thumb-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-thumb-thumb.s}
- {{objdump -d farcall-thumb-thumb-blx.d}}
- "farcall-thumb-thumb-blx"}
- {"Thumb-Thumb farcall M profile" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv7m" {farcall-thumb-thumb.s}
- {{objdump -d farcall-thumb-thumb-m.d}}
- "farcall-thumb-thumb-m"}
- {"Thumb-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-thumb-thumb.s}
- {{objdump -d farcall-thumb-thumb-blx-pic-veneer.d}}
- "farcall-thumb-thumb-blx-pic-veneer"}
+ {"Thumb-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-blx.d}}
+ "farcall-thumb-thumb-blx"}
+ {"Thumb-Thumb farcall M profile" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv7m" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-m.d}}
+ "farcall-thumb-thumb-m"}
+ {"Thumb-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-blx-pic-veneer.d}}
+ "farcall-thumb-thumb-blx-pic-veneer"}
- {"Thumb-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-thumb-arm.s}
- {{objdump -d farcall-thumb-arm.d}}
- "farcall-thumb-arm"}
- {"Thumb-ARM farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-thumb-arm.s}
- {{objdump -d farcall-thumb-arm-blx.d}}
- "farcall-thumb-arm-blx"}
- {"Thumb-ARM farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-thumb-arm.s}
- {{objdump -d farcall-thumb-arm-blx-pic-veneer.d}}
- "farcall-thumb-arm-blx-pic-veneer"}
+ {"Thumb-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "-W" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm.d}}
+ "farcall-thumb-arm"}
+ {"Thumb-ARM farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-W -march=armv5t" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm-blx.d}}
+ "farcall-thumb-arm-blx"}
+ {"Thumb-ARM farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-W -march=armv5t" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm-blx-pic-veneer.d}}
+ "farcall-thumb-arm-blx-pic-veneer"}
+
+ {"Multiple farcalls" "-Ttext 0x1000 --section-start .foo=0x2002020" "" {farcall-mix.s}
+ {{objdump -d farcall-mix.d}}
+ "farcall-mix"}
+ {"Multiple farcalls from several sections" "-Ttext 0x1000 --section-start .mytext=0x2000 --section-start .foo=0x2003020" "" {farcall-mix2.s}
+ {{objdump -d farcall-mix2.d}}
+ "farcall-mix2"}
+
+ {"Default group size" "-Ttext 0x1000 --section-start .foo=0x2003020" "" {farcall-group.s farcall-group2.s}
+ {{objdump -d farcall-group.d}}
+ "farcall-group-default"}
+ {"Group size=2" "-Ttext 0x1000 --section-start .foo=0x2003020 --stub-group-size=2" "" {farcall-group.s farcall-group2.s}
+ {{objdump -d farcall-group-size2.d}}
+ "farcall-group-size2"}
}
run_ld_link_tests $armelftests
run_dump_test "farcall-thumb-thumb-pic-veneer"
run_dump_test "farcall-thumb-thumb-m-pic-veneer"
run_dump_test "farcall-thumb-arm-pic-veneer"
+run_dump_test "farcall-section"
# Exclude non-ARM-EABI targets.
.* <.plt>:
.*: e52de004 push {lr} ; \(str lr, \[sp, #-4\]!\)
- .*: e59fe004 ldr lr, \[pc, #4\] ; .* <lib_func1-0x1c>
+ .*: e59fe004 ldr lr, \[pc, #4\] ; .* <lib_func1-0x1.>
.*: e08fe00e add lr, pc, lr
.*: e5bef008 ldr pc, \[lr, #8\]!
.*: .*
.section .foo, "xa"
+ .type bar, %function
bar:
bx lr
Disassembly of section .foo:
02001014 <bar>:
- 2001014: 4770 bx lr
+ 2001014: e12fff1e bx lr
Disassembly of section .foo:
02001014 <bar>:
- 2001014: 4770 bx lr
+ 2001014: e12fff1e bx lr
Disassembly of section .foo:
02001014 <bar>:
- 2001014: 4770 bx lr
+ 2001014: e12fff1e bx lr
.section .foo, "xa"
+ .arm
+ .type bar, %function
bar:
bx lr