Skip to content

Commit

Permalink
elf: test handling of preinit array
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Jul 20, 2023
1 parent e4a51f9 commit 59f01e3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn addElfTests(b: *Build, opts: Options) *Step {
elf_step.dependOn(testLinkerScript(b, opts));
elf_step.dependOn(testNoEhFrameHdr(b, opts));
elf_step.dependOn(testPltGot(b, opts));
elf_step.dependOn(testPreinitArray(b, opts));
elf_step.dependOn(testTlsDesc(b, opts));
elf_step.dependOn(testTlsDescImport(b, opts));
elf_step.dependOn(testTlsDescStatic(b, opts));
Expand Down Expand Up @@ -1663,6 +1664,39 @@ fn testPltGot(b: *Build, opts: Options) *Step {
return test_step;
}

fn testPreinitArray(b: *Build, opts: Options) *Step {
const test_step = b.step("test-elf-preinit-array", "");

{
const obj = cc(b, opts);
obj.addCSource("void _start() {}");
obj.addArg("-c");

const exe = ld(b, opts);
exe.addFileSource(obj.out);

const check = exe.check();
check.checkInDynamicSection();
check.checkNotPresent("PREINIT_ARRAY");
}

{
const exe = cc(b, opts);
exe.addCSource(
\\void preinit_fn() {}
\\int main() {}
\\__attribute__((section(".preinit_array")))
\\void *preinit[] = { preinit_fn };
);

const check = exe.check();
check.checkInDynamicSection();
check.checkContains("PREINIT_ARRAY");
}

return test_step;
}

fn testTlsDesc(b: *Build, opts: Options) *Step {
const test_step = b.step("test-elf-tls-desc", "");

Expand Down

0 comments on commit 59f01e3

Please sign in to comment.