authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-07 23:13:32+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:05+02:00
log20980b33e38295aa049d1ae419a74530aa8c62c9
tree1b50a314bbc83089455316018c7657631f078106
parent9861a9ea75f117ce236f62af8af22620c625a0f9

elf: test entry point


1 files changed, 44 insertions(+), 0 deletions(-)

test/link/elf.zig+44
......@@ -51,6 +51,7 @@ pub fn build(b: *Build) void {
5151 elf_step.dependOn(testLargeAlignmentDso(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker }));
5252
5353 for (&[_]CrossTarget{ musl_target, glibc_target }) |target| {
54 elf_step.dependOn(testEntryPoint(b, .{ .target = target }));
5455 elf_step.dependOn(testLargeAlignmentExe(b, .{ .target = target }));
5556 }
5657}
......@@ -564,6 +565,49 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
564565 return test_step;
565566}
566567
568fn testEntryPoint(b: *Build, opts: Options) *Step {
569 const test_step = addTestStep(b, "entry-point", opts);
570
571 const a_o = addObject(b, "a", opts);
572 addAsmSourceBytes(a_o,
573 \\.globl foo, bar
574 \\foo = 0x1000
575 \\bar = 0x2000
576 );
577
578 const b_o = addObject(b, "b", opts);
579 addCSourceBytes(b_o, "int main() { return 0; }", &.{});
580
581 {
582 const exe = addExecutable(b, "main", opts);
583 exe.addObject(a_o);
584 exe.addObject(b_o);
585 exe.entry_symbol_name = "foo";
586
587 const check = exe.checkObject();
588 check.checkStart();
589 check.checkExact("header");
590 check.checkExact("entry 1000");
591 test_step.dependOn(&check.step);
592 }
593
594 {
595 // TODO if I rename this to `main` it fails
596 const exe = addExecutable(b, "other", opts);
597 exe.addObject(a_o);
598 exe.addObject(b_o);
599 exe.entry_symbol_name = "bar";
600
601 const check = exe.checkObject();
602 check.checkStart();
603 check.checkExact("header");
604 check.checkExact("entry 2000");
605 test_step.dependOn(&check.step);
606 }
607
608 return test_step;
609}
610
567611fn testGcSections(b: *Build, opts: Options) *Step {
568612 const test_step = addTestStep(b, "gc-sections", opts);
569613