brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 83d2cd0 Raw
157 lines · plain
1# REQUIRES: system-linux2 3## Check that BOLT correctly parses the Linux kernel .altinstructions section4## and annotates alternative instructions.5 6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o7# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \8# RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie9# RUN: llvm-bolt %t.exe --print-cfg --alt-inst-feature-size=2 -o %t.out \10# RUN:   | FileCheck %s11 12## Older kernels used to have padlen field in alt_instr. Check compatibility.13 14# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --defsym PADLEN=1 \15# RUN:   %s -o %t.padlen.o16# RUN: %clang %cflags -nostdlib %t.padlen.o -o %t.padlen.exe \17# RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie18# RUN: llvm-bolt %t.padlen.exe --print-cfg --alt-inst-has-padlen -o %t.padlen.out \19# RUN:   | FileCheck %s20 21## Check with a larger size of "feature" field in alt_instr.22 23# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \24# RUN:   --defsym FEATURE_SIZE_4=1 %s -o %t.fs4.o25# RUN: %clang %cflags -nostdlib %t.fs4.o -o %t.fs4.exe \26# RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie27# RUN: llvm-bolt %t.fs4.exe --print-cfg --alt-inst-feature-size=4 -o %t.fs4.out \28# RUN:   | FileCheck %s29 30## Check that out-of-bounds read is handled properly.31 32# RUN: not llvm-bolt %t.fs4.exe --alt-inst-feature-size=2 -o %t.fs4.out33 34## Check that BOLT automatically detects structure fields in .altinstructions.35 36# RUN: llvm-bolt %t.exe --print-cfg -o %t.out | FileCheck %s37# RUN: llvm-bolt %t.exe --print-cfg -o %t.padlen.out | FileCheck %s38# RUN: llvm-bolt %t.exe --print-cfg -o %t.fs4.out | FileCheck %s39 40# CHECK:      BOLT-INFO: Linux kernel binary detected41# CHECK:      BOLT-INFO: parsed 3 alternative instruction entries42 43  .text44  .globl _start45  .type _start, %function46_start:47# CHECK: Binary Function "_start"48.L0:49  rdtsc50# CHECK:      rdtsc51# CHECK-SAME: AltInst: 152# CHECK-SAME: AltInst2: 253# CHECK-SAME: AltInst3: 354  nop55# CHECK-NEXT: nop56# CHECK-SAME: AltInst: 157# CHECK-SAME: AltInst2: 258# CHECK-SAME: AltInst3: 359  nop60  nop61.L1:62  ret63  .size _start, .-_start64 65  .section .altinstr_replacement,"ax",@progbits66.A0:67  lfence68  rdtsc69.A1:70  rdtscp71.A2:72  pushf73  pop %rax74.Ae:75 76## Alternative instruction info.77  .section .altinstructions,"a",@progbits78 79  .long .L0 - .   # org instruction80  .long .A0 - .   # alt instruction81.ifdef FEATURE_SIZE_482  .long 0x72      # feature flags83.else84  .word 0x72      # feature flags85.endif86  .byte .L1 - .L0 # org size87  .byte .A1 - .A0 # alt size88.ifdef PADLEN89  .byte 090.endif91 92  .long .L0 - .   # org instruction93  .long .A1 - .   # alt instruction94.ifdef FEATURE_SIZE_495  .long 0x3b      # feature flags96.else97  .word 0x3b      # feature flags98.endif99  .byte .L1 - .L0 # org size100  .byte .A2 - .A1 # alt size101.ifdef PADLEN102  .byte 0103.endif104 105  .long .L0 - .   # org instruction106  .long .A2 - .   # alt instruction107.ifdef FEATURE_SIZE_4108  .long 0x110     # feature flags109.else110  .word 0x110     # feature flags111.endif112  .byte .L1 - .L0 # org size113  .byte .Ae - .A2 # alt size114.ifdef PADLEN115  .byte 0116.endif117 118## ORC unwind for "pushf; pop %rax" alternative sequence.119  .section .orc_unwind,"a",@progbits120  .align 4121  .section .orc_unwind_ip,"a",@progbits122  .align 4123 124  .section .orc_unwind125  .2byte 8126  .2byte 0127  .2byte 0x205128  .section .orc_unwind_ip129  .long _start - .130 131  .section .orc_unwind132  .2byte 16133  .2byte 0134  .2byte 0x205135  .section .orc_unwind_ip136  .long .L0 + 1 - .137 138  .section .orc_unwind139  .2byte 8140  .2byte 0141  .2byte 0x205142  .section .orc_unwind_ip143  .long .L0 + 2 - .144 145## Linux kernel version146  .rodata147  .align 16148  .globl linux_banner149  .type  linux_banner, @object150linux_banner:151  .string  "Linux version 6.6.61\n"152  .size  linux_banner, . - linux_banner153 154## Fake Linux Kernel sections.155  .section __ksymtab,"a",@progbits156  .section __ksymtab_gpl,"a",@progbits157