From 34e77a920a469734b88c8efc79be94be955b1029 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 14 Mar 2011 16:04:16 +0000 Subject: include/elf/ * arm.h (R_ARM_IRELATIVE): New relocation. bfd/ * reloc.c (BFD_RELOC_ARM_IRELATIVE): New relocation. * bfd-in2.h: Regenerate. * elf32-arm.c (elf32_arm_howto_table_2): Rename existing definition to elf32_arm_howto_table_3 and replace with a single R_ARM_IRELATIVE entry. (elf32_arm_howto_from_type): Update accordingly. (elf32_arm_reloc_map): Map BFD_RELOC_ARM_IRELATIVE to R_ARM_IRELATIVE. (elf32_arm_reloc_name_lookup): Handle elf32_arm_howto_table_3. (arm_plt_info): New structure, split out from elf32_arm_link_hash_entry with an extra noncall_refcount field. (arm_local_iplt_info): New structure. (elf_arm_obj_tdata): Add local_iplt. (elf32_arm_local_iplt): New accessor macro. (elf32_arm_link_hash_entry): Replace plt_thumb_refcount, plt_maybe_thumb_refcount and plt_got_offset with an arm_plt_info. Change tls_type to a bitfield and add is_iplt. (elf32_arm_link_hash_newfunc): Update accordingly. (elf32_arm_allocate_local_sym_info): New function. (elf32_arm_create_local_iplt): Likewise. (elf32_arm_get_plt_info): Likewise. (elf32_arm_plt_needs_thumb_stub_p): Likewise. (elf32_arm_get_local_dynreloc_list): Likewise. (create_ifunc_sections): Likewise. (elf32_arm_copy_indirect_symbol): Update after the changes to elf32_arm_link_hash_entry. Assert the is_iplt has not yet been set. (arm_type_of_stub): Add an st_type argument. Use elf32_arm_get_plt_info to get PLT information. Assert that all STT_GNU_IFUNC references are turned into PLT references. (arm_build_one_stub): Pass the symbol type to elf32_arm_final_link_relocate. (elf32_arm_size_stubs): Pass the symbol type to arm_type_of_stub. (elf32_arm_allocate_irelocs): New function. (elf32_arm_add_dynreloc): In static objects, use .rel.iplt for all R_ARM_IRELATIVE. (elf32_arm_allocate_plt_entry): New function. (elf32_arm_populate_plt_entry): Likewise. (elf32_arm_final_link_relocate): Add an st_type parameter. Set srelgot to null for static objects. Use separate variables to record which st_value and st_type should be used when generating a dynamic relocation. Use elf32_arm_get_plt_info to find the symbol's PLT information, setting has_iplt_entry, splt, plt_offset and gotplt_offset accordingly. Check whether STT_GNU_IFUNC symbols should resolve to an .iplt entry, and change the relocation target accordingly. Broaden assert to include .iplts. Don't set sreloc for static relocations. Assert that we only generate dynamic R_ARM_RELATIVE relocations for R_ARM_ABS32 and R_ARM_ABS32_NOI. Generate R_ARM_IRELATIVE relocations instead of R_ARM_RELATIVE relocations if the target is an STT_GNU_IFUNC symbol. Pass the symbol type to arm_type_of_stub. Conditionally resolve GOT references to the .igot.plt entry. (elf32_arm_relocate_section): Update the call to elf32_arm_final_link_relocate. (elf32_arm_gc_sweep_hook): Use elf32_arm_get_plt_info to get PLT information. Treat R_ARM_REL32 and R_ARM_REL32_NOI as call relocations in shared libraries and relocatable executables. Count non-call PLT references. Use elf32_arm_get_local_dynreloc_list to get the list of dynamic relocations for a local symbol. (elf32_arm_check_relocs): Always create ifunc sections. Set isym at the same time as setting h. Use elf32_arm_allocate_local_sym_info to allocate local symbol information. Treat R_ARM_REL32 and R_ARM_REL32_NOI as call relocations in shared libraries and relocatable executables. Record PLT information for local STT_GNU_IFUNC functions as well as global functions. Count non-call PLT references. Use elf32_arm_get_local_dynreloc_list to get the list of dynamic relocations for a local symbol. (elf32_arm_adjust_dynamic_symbol): Handle STT_GNU_IFUNC symbols. Don't remove STT_GNU_IFUNC PLTs unless all references have been removed. Update after the changes to elf32_arm_link_hash_entry. (allocate_dynrelocs_for_symbol): Decide whether STT_GNU_IFUNC PLT entries should live in .plt or .iplt. Check whether the .igot.plt and .got entries can be combined. Use elf32_arm_allocate_plt_entry to allocate .plt and .(i)got.plt entries. Detect which .got entries will need R_ARM_IRELATIVE relocations and use elf32_arm_allocate_irelocs to allocate them. Likewise other non-.got dynamic relocations. (elf32_arm_size_dynamic_sections): Allocate .iplt, .igot.plt and dynamic relocations for local STT_GNU_IFUNC symbols. Check whether the .igot.plt and .got entries can be combined. Detect which .got entries will need R_ARM_IRELATIVE relocations and use elf32_arm_allocate_irelocs to allocate them. Use stashed section pointers intead of strcmp checks. Handle iplt and igotplt. (elf32_arm_finish_dynamic_symbol): Use elf32_arm_populate_plt_entry to fill in .plt, .got.plt and .rel(a).plt entries. Point STT_GNU_IFUNC symbols at an .iplt entry if non-call relocations resolve to it. (elf32_arm_output_plt_map_1): New function, split out from elf32_arm_output_plt_map. Handle .iplt entries. Use elf32_arm_plt_needs_thumb_stub_p. (elf32_arm_output_plt_map): Call it. (elf32_arm_output_arch_local_syms): Add mapping symbols for local .iplt entries. (elf32_arm_swap_symbol_in): Handle Thumb STT_GNU_IFUNC symbols. (elf32_arm_swap_symbol_out): Likewise. (elf32_arm_add_symbol_hook): New function. (elf_backend_add_symbol_hook): Define for all targets. opcodes/ * arm-dis.c (get_sym_code_type): Treat STT_GNU_IFUNCs as code. gas/ * config/tc-arm.c (md_pcrel_from_section): Use S_FORCE_RELOC to determine whether a relocation is needed. (md_apply_fix, arm_apply_sym_value): Likewise. ld/testsuite/ * ld-arm/ifunc-1.s, ld-arm/ifunc-1.dd, ld-arm/ifunc-1.gd, ld-arm/ifunc-1.rd, ld-arm/ifunc-2.s, ld-arm/ifunc-2.dd, ld-arm/ifunc-2.gd, ld-arm/ifunc-2.rd, ld-arm/ifunc-3.s, ld-arm/ifunc-3.dd, ld-arm/ifunc-3.gd, ld-arm/ifunc-3.rd, ld-arm/ifunc-4.s, ld-arm/ifunc-4.dd, ld-arm/ifunc-4.gd, ld-arm/ifunc-4.rd, ld-arm/ifunc-5.s, ld-arm/ifunc-5.dd, ld-arm/ifunc-5.gd, ld-arm/ifunc-5.rd, ld-arm/ifunc-6.s, ld-arm/ifunc-6.dd, ld-arm/ifunc-6.gd, ld-arm/ifunc-6.rd, ld-arm/ifunc-7.s, ld-arm/ifunc-7.dd, ld-arm/ifunc-7.gd, ld-arm/ifunc-7.rd, ld-arm/ifunc-8.s, ld-arm/ifunc-8.dd, ld-arm/ifunc-8.gd, ld-arm/ifunc-8.rd, ld-arm/ifunc-9.s, ld-arm/ifunc-9.dd, ld-arm/ifunc-9.gd, ld-arm/ifunc-9.rd, ld-arm/ifunc-10.s, ld-arm/ifunc-10.dd, ld-arm/ifunc-10.gd, ld-arm/ifunc-10.rd, ld-arm/ifunc-11.s, ld-arm/ifunc-11.dd, ld-arm/ifunc-11.gd, ld-arm/ifunc-11.rd, ld-arm/ifunc-12.s, ld-arm/ifunc-12.dd, ld-arm/ifunc-12.gd, ld-arm/ifunc-12.rd, ld-arm/ifunc-13.s, ld-arm/ifunc-13.dd, ld-arm/ifunc-13.gd, ld-arm/ifunc-13.rd, ld-arm/ifunc-14.s, ld-arm/ifunc-14.dd, ld-arm/ifunc-14.gd, ld-arm/ifunc-14.rd, ld-arm/ifunc-15.s, ld-arm/ifunc-15.dd, ld-arm/ifunc-15.gd, ld-arm/ifunc-15.rd, ld-arm/ifunc-16.s, ld-arm/ifunc-16.dd, ld-arm/ifunc-16.gd, ld-arm/ifunc-16.rd, ld-arm/ifunc-dynamic.ld, ld-arm/ifunc-static.ld: New tests. * ld-arm/farcall-group.d, ld-arm/farcall-group-size2.d, ld-arm/farcall-mixed-lib-v4t.d, ld-arm/farcall-mixed-lib.d: Update for new stub hashes. * ld-arm/arm-elf.exp: Run them. --- ld/testsuite/ld-arm/ifunc-6.dd | 175 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 ld/testsuite/ld-arm/ifunc-6.dd (limited to 'ld/testsuite/ld-arm/ifunc-6.dd') diff --git a/ld/testsuite/ld-arm/ifunc-6.dd b/ld/testsuite/ld-arm/ifunc-6.dd new file mode 100644 index 0000000..6715dce --- /dev/null +++ b/ld/testsuite/ld-arm/ifunc-6.dd @@ -0,0 +1,175 @@ + +.* + + +Disassembly of section \.iplt: + +00009000 <\.iplt>: +#------------------------------------------------------------------------------ +#------ thumb entry to f3's .iplt entry +#------------------------------------------------------------------------------ + 9000: 4778 bx pc + 9002: 46c0 nop ; \(mov r8, r8\) +#------------------------------------------------------------------------------ +#------ f3's .iplt entry +#------------------------------------------------------------------------------ + 9004: e28fc600 add ip, pc, #0 + 9008: e28cca08 add ip, ip, #32768 ; 0x8000 + 900c: e5bcf000 ldr pc, \[ip\]! +#------------------------------------------------------------------------------ +#------ f2's .iplt entry +#------------------------------------------------------------------------------ + 9010: e28fc600 add ip, pc, #0 + 9014: e28cca07 add ip, ip, #28672 ; 0x7000 + 9018: e5bcfff8 ldr pc, \[ip, #4088\]! ; 0xff8 +#------------------------------------------------------------------------------ +#------ thumb entry to f4's .iplt entry +#------------------------------------------------------------------------------ + 901c: 4778 bx pc + 901e: 46c0 nop ; \(mov r8, r8\) +#------------------------------------------------------------------------------ +#------ f4's .iplt entry +#------------------------------------------------------------------------------ + 9020: e28fc600 add ip, pc, #0 + 9024: e28cca07 add ip, ip, #28672 ; 0x7000 + 9028: e5bcffec ldr pc, \[ip, #4076\]! ; 0xfec +#------------------------------------------------------------------------------ +#------ f1's .iplt entry +#------------------------------------------------------------------------------ + 902c: e28fc600 add ip, pc, #0 + 9030: e28cca07 add ip, ip, #28672 ; 0x7000 + 9034: e5bcffe4 ldr pc, \[ip, #4068\]! ; 0xfe4 + +Disassembly of section \.text: + +0000a000 : + a000: e1a0f00e mov pc, lr + +0000a004 : + a004: 46f7 mov pc, lr + \.\.\. + +0000a008 : + a008: e1a0f00e mov pc, lr + +0000a00c : + a00c: 46f7 mov pc, lr + \.\.\. + +0000a010 <_start>: + a010: eb0017fa bl 10000 + a014: ea0017f9 b 10000 + a018: 0a0017f8 beq 10000 + a01c: e59f4000 ldr r4, \[pc, #0\] ; a024 <_start\+0x14> + a020: e59f4000 ldr r4, \[pc, #0\] ; a028 <_start\+0x18> +#------------------------------------------------------------------------------ +#------ .got offset for foo +#------------------------------------------------------------------------------ + a024: 00000020 \.word 0x00000020 +#------------------------------------------------------------------------------ +#------ PC-relative offset of .got entry for foo +#------------------------------------------------------------------------------ + a028: 00006ff4 \.word 0x00006ff4 +#------------------------------------------------------------------------------ +#------ f1's .iplt entry +#------------------------------------------------------------------------------ + a02c: ebfffbfe bl 902c <__irel_end\+0x100c> +#------------------------------------------------------------------------------ +#------ f1's .iplt entry +#------------------------------------------------------------------------------ + a030: eafffbfd b 902c <__irel_end\+0x100c> +#------------------------------------------------------------------------------ +#------ f1's .iplt entry +#------------------------------------------------------------------------------ + a034: 0afffbfc beq 902c <__irel_end\+0x100c> + a038: e59f4000 ldr r4, \[pc, #0\] ; a040 <_start\+0x30> + a03c: e59f4000 ldr r4, \[pc, #0\] ; a044 <_start\+0x34> +#------------------------------------------------------------------------------ +#------ GP-relative offset of f1's .igot.plt entry +#------------------------------------------------------------------------------ + a040: 00000018 \.word 0x00000018 +#------------------------------------------------------------------------------ +#------ PC-relative offset of f1's .igot.plt entry +#------------------------------------------------------------------------------ + a044: 00006fd4 \.word 0x00006fd4 +#------------------------------------------------------------------------------ +#------ f2's .iplt entry +#------------------------------------------------------------------------------ + a048: ebfffbf0 bl 9010 <__irel_end\+0xff0> +#------------------------------------------------------------------------------ +#------ f2's .iplt entry +#------------------------------------------------------------------------------ + a04c: eafffbef b 9010 <__irel_end\+0xff0> +#------------------------------------------------------------------------------ +#------ f2's .iplt entry +#------------------------------------------------------------------------------ + a050: 0afffbee beq 9010 <__irel_end\+0xff0> + a054: e59f4000 ldr r4, \[pc, #0\] ; a05c <_start\+0x4c> + a058: e59f4000 ldr r4, \[pc, #0\] ; a060 <_start\+0x50> +#------------------------------------------------------------------------------ +#------ GP-relative offset of f2's .igot.plt entry +#------------------------------------------------------------------------------ + a05c: 00000010 \.word 0x00000010 +#------------------------------------------------------------------------------ +#------ PC-relative offset of f2's .igot.plt entry +#------------------------------------------------------------------------------ + a060: 00006fb0 \.word 0x00006fb0 + +0000a064 <_thumb>: + a064: f005 ffcc bl 10000 + a068: f005 bfca b\.w 10000 + a06c: f005 87c8 beq\.w 10000 + a070: 4c00 ldr r4, \[pc, #0\] ; \(a074 <_thumb\+0x10>\) + a072: 4c01 ldr r4, \[pc, #4\] ; \(a078 <_thumb\+0x14>\) +#------------------------------------------------------------------------------ +#------ .got offset for foo +#------------------------------------------------------------------------------ + a074: 00000020 \.word 0x00000020 +#------------------------------------------------------------------------------ +#------ PC-relative offset of .got entry for foo +#------------------------------------------------------------------------------ + a078: 00006fa4 \.word 0x00006fa4 +#------------------------------------------------------------------------------ +#------ f3's .iplt entry +#------------------------------------------------------------------------------ + a07c: f7fe efc2 blx 9004 <__irel_end\+0xfe4> +#------------------------------------------------------------------------------ +#------ thumb entry to f3's .iplt entry +#------------------------------------------------------------------------------ + a080: f7fe bfbe b\.w 9000 <__irel_end\+0xfe0> +#------------------------------------------------------------------------------ +#------ thumb entry to f3's .iplt entry +#------------------------------------------------------------------------------ + a084: f43e afbc beq\.w 9000 <__irel_end\+0xfe0> + a088: 4c00 ldr r4, \[pc, #0\] ; \(a08c <_thumb\+0x28>\) + a08a: 4c01 ldr r4, \[pc, #4\] ; \(a090 <_thumb\+0x2c>\) +#------------------------------------------------------------------------------ +#------ GP-relative offset of f3's .igot.plt entry +#------------------------------------------------------------------------------ + a08c: 0000000c \.word 0x0000000c +#------------------------------------------------------------------------------ +#------ PC-relative offset of f3's .igot.plt entry +#------------------------------------------------------------------------------ + a090: 00006f7c \.word 0x00006f7c +#------------------------------------------------------------------------------ +#------ f4's .iplt entry +#------------------------------------------------------------------------------ + a094: f7fe efc4 blx 9020 <__irel_end\+0x1000> +#------------------------------------------------------------------------------ +#------ thumb entry to f4's .iplt entry +#------------------------------------------------------------------------------ + a098: f7fe bfc0 b\.w 901c <__irel_end\+0xffc> +#------------------------------------------------------------------------------ +#------ thumb entry to f4's .iplt entry +#------------------------------------------------------------------------------ + a09c: f43e afbe beq\.w 901c <__irel_end\+0xffc> + a0a0: 4c00 ldr r4, \[pc, #0\] ; \(a0a4 <_thumb\+0x40>\) + a0a2: 4c01 ldr r4, \[pc, #4\] ; \(a0a8 <_thumb\+0x44>\) +#------------------------------------------------------------------------------ +#------ GP-relative offset of f4's .igot.plt entry +#------------------------------------------------------------------------------ + a0a4: 00000014 \.word 0x00000014 +#------------------------------------------------------------------------------ +#------ PC-relative offset of f4's .igot.plt entry +#------------------------------------------------------------------------------ + a0a8: 00006f6c \.word 0x00006f6c -- cgit v1.1