127 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/x86-64-cet1.s -o %t1.o4# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/x86-64-cet2.s -o %t2.o5# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/x86-64-cet3.s -o %t3.o6# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/x86-64-cet4.s -o %t4.o7 8# RUN: ld.lld -e func1 %t.o %t1.o -o %t9# RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s10 11# RUN: ld.lld -e func1 %t.o %t2.o -o %t12# RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s13 14# CET: Properties: x86 feature: IBT, SHSTK15 16# RUN: ld.lld -e func1 %t.o %t3.o -o %t17# RUN: llvm-readelf -S %t | FileCheck --check-prefix=NOCET %s18 19# NOCET: Section Headers20# NOCET-NOT: .note.gnu.property21 22# RUN: ld.lld -e func1 %t.o %t3.o -o %t -z force-ibt 2>&1 \23# RUN: | FileCheck --check-prefix=WARN %s24# WARN: {{.*}}.o: -z force-ibt: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property25 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 %s28# REPORT_INVALID: error: unknown -z cet-report= value: something29# REPORT_INVALID-EMPTY:30 31# RUN: ld.lld -e func1 %t.o %t3.o -o /dev/null -z force-ibt -z cet-report=warning 2>&1 \32# RUN: | FileCheck --check-prefix=REPORT_FORCE %s33# REPORT_FORCE: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property34# REPORT_FORCE: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_SHSTK property35# REPORT_FORCE-EMPTY:36 37# RUN: ld.lld -e func1 %t.o %t3.o -o /dev/null -z cet-report=warning 2>&1 \38# RUN: | FileCheck --check-prefix=CET_REPORT_WARN %s39# CET_REPORT_WARN: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property40# CET_REPORT_WARN: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_SHSTK property41# CET_REPORT_WARN-EMPTY:42 43# RUN: not ld.lld -e func1 %t.o %t3.o -o /dev/null -z cet-report=error 2>&1 \44# RUN: | FileCheck --check-prefix=CET_REPORT_ERROR %s45# CET_REPORT_ERROR: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_IBT property46# CET_REPORT_ERROR: {{.*}}.o: -z cet-report: file does not have GNU_PROPERTY_X86_FEATURE_1_SHSTK property47# CET_REPORT_ERROR-EMPTY:48 49# RUN: ld.lld -e func1 %t.o %t4.o -o %t50# RUN: llvm-readelf -n %t | FileCheck --check-prefix=NOSHSTK %s51 52# Check .note.gnu.protery without property SHSTK.53# NOSHSTK: Properties: x86 feature: IBT{{$}}54 55# RUN: ld.lld -shared %t1.o -soname=so -o %t1.so56# RUN: ld.lld -e func1 %t.o %t1.so -o %t57# RUN: llvm-readelf -n %t | FileCheck --check-prefix=CET --match-full-lines %s58# RUN: llvm-readelf -x .got.plt %t | FileCheck --check-prefix=GOTPLT %s59# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck --check-prefix=DISASM %s60 61# GOTPLT: Hex dump of section '.got.plt':62# GOTPLT-NEXT: 203480 80232000 00000000 00000000 0000000063# GOTPLT-NEXT: 203490 00000000 00000000 50132000 0000000064# GOTPLT-NEXT: 2034a0 00000000 0000000065 66# DISASM: Disassembly of section .text:67# DISASM: 0000000000201330 <func1>:68# DISASM-NEXT: 201330: callq 0x201360 <func2+0x201360>69# DISASM-NEXT: 201335: callq 0x201370 <func2+0x201370>70# DISASM-NEXT: retq71 72# DISASM: Disassembly of section .plt:73# DISASM: 0000000000201340 <.plt>:74# DISASM-NEXT: 201340: pushq 0x2142(%rip)75# DISASM-NEXT: jmpq *0x2144(%rip)76# DISASM-NEXT: nopl (%rax)77# DISASM-NEXT: endbr6478# DISASM-NEXT: pushq $0x079# DISASM-NEXT: jmp 0x201340 <.plt>80# DISASM-NEXT: nop81 82# DISASM: Disassembly of section .plt.sec:83# DISASM: 0000000000201360 <.plt.sec>:84# DISASM-NEXT: 201360: endbr6485# DISASM-NEXT: jmpq *0x212e(%rip)86# DISASM-NEXT: nopw (%rax,%rax)87 88# DISASM: Disassembly of section .iplt:89# DISASM: 0000000000201370 <.iplt>:90# DISASM-NEXT: 201370: endbr6491# DISASM-NEXT: jmpq *0x2126(%rip)92# DISASM-NEXT: nopw (%rax,%rax)93 94## If there is no PLT entry, don't create .plt section.95# RUN: ld.lld -e 0 %t1.o -o %t.noplt96# RUN: llvm-readelf -S %t.noplt | FileCheck %s --check-prefix=NOPLT97# RUN: ld.lld -r %t1.o -o %t.noplt98# RUN: llvm-readelf -S %t.noplt | FileCheck %s --check-prefix=NOPLT99 100# NOPLT: [Nr] Name101# NOPLT-NOT: .plt102# NOPLT: .note.gnu.property103# NOPLT-NOT: .plt104 105.section ".note.gnu.property", "a"106.long 4107.long 0x10108.long 0x5109.asciz "GNU"110 111.long 0xc0000002 # GNU_PROPERTY_X86_FEATURE_1_AND112.long 4113.long 3 # GNU_PROPERTY_X86_FEATURE_1_IBT and SHSTK114.long 0115 116.text117.globl func1118.type func1,@function119func1:120 call func2121 call ifunc122 ret123 124.type ifunc,@gnu_indirect_function125ifunc:126 ret127