brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 2e4457e Raw
100 lines · plain
1# REQUIRES: system-linux2 3## Check that BOLT correctly updates the Linux kernel static keys jump table.4 5# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o6# RUN: link_fdata %s %t.o %t.fdata7# RUN: llvm-strip --strip-unneeded %t.o8# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \9# RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr10 11## Verify static keys jump bindings to instructions.12 13# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \14# RUN:   --bolt-info=0 2>&1 | FileCheck %s15 16## Verify that profile is matched correctly.17 18# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \19# RUN:   --bolt-info=0 --data %t.fdata 2>&1 \20# RUN:   | FileCheck --check-prefix=CHECK-FDATA %s21 22## Verify the bindings again on the rewritten binary with nops removed.23 24# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s25 26# CHECK:      BOLT-INFO: Linux kernel binary detected27# CHECK:      BOLT-INFO: parsed 2 static keys jump entries28 29  .text30  .globl _start31  .type _start, %function32_start:33# CHECK: Binary Function "_start"34  nop35.L0:36  jmp L137# CHECK:      jit38# CHECK-SAME: # ID: 1 {{.*}} # Likely: 1 # InitValue: 039  nop40L1:41  .nops 542# CHECK:      jit43# CHECK-SAME: # ID: 2 {{.*}} # Likely: 0 # InitValue: 044  jmp .L045 46## Check that a branch profile associated with a NOP is handled properly when47## dynamic branch is created.48 49# FDATA: 1 _start #L1# 1 _start #L2# 3 4250# CHECK-FDATA: jit {{.*}} # ID: 251# CHECK-FDATA-NEXT: jmp52# CHECK-FDATA-NEXT: Successors: {{.*}}  (mispreds: 3, count: 42)53L2:54  nop55  .size _start, .-_start56 57  .globl foo58  .type foo, %function59foo:60  ret61  .size foo, .-foo62 63 64## Static keys jump table.65  .rodata66  .globl __start___jump_table67  .type __start___jump_table, %object68__start___jump_table:69 70  .long .L0 - .                   # Jump address71  .long L1 - .                    # Target address72  .quad fake_static_key + 1 - .   # Key address; LSB = 1 : likely73 74  .long L1 - .                    # Jump address75  .long L2 - .                    # Target address76  .quad fake_static_key -.        # Key address; LSB = 0 : unlikely77 78  .globl __stop___jump_table79  .type __stop___jump_table, %object80__stop___jump_table:81 82## Staic keys (we just use the label ignoring the format of the keys).83  .data84  .align 885fake_static_key:86  .quad 087 88## Linux kernel version89  .rodata90  .align 1691  .globl linux_banner92  .type  linux_banner, @object93linux_banner:94  .string  "Linux version 6.6.61\n"95  .size  linux_banner, . - linux_banner96 97## Fake Linux Kernel sections.98  .section __ksymtab,"a",@progbits99  .section __ksymtab_gpl,"a",@progbits100