aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-08-21 23:05:28 +0200
committerJakub Konka <kubkon@jakubkonka.com>2024-08-21 23:05:28 +0200
commitca417e1e32571b87b4a198a3f6faf1e63e7833b2 (patch)
tree6fec0e3ebc4cd43cfddd69e9de8411e56c4c9457 /test
parent8fc15f188c0deb1b0e2847297e535823eca1d2e8 (diff)
downloadzig-ca417e1e32571b87b4a198a3f6faf1e63e7833b2.tar.gz
zig-ca417e1e32571b87b4a198a3f6faf1e63e7833b2.zip
link/elf: simplify how we test thunks
Diffstat (limited to 'test')
-rw-r--r--test/link/elf.zig57
1 files changed, 20 insertions, 37 deletions
diff --git a/test/link/elf.zig b/test/link/elf.zig
index 5539638ba7..98253811b2 100644
--- a/test/link/elf.zig
+++ b/test/link/elf.zig
@@ -2973,44 +2973,27 @@ fn testStrip(b: *Build, opts: Options) *Step {
fn testThunks(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "thunks", opts);
- const src =
- \\#include <stdio.h>
- \\__attribute__((aligned(0x8000000))) int bar() {
- \\ return 42;
- \\}
- \\int foobar();
- \\int foo() {
- \\ return bar() - foobar();
- \\}
- \\__attribute__((aligned(0x8000000))) int foobar() {
- \\ return 42;
- \\}
- \\int main() {
- \\ printf("bar=%d, foo=%d, foobar=%d", bar(), foo(), foobar());
- \\ return foo();
- \\}
- ;
-
- {
- const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = src });
- exe.link_function_sections = true;
- exe.linkLibC();
-
- const run = addRunArtifact(exe);
- run.expectStdOutEqual("bar=42, foo=0, foobar=42");
- run.expectExitCode(0);
- test_step.dependOn(&run.step);
- }
-
- {
- const exe = addExecutable(b, opts, .{ .name = "main2", .c_source_bytes = src });
- exe.linkLibC();
+ const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
+ \\void foo();
+ \\__attribute__((section(".bar"))) void bar() {
+ \\ return foo();
+ \\}
+ \\__attribute__((section(".foo"))) void foo() {
+ \\ return bar();
+ \\}
+ \\int main() {
+ \\ foo();
+ \\ bar();
+ \\ return 0;
+ \\}
+ });
- const run = addRunArtifact(exe);
- run.expectStdOutEqual("bar=42, foo=0, foobar=42");
- run.expectExitCode(0);
- test_step.dependOn(&run.step);
- }
+ const check = exe.checkObject();
+ check.checkInSymtab();
+ check.checkContains("foo$thunk");
+ check.checkInSymtab();
+ check.checkContains("bar$thunk");
+ test_step.dependOn(&check.step);
return test_step;
}