Skip to content

Commit ca417e1

Browse files
committed
link/elf: simplify how we test thunks
1 parent 8fc15f1 commit ca417e1

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

test/link/elf.zig

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,44 +2973,27 @@ fn testStrip(b: *Build, opts: Options) *Step {
29732973
fn testThunks(b: *Build, opts: Options) *Step {
29742974
const test_step = addTestStep(b, "thunks", opts);
29752975

2976-
const src =
2977-
\\#include <stdio.h>
2978-
\\__attribute__((aligned(0x8000000))) int bar() {
2979-
\\ return 42;
2980-
\\}
2981-
\\int foobar();
2982-
\\int foo() {
2983-
\\ return bar() - foobar();
2984-
\\}
2985-
\\__attribute__((aligned(0x8000000))) int foobar() {
2986-
\\ return 42;
2987-
\\}
2988-
\\int main() {
2989-
\\ printf("bar=%d, foo=%d, foobar=%d", bar(), foo(), foobar());
2990-
\\ return foo();
2991-
\\}
2992-
;
2993-
2994-
{
2995-
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = src });
2996-
exe.link_function_sections = true;
2997-
exe.linkLibC();
2998-
2999-
const run = addRunArtifact(exe);
3000-
run.expectStdOutEqual("bar=42, foo=0, foobar=42");
3001-
run.expectExitCode(0);
3002-
test_step.dependOn(&run.step);
3003-
}
3004-
3005-
{
3006-
const exe = addExecutable(b, opts, .{ .name = "main2", .c_source_bytes = src });
3007-
exe.linkLibC();
2976+
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2977+
\\void foo();
2978+
\\__attribute__((section(".bar"))) void bar() {
2979+
\\ return foo();
2980+
\\}
2981+
\\__attribute__((section(".foo"))) void foo() {
2982+
\\ return bar();
2983+
\\}
2984+
\\int main() {
2985+
\\ foo();
2986+
\\ bar();
2987+
\\ return 0;
2988+
\\}
2989+
});
30082990

3009-
const run = addRunArtifact(exe);
3010-
run.expectStdOutEqual("bar=42, foo=0, foobar=42");
3011-
run.expectExitCode(0);
3012-
test_step.dependOn(&run.step);
3013-
}
2991+
const check = exe.checkObject();
2992+
check.checkInSymtab();
2993+
check.checkContains("foo$thunk");
2994+
check.checkInSymtab();
2995+
check.checkContains("bar$thunk");
2996+
test_step.dependOn(&check.step);
30142997

30152998
return test_step;
30162999
}

0 commit comments

Comments
 (0)