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.) |
6 | |
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 |
14 | |
15 | // REDEFINE: %{cflags} = -no-pie |
16 | // RUN: %{check} |
17 | |
18 | // REDEFINE: %{cflags} = -pie -fPIE |
19 | // RUN: %{check} |
20 | |
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 |
24 | |
25 | // REDEFINE: %{cflags} = -no-pie -Wl,--script=%t.script |
26 | // RUN: %{check} |
27 | |
28 | // REDEFINE: %{cflags} = -pie -fPIE -Wl,--script=%t.script |
29 | // RUN: %{check} |
30 | |
31 | // CHECK-LABEL{LITERAL}: .note.gnu.build-id |
32 | // CHECK: Build ID: [[ID:[0-9a-f]+]] |
33 | |
34 | // CHECK-LABEL{LITERAL}: Instrumentation level: Front-end |
35 | // CHECK-LABEL{LITERAL}: Binary IDs: |
36 | // CHECK-NEXT: [[ID]] |
37 | |
38 | int main() { return 0; } |
39 | |