xref: /llvm-project/lld/test/ELF/arm-cmse-keep-sections.s (revision 9acbab60e59183e04741060984cb684163a73460)
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/// Create the secure app and import library.
9// RUN: ld.lld -e secure_entry --section-start .gnu.sgstubs=0x1000000 --section-start SECURE1=0x10 --section-start SECURE2=0x2000000 --cmse-implib implib.o secureapp.o --out-implib=implib.lib -o secureapp --gc-sections
10// RUN: llvm-readelf -s implib.lib | FileCheck %s
11// RUN: llvm-objdump -d --no-show-raw-insn secureapp | FileCheck %s --check-prefix=DISS
12
13
14// DISS-LABEL: <__acle_se_entry1>:
15// DISS-NEXT:  10: nop
16
17// DISS-LABEL: <entry1>:
18// DISS-NEXT: 1000000: sg
19// DISS-LABEL:         b.w {{.*}} <__acle_se_entry1>
20
21// DISS-LABEL: <entry2>:
22// DISS-NEXT: 1000008: sg
23// DISS-LABEL:         b.w {{.*}} <__acle_se_entry2>
24
25// DISS-LABEL: <__acle_se_entry2>:
26// DISS-NEXT:  2000000: nop
27
28// CHECK:    Symbol table '.symtab' contains {{.*}} entries:
29// CHECK-NEXT:  Num:  Value  Size Type  Bind   Vis     Ndx Name
30// CHECK-NEXT:    0: 00000000   0 NOTYPE  LOCAL  DEFAULT   UND
31// CHECK-NEXT:    1: 01000001   8 FUNC  GLOBAL DEFAULT   ABS entry1
32// CHECK-NEXT:    2: 01000009   8 FUNC  GLOBAL DEFAULT   ABS entry2
33
34//--- cmse-implib.s
35  .include "arm-cmse-macros.s"
36
37  .syntax unified
38  .section SECURE1, "ax"
39
40  cmse_veneer entry1, function, global, function, global
41
42  .syntax unified
43  .section SECURE2, "ax"
44
45  cmse_veneer entry2, function, global, function, global
46
47//--- cmse-secure-app.s
48  .text
49  .align  2
50  // Main entry point.
51  .global secure_entry
52  .thumb_func
53secure_entry:
54  bx lr
55  .size  secure_entry, .-secure_entry
56