binutils-gdb/ld/testsuite/ld-arm/cmse-veneers.s

108 lines
2.5 KiB
ArmAsm
Raw Normal View History

2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com> bfd/ * elf32-arm.c (CMSE_PREFIX): Define macro. (elf32_arm_stub_cmse_branch_thumb_only): Define stub sequence. (cmse_branch_thumb_only): Declare stub. (struct elf32_arm_link_hash_table): Define cmse_stub_sec field. (elf32_arm_get_plt_info): Add globals parameter. Use it to return FALSE if there is no PLT. (arm_type_of_stub): Adapt to new elf32_arm_get_plt_info signature. (elf32_arm_final_link_relocate): Likewise. (elf32_arm_gc_sweep_hook): Likewise. (elf32_arm_gc_mark_extra_sections): Mark sections holding ARMv8-M secure entry functions. (arm_stub_is_thumb): Add case for arm_stub_cmse_branch_thumb_only. (arm_dedicated_stub_output_section_required): Change to a switch case and add a case for arm_stub_cmse_branch_thumb_only. (arm_dedicated_stub_output_section_required_alignment): Likewise. (arm_stub_dedicated_output_section_name): Likewise. (arm_stub_dedicated_input_section_ptr): Likewise and remove ATTRIBUTE_UNUSED for htab parameter. (arm_stub_required_alignment): Likewise. (arm_stub_sym_claimed): Likewise. (arm_dedicated_stub_section_padding): Likewise. (cmse_scan): New function. (elf32_arm_size_stubs): Call cmse_scan for ARM M profile targets. Set stub_changed to TRUE if such veneers were created. (elf32_arm_swap_symbol_in): Add detection code for CMSE special symbols. include/ * arm.h (ARM_GET_SYM_CMSE_SPCL): Define macro. (ARM_SET_SYM_CMSE_SPCL): Likewise. ld/ * ld.texinfo (Placement of SG veneers): New concept entry. * testsuite/ld-arm/arm-elf.exp (Secure gateway veneers: no .gnu.sgstubs section): New test. (Secure gateway veneers: wrong entry functions): Likewise. (Secure gateway veneers (ARMv8-M Baseline)): Likewise. (Secure gateway veneers (ARMv8-M Mainline)): Likewise. * testsuite/ld-arm/cmse-veneers.s: New file. * testsuite/ld-arm/cmse-veneers.d: Likewise. * testsuite/ld-arm/cmse-veneers.rd: Likewise. * testsuite/ld-arm/cmse-veneers.sd: Likewise. * testsuite/ld-arm/cmse-veneers-no-gnu_sgstubs.out: Likewise. * testsuite/ld-arm/cmse-veneers-wrong-entryfct.out: Likewise.
2016-08-04 22:36:52 +08:00
.syntax unified
.thumb
.file "foo.c"
.text
.macro decltype name, type
.ifc \type,object
.data
.else
.thumb
.thumb_func
.endif
.type \name, %\type
.endm
.macro entry name, type, vis, typespc, visspc, entry_fct
.align 2
.ifb \visspc
.\vis __acle_se_\name
.else
.\visspc __acle_se_\name
.endif
.\vis \name
.thumb
.thumb_func
.ifb \typespc
decltype __acle_se_\name, \type
.else
decltype __acle_se_\name, \typespc
.endif
decltype \name, \type
__acle_se_\name:
\entry_fct
\name:
.ifc \type,object
.word 42
.else
nop
.endif
.size \name, .-\name
.size __acle_se_\name, .-__acle_se_\name
.endm
.ifndef CHECK_ERRORS
@ Valid setups for veneer generation
entry glob_entry_veneer1, function, global
entry weak_entry_veneer1, function, weak
entry glob_entry_veneer2, function, global, visspc=weak
entry weak_entry_veneer2, function, weak, visspc=global
@ Valid setup for entry function without SG veneer
entry glob_entry_fct, function, global, entry_fct=nop
@ Valid setup for entry function with absolute address
.align 2
.global __acle_se_abs_entry_fct
.global abs_entry_fct
.type __acle_se_abs_entry_fct, %function
.type abs_entry_fct, %function
__acle_se_abs_entry_fct = 0x10000
abs_entry_fct = 0x10004
.size abs_entry_fct, 0
.size __acle_se_abs_entry_fct, 0
2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com> bfd/ * elf32-arm.c (CMSE_PREFIX): Define macro. (elf32_arm_stub_cmse_branch_thumb_only): Define stub sequence. (cmse_branch_thumb_only): Declare stub. (struct elf32_arm_link_hash_table): Define cmse_stub_sec field. (elf32_arm_get_plt_info): Add globals parameter. Use it to return FALSE if there is no PLT. (arm_type_of_stub): Adapt to new elf32_arm_get_plt_info signature. (elf32_arm_final_link_relocate): Likewise. (elf32_arm_gc_sweep_hook): Likewise. (elf32_arm_gc_mark_extra_sections): Mark sections holding ARMv8-M secure entry functions. (arm_stub_is_thumb): Add case for arm_stub_cmse_branch_thumb_only. (arm_dedicated_stub_output_section_required): Change to a switch case and add a case for arm_stub_cmse_branch_thumb_only. (arm_dedicated_stub_output_section_required_alignment): Likewise. (arm_stub_dedicated_output_section_name): Likewise. (arm_stub_dedicated_input_section_ptr): Likewise and remove ATTRIBUTE_UNUSED for htab parameter. (arm_stub_required_alignment): Likewise. (arm_stub_sym_claimed): Likewise. (arm_dedicated_stub_section_padding): Likewise. (cmse_scan): New function. (elf32_arm_size_stubs): Call cmse_scan for ARM M profile targets. Set stub_changed to TRUE if such veneers were created. (elf32_arm_swap_symbol_in): Add detection code for CMSE special symbols. include/ * arm.h (ARM_GET_SYM_CMSE_SPCL): Define macro. (ARM_SET_SYM_CMSE_SPCL): Likewise. ld/ * ld.texinfo (Placement of SG veneers): New concept entry. * testsuite/ld-arm/arm-elf.exp (Secure gateway veneers: no .gnu.sgstubs section): New test. (Secure gateway veneers: wrong entry functions): Likewise. (Secure gateway veneers (ARMv8-M Baseline)): Likewise. (Secure gateway veneers (ARMv8-M Mainline)): Likewise. * testsuite/ld-arm/cmse-veneers.s: New file. * testsuite/ld-arm/cmse-veneers.d: Likewise. * testsuite/ld-arm/cmse-veneers.rd: Likewise. * testsuite/ld-arm/cmse-veneers.sd: Likewise. * testsuite/ld-arm/cmse-veneers-no-gnu_sgstubs.out: Likewise. * testsuite/ld-arm/cmse-veneers-wrong-entryfct.out: Likewise.
2016-08-04 22:36:52 +08:00
.else
@ Invalid setups for veneer generation (visibility)
entry loc_entry_veneer1, function, local
entry loc_entry_veneer2, function, global, visspc=local
entry loc_entry_veneer3, function, local, visspc=global
entry loc_entry_veneer4, function, weak, visspc=local
entry loc_entry_veneer5, function, local, visspc=weak
@ Invalid setups for veneer generation (absent standard symbol)
.align 2
.global __acle_se_fake_entry_veneer1
.thumb
.thumb_func
.type __acle_se_fake_entry_veneer1, %function
__acle_se_fake_entry_veneer1:
nop
.size __acle_se_fake_entry_veneer1, .-__acle_se_fake_entry_veneer1
@ Invalid setups for veneer generation (type)
entry obj_entry_veneer1, object, global, typespc=function
entry obj_entry_veneer2, function, global, typespc=object
@ Invalid setup for veneer generation (sections)
.section .text.sub1
.align 2
.thumb
.thumb_func
.global __acle_se_fake_entry_veneer2
.type __acle_se_fake_entry_veneer2, %function
__acle_se_fake_entry_veneer2:
nop
.size __acle_se_fake_entry_veneer2, .-__acle_se_fake_entry_veneer2
.section .text.sub2
.align 2
.thumb
.thumb_func
.global fake_entry_veneer2
.type fake_entry_veneer2, %function
fake_entry_veneer2:
nop
.size fake_entry_veneer2, .-fake_entry_veneer2
.endif