authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-24 22:31:25+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-24 22:31:25+02:00
logc9c210a4e74986a2bd1d0576d22ac9458d523d68
treeda63155025ea9a2d808b0466980a003fb295ebb8
parent403e539669deae8d4aeb11baa5f30aad5dfe6589

elf: test path errors in ld script parsing


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

test/link/elf.zig+22
......@@ -76,6 +76,7 @@ pub fn build(b: *Build) void {
7676 elf_step.dependOn(testLargeBss(b, .{ .target = glibc_target }));
7777 elf_step.dependOn(testLinkOrder(b, .{ .target = glibc_target }));
7878 elf_step.dependOn(testLdScript(b, .{ .target = glibc_target }));
79 elf_step.dependOn(testLdScriptPathErrors(b, .{ .target = glibc_target }));
7980 // https://github.com/ziglang/zig/issues/17451
8081 // elf_step.dependOn(testNoEhFrameHdr(b, .{ .target = glibc_target }));
8182 elf_step.dependOn(testPie(b, .{ .target = glibc_target }));
......@@ -1602,6 +1603,27 @@ fn testLdScript(b: *Build, opts: Options) *Step {
16021603 return test_step;
16031604}
16041605
1606fn testLdScriptPathErrors(b: *Build, opts: Options) *Step {
1607 const test_step = addTestStep(b, "ld-script-path-errors", opts);
1608
1609 const scripts = WriteFile.create(b);
1610 _ = scripts.add("liba.so", "INPUT(libfoo.so)");
1611
1612 const exe = addExecutable(b, "main", opts);
1613 addCSourceBytes(exe, "int main() { return 0; }", &.{});
1614 exe.linkSystemLibrary2("a", .{});
1615 exe.addLibraryPath(scripts.getDirectory());
1616 exe.linkLibC();
1617
1618 expectLinkErrors(exe, test_step, &.{
1619 "error: missing library dependency: GNU ld script '/?/liba.so' requires 'libfoo.so', but file not found",
1620 "note: tried libfoo.so",
1621 "note: tried /?/libfoo.so",
1622 });
1623
1624 return test_step;
1625}
1626
16051627fn testLinkingC(b: *Build, opts: Options) *Step {
16061628 const test_step = addTestStep(b, "linking-c", opts);
16071629