| 1 | # REQUIRES: system-linux |
| 2 | |
| 3 | ## Check that BOLT correctly detects the Linux kernel version |
| 4 | |
| 5 | # RUN: %clang -DA -target x86_64-unknown-unknown \ |
| 6 | # RUN: %cflags -nostdlib %s -o %t.exe \ |
| 7 | # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr |
| 8 | # RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-A %s |
| 9 | |
| 10 | # RUN: %clang -DB -target x86_64-unknown-unknown \ |
| 11 | # RUN: %cflags -nostdlib %s -o %t.exe \ |
| 12 | # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr |
| 13 | # RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-B %s |
| 14 | |
| 15 | # RUN: %clang -DC -target x86_64-unknown-unknown \ |
| 16 | # RUN: %cflags -nostdlib %s -o %t.exe \ |
| 17 | # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr |
| 18 | # RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-C %s |
| 19 | |
| 20 | # RUN: %clang -DD -target x86_64-unknown-unknown \ |
| 21 | # RUN: %cflags -nostdlib %s -o %t.exe \ |
| 22 | # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr |
| 23 | # RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-D %s |
| 24 | |
| 25 | .text |
| 26 | .globl foo |
| 27 | .type foo, %function |
| 28 | foo: |
| 29 | ret |
| 30 | .size foo, .-foo |
| 31 | |
| 32 | ## Linux kernel version |
| 33 | .rodata |
| 34 | .align 16 |
| 35 | .globl linux_banner |
| 36 | .type linux_banner, @object |
| 37 | linux_banner: |
| 38 | |
| 39 | #ifdef A |
| 40 | .string "Linux version 6.6.61\n" |
| 41 | #endif |
| 42 | # CHECK-A: BOLT-INFO: Linux kernel version is 6.6.61 |
| 43 | |
| 44 | #ifdef B |
| 45 | .string "Linux version 6.6.50-rc4\n" |
| 46 | #endif |
| 47 | # CHECK-B: BOLT-INFO: Linux kernel version is 6.6.50 |
| 48 | |
| 49 | #ifdef C |
| 50 | .string "Linux version 6.6\n" |
| 51 | #endif |
| 52 | # CHECK-C: BOLT-INFO: Linux kernel version is 6.6 |
| 53 | |
| 54 | #ifdef D |
| 55 | .hidden linux_banner |
| 56 | .string "Linux version 6.6.15.2-2-xxx\n" |
| 57 | #endif |
| 58 | # CHECK-D: BOLT-INFO: Linux kernel version is 6.6 |
| 59 | |
| 60 | .size linux_banner, . - linux_banner |
| 61 | |
| 62 | ## Fake Linux Kernel sections. |
| 63 | .section __ksymtab,"a" ,@progbits |
| 64 | .section __ksymtab_gpl,"a" ,@progbits |
| 65 | |