2 # RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=i386 %p/Inputs/i386-cet1.s -o %t1.o
4 # RUN: llvm-mc -filetype=obj -triple=i386 %p/Inputs/i386-cet2.s -o %t2.o
5 # RUN: llvm-mc -filetype=obj -triple=i386 %p/Inputs/i386-cet3.s -o %t3.o
6 # RUN: llvm-mc -filetype=obj -triple=i386 %p/Inputs/i386-cet4.s -o %t4.o
8 # RUN: ld.lld -e func1 %t.o %t1.o -o %t
9 # RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s
11 # RUN: ld.lld -e func1 %t.o %t2.o -o %t
12 # RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s
14 # CET: Properties: x86 feature: IBT, SHSTK
16 # RUN: ld.lld -e func1 %t.o %t3.o -o %t
17 # RUN: llvm-readelf -S %t | FileCheck --check-prefix=NOCET %s
19 # NOCET: Section Headers
20 # NOCET-NOT: .note.gnu.property
22 # RUN: ld.lld -e func1 %t.o %t3.o -o %t -z force-ibt 2>&1 \
23 # RUN: | FileCheck --check-prefix=WARN %s
24 # WARN: {{.*}}.o: -z force-ibt: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property
26 # RUN: not ld.lld -e func1 %t.o %t3.o -o /dev/null -z cet-report=something 2>&1 \
27 # RUN: | FileCheck --check-prefix=REPORT_INVALID %s
28 # REPORT_INVALID: error: -z cet-report= parameter something is not recognized
29 # REPORT_INVALID-EMPTY:
31 # RUN: ld.lld -e func1 %t.o %t3.o -o /dev/null -z cet-report=warning 2>&1 \
32 # RUN: | FileCheck --check-prefix=CET_REPORT_WARN %s
33 # CET_REPORT_WARN: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property
34 # CET_REPORT_WARN: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_SHSTK property
35 # CET_REPORT_WARN-EMPTY:
37 # RUN: not ld.lld -e func1 %t.o %t3.o -o /dev/null -z cet-report=error 2>&1 \
38 # RUN: | FileCheck --check-prefix=CET_REPORT_ERROR %s
39 # CET_REPORT_ERROR: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property
40 # CET_REPORT_ERROR: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_SHSTK property
41 # CET_REPORT_ERROR-EMPTY:
43 # RUN: ld.lld -e func1 %t.o %t4.o -o %t
44 # RUN: llvm-readelf -n %t | FileCheck --check-prefix=NOSHSTK %s
46 # Check .note.gnu.protery without property SHSTK.
47 # NOSHSTK: Properties: x86 feature: IBT{{$}}
49 # RUN: ld.lld -shared %t1.o -soname=so -o %t1.so
50 # RUN: ld.lld -e func1 %t.o %t1.so -o %t
51 # RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s
52 # RUN: llvm-readelf -x .got.plt %t | FileCheck --check-prefix=GOTPLT %s
53 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck --check-prefix=DISASM %s
55 # GOTPLT: Hex dump of section '.got.plt':
56 # GOTPLT-NEXT: 0x004032d0 50224000 00000000 00000000 20124000
57 # GOTPLT-NEXT: 0x004032e0 0b124000
59 # DISASM: Disassembly of section .text:
60 # DISASM: 00401200 <func1>:
61 # DISASM-NEXT: 401200: calll 0x401230 <func2+0x401230>
62 # DISASM-NEXT: 401205: calll 0x401240 <ifunc>
65 # DISASM: Disassembly of section .plt:
66 # DISASM: 00401210 <.plt>:
67 # DISASM-NEXT: 401210: pushl 0x4032d4
68 # DISASM-NEXT: jmpl *0x4032d8
73 # DISASM-NEXT: endbr32
74 # DISASM-NEXT: pushl $0x0
75 # DISASM-NEXT: jmp 0x401210 <.plt>
78 # DISASM: Disassembly of section .plt.sec:
79 # DISASM: 00401230 <.plt.sec>:
80 # DISASM-NEXT: 401230: endbr32
81 # DISASM-NEXT: jmpl *0x4032dc
82 # DISASM-NEXT: nopw (%eax,%eax)
84 # DISASM: Disassembly of section .iplt:
85 # DISASM: 00401240 <ifunc>:
86 # DISASM-NEXT: 401240: endbr32
87 # DISASM-NEXT: jmpl *0x4032e0
88 # DISASM-NEXT: nopw (%eax,%eax)
90 .section ".note.gnu.property", "a"
96 .long 0xc0000002 # GNU_PROPERTY_X86_FEATURE_1_AND
98 .long 3 # GNU_PROPERTY_X86_FEATURE_1_IBT and SHSTK
102 .type func1,@function
108 .type ifunc,@gnu_indirect_function