Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / profile / Linux / binary-id-offset.c
blobdd4ce7dc4d03d2038212cb0f90c7de344184ce27
1 // REQUIRES: linux, lld-available
2 //
3 // Make sure the build-id can be found in both EXEC and DYN (PIE) files,
4 // even when the note has been loaded at an offset address in memory.
5 // (The DYN case would also apply to libraries, not explicitly tested here.)
7 // DEFINE: %{cflags} =
8 // DEFINE: %{check} = ( \
9 // DEFINE: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} && \
10 // DEFINE: env LLVM_PROFILE_FILE=%t.profraw %run %t && \
11 // DEFINE: llvm-readelf --notes %t && \
12 // DEFINE: llvm-profdata show --binary-ids %t.profraw \
13 // DEFINE: ) | FileCheck %s
15 // REDEFINE: %{cflags} = -no-pie
16 // RUN: %{check}
18 // REDEFINE: %{cflags} = -pie -fPIE
19 // RUN: %{check}
21 // Moving the note after .bss also gives it extra LOAD segment padding,
22 // making its memory offset different than its file offset.
23 // RUN: echo "SECTIONS { .note.gnu.build-id : {} } INSERT AFTER .bss;" >%t.script
25 // REDEFINE: %{cflags} = -no-pie -Wl,--script=%t.script
26 // RUN: %{check}
28 // REDEFINE: %{cflags} = -pie -fPIE -Wl,--script=%t.script
29 // RUN: %{check}
31 // CHECK-LABEL{LITERAL}: .note.gnu.build-id
32 // CHECK: Build ID: [[ID:[0-9a-f]+]]
34 // CHECK-LABEL{LITERAL}: Instrumentation level: Front-end
35 // CHECK-LABEL{LITERAL}: Binary IDs:
36 // CHECK-NEXT: [[ID]]
38 int main() { return 0; }