1// REQUIRES: arm 2/// Create a secure app and import library using CMSE. 3/// Create a non-secure app that refers symbols in the import library. 4 5// RUN: rm -rf %t && split-file %s %t && cd %t 6// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-implib.s -o implib.o -I%S/Inputs/ 7// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-secure-app.s -o secureapp.o 8// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-non-secure-app.s -o nonsecureapp.o 9/// Create the secure app and import library. 10// RUN: ld.lld -e secure_entry --section-start .gnu.sgstubs=0x20000 --cmse-implib implib.o secureapp.o --out-implib=implib.lib -o secureapp 11/// Link the non-secure app against the import library. 12// RUN: ld.lld -e nonsecure_entry -Ttext=0x8000 implib.lib nonsecureapp.o -o nonsecureapp 13// RUN: llvm-readelf -s implib.lib | FileCheck %s 14// RUN: llvm-objdump -d --no-show-raw-insn secureapp | FileCheck %s --check-prefixes=SECUREDISS 15// RUN: llvm-objdump -d --no-show-raw-insn nonsecureapp | FileCheck %s --check-prefixes=NONSECUREDISS 16 17// SECUREDISS-LABEL: <entry>: 18// SECUREDISS-NEXT: 20000: sg 19// SECUREDISS-NEXT: b.w {{.*}} <__acle_se_entry> 20 21// SECUREDISS-LABEL: <__acle_se_entry>: 22// SECUREDISS-NEXT: 20008: nop 23 24// SECUREDISS-LABEL: <secure_entry>: 25// SECUREDISS-NEXT: 2000c: bl {{.*}} <__acle_se_entry> 26// SECUREDISS-NEXT: bx lr 27 28// NONSECUREDISS-LABEL: <nonsecure_entry>: 29// NONSECUREDISS-NEXT: 8000: push {r0, lr} 30// NONSECUREDISS-NEXT: bl 0x20000 31// NONSECUREDISS-NEXT: pop.w {r0, lr} 32// NONSECUREDISS-NEXT: bx lr 33 34// CHECK: Symbol table '.symtab' contains 2 entries: 35// CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name 36// CHECK-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 37// CHECK-NEXT: 1: 00020001 8 FUNC GLOBAL DEFAULT ABS entry 38 39//--- cmse-implib.s 40 .include "arm-cmse-macros.s" 41 42 .syntax unified 43 .text 44 45 cmse_veneer entry, function, global, function, global 46 47//--- cmse-secure-app.s 48 .align 2 49 // Main entry point. 50 .global secure_entry 51 .thumb_func 52secure_entry: 53 bl entry 54 bx lr 55 .size secure_entry, .-secure_entry 56 57//--- cmse-non-secure-app.s 58 .align 2 59 .global nonsecure_entry 60 .thumb 61 .thumb_func 62 .type nonsecure_entry, %function 63nonsecure_entry: 64 push {r0,lr} 65 bl entry 66 pop {r0,lr} 67 bx lr 68 .size nonsecure_entry, .-nonsecure_entry 69