| ... | @@ -2671,36 +2671,56 @@ fn testStrip(b: *Build, opts: Options) *Step { | ... | @@ -2671,36 +2671,56 @@ fn testStrip(b: *Build, opts: Options) *Step { |
| 2671 | fn testThunks(b: *Build, opts: Options) *Step { | 2671 | fn testThunks(b: *Build, opts: Options) *Step { |
| 2672 | const test_step = addTestStep(b, "thunks", opts); | 2672 | const test_step = addTestStep(b, "thunks", opts); |
| 2673 | | 2673 | |
| 2674 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = | 2674 | const src = |
| 2675 | \\#include <stdio.h> | 2675 | \\#include <stdio.h> |
| 2676 | \\__attribute__((aligned(0x8000000))) int bar() { | 2676 | \\__attribute__((aligned(0x8000000))) int bar() { |
| 2677 | \\ return 42; | 2677 | \\ return 42; |
| 2678 | \\} | 2678 | \\} |
| 2679 | \\int foobar(); | 2679 | \\int foobar(); |
| 2680 | \\int foo() { | 2680 | \\int foo() { |
| 2681 | \\ return bar() - foobar(); | 2681 | \\ return bar() - foobar(); |
| 2682 | \\} | 2682 | \\} |
| 2683 | \\__attribute__((aligned(0x8000000))) int foobar() { | 2683 | \\__attribute__((aligned(0x8000000))) int foobar() { |
| 2684 | \\ return 42; | 2684 | \\ return 42; |
| 2685 | \\} | 2685 | \\} |
| 2686 | \\int main() { | 2686 | \\int main() { |
| 2687 | \\ printf("bar=%d, foo=%d, foobar=%d", bar(), foo(), foobar()); | 2687 | \\ printf("bar=%d, foo=%d, foobar=%d", bar(), foo(), foobar()); |
| 2688 | \\ return foo(); | 2688 | \\ return foo(); |
| 2689 | \\} | 2689 | \\} |
| 2690 | }); | 2690 | ; |
| 2691 | exe.link_function_sections = true; | | |
| 2692 | exe.linkLibC(); | | |
| 2693 | | 2691 | |
| 2694 | const run = addRunArtifact(exe); | 2692 | { |
| 2695 | run.expectStdOutEqual("bar=42, foo=0, foobar=42"); | 2693 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = src }); |
| 2696 | run.expectExitCode(0); | 2694 | exe.link_function_sections = true; |
| 2697 | test_step.dependOn(&run.step); | 2695 | exe.linkLibC(); |
| 2698 | | 2696 | |
| 2699 | const check = exe.checkObject(); | 2697 | const run = addRunArtifact(exe); |
| 2700 | check.max_bytes = std.math.maxInt(u32); | 2698 | run.expectStdOutEqual("bar=42, foo=0, foobar=42"); |
| 2701 | check.checkInSymtab(); | 2699 | run.expectExitCode(0); |
| 2702 | check.checkContains("_libc_start_main$thunk"); | 2700 | test_step.dependOn(&run.step); |
| 2703 | test_step.dependOn(&check.step); | 2701 | |
| | 2702 | const check = exe.checkObject(); |
| | 2703 | check.max_bytes = std.math.maxInt(u32); |
| | 2704 | check.checkInSymtab(); |
| | 2705 | check.checkContains("__libc_start_main$thunk"); |
| | 2706 | test_step.dependOn(&check.step); |
| | 2707 | } |
| | 2708 | |
| | 2709 | { |
| | 2710 | const exe = addExecutable(b, opts, .{ .name = "main2", .c_source_bytes = src }); |
| | 2711 | exe.linkLibC(); |
| | 2712 | |
| | 2713 | const run = addRunArtifact(exe); |
| | 2714 | run.expectStdOutEqual("bar=42, foo=0, foobar=42"); |
| | 2715 | run.expectExitCode(0); |
| | 2716 | test_step.dependOn(&run.step); |
| | 2717 | |
| | 2718 | const check = exe.checkObject(); |
| | 2719 | check.max_bytes = std.math.maxInt(u32); |
| | 2720 | check.checkInSymtab(); |
| | 2721 | check.checkContains("__libc_start_main$thunk"); |
| | 2722 | test_step.dependOn(&check.step); |
| | 2723 | } |
| 2704 | | 2724 | |
| 2705 | return test_step; | 2725 | return test_step; |
| 2706 | } | 2726 | } |