[llvm] [BOLT] Detect Linux kernel version if the binary is a Linux kernel (PR #119088)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 19:59:48 PST 2024
================
@@ -0,0 +1,54 @@
+# REQUIRES: system-linux
+
+## Check that BOLT correctly detects the Linux kernel version
+
+# RUN: %clang -DA -target x86_64-unknown-unknown \
+# RUN: %cflags -nostdlib %s -o %t.exe \
+# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr
+# RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-A %s
+
+# CHECK-A: BOLT-INFO: Linux kernel version is 6.6.61
+
+# RUN: %clang -DB -target x86_64-unknown-unknown \
+# RUN: %cflags -nostdlib %s -o %t.exe \
+# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr
+# RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-B %s
+
+# CHECK-B: BOLT-INFO: Linux kernel version is 6.6.50
+
+# RUN: %clang -DC -target x86_64-unknown-unknown \
+# RUN: %cflags -nostdlib %s -o %t.exe \
+# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr
+# RUN: llvm-bolt %t.exe -o %t.out 2>&1 | FileCheck --check-prefix=CHECK-C %s
+
+# CHECK-C: BOLT-INFO: Linux kernel version is 6.6
+
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ ret
+ .size foo, .-foo
+
+## Linux kernel version
+ .rodata
+ .align 16
+ .globl linux_banner
+ .type linux_banner, @object
+linux_banner:
+
+#ifdef A
+ .string "Linux version 6.6.61\n"
----------------
maksfb wrote:
nit: could you please place `CHECK`s next to the object you are checking against?
https://github.com/llvm/llvm-project/pull/119088
More information about the llvm-commits
mailing list