Skip to content

Commit bc1e0c5

Browse files
authored
[profile] Make the binary-id-offset.c test more robust (#117647)
Using a `--section-start` address in the test was causing link errors on some targets. Now it uses a linker script to move the note after `.bss`, which should still have the kind of memory offset we're looking for. This is a follow-up to #114907 to fix buildbot errors.
1 parent 61a2364 commit bc1e0c5

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

compiler-rt/test/profile/Linux/binary-id-offset.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// REQUIRES: linux
1+
// REQUIRES: linux, lld-available
22
//
33
// Make sure the build-id can be found in both EXEC and DYN (PIE) files,
4-
// even when the note's section-start is forced to a weird address.
4+
// even when the note has been loaded at an offset address in memory.
55
// (The DYN case would also apply to libraries, not explicitly tested here.)
66

77
// DEFINE: %{cflags} =
8-
// DEFINE: %{check} = ( \
9-
// DEFINE: %clang_profgen -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 \
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 \
1313
// DEFINE: ) | FileCheck %s
1414

1515
// REDEFINE: %{cflags} = -no-pie
@@ -18,15 +18,20 @@
1818
// REDEFINE: %{cflags} = -pie -fPIE
1919
// RUN: %{check}
2020

21-
// REDEFINE: %{cflags} = -no-pie -Wl,--section-start=.note.gnu.build-id=0x1000000
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
2226
// RUN: %{check}
2327

24-
// REDEFINE: %{cflags} = -pie -fPIE -Wl,--section-start=.note.gnu.build-id=0x1000000
28+
// REDEFINE: %{cflags} = -pie -fPIE -Wl,--script=%t.script
2529
// RUN: %{check}
2630

2731
// CHECK-LABEL{LITERAL}: .note.gnu.build-id
2832
// CHECK: Build ID: [[ID:[0-9a-f]+]]
2933

34+
// CHECK-LABEL{LITERAL}: Instrumentation level: Front-end
3035
// CHECK-LABEL{LITERAL}: Binary IDs:
3136
// CHECK-NEXT: [[ID]]
3237

0 commit comments

Comments
 (0)