aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-11-16 10:51:21 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-11-16 10:51:21 +0100
commitf6bf3353b14682dab395f40ae3d2354a0ee64aed (patch)
treefe56b4a182865a4819c1b4642b32eb7151484e1c
parent359842f8d5a0ee2641c07c1e659d06553d6269fc (diff)
downloadzig-f6bf3353b14682dab395f40ae3d2354a0ee64aed.tar.gz
zig-f6bf3353b14682dab395f40ae3d2354a0ee64aed.zip
elf: test -r mode with archive on the linker line
-rw-r--r--test/link/elf.zig51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/link/elf.zig b/test/link/elf.zig
index 1c0a1835f0..3c02d61e92 100644
--- a/test/link/elf.zig
+++ b/test/link/elf.zig
@@ -23,6 +23,7 @@ pub fn testAll(b: *Build) *Step {
// Exercise linker in -r mode
elf_step.dependOn(testEmitRelocatable(b, .{ .use_llvm = false, .target = musl_target }));
elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));
+ elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target }));
elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));
// Exercise linker in ar mode
@@ -2141,6 +2142,56 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
return test_step;
}
+fn testRelocatableArchive(b: *Build, opts: Options) *Step {
+ const test_step = addTestStep(b, "relocatable-archive", opts);
+
+ const obj1 = addObject(b, "obj1", opts);
+ addCSourceBytes(obj1,
+ \\void bar();
+ \\void foo() {
+ \\ bar();
+ \\}
+ , &.{});
+
+ const obj2 = addObject(b, "obj2", opts);
+ addCSourceBytes(obj2,
+ \\void bar() {}
+ , &.{});
+
+ const obj3 = addObject(b, "obj3", opts);
+ addCSourceBytes(obj3,
+ \\void baz();
+ , &.{});
+
+ const obj4 = addObject(b, "obj4", opts);
+ addCSourceBytes(obj4,
+ \\void foo();
+ \\int main() {
+ \\ foo();
+ \\}
+ , &.{});
+
+ const lib = addStaticLibrary(b, "lib", opts);
+ lib.addObject(obj1);
+ lib.addObject(obj2);
+ lib.addObject(obj3);
+
+ const obj5 = addObject(b, "obj5", opts);
+ obj5.addObject(obj4);
+ obj5.linkLibrary(lib);
+
+ const check = obj5.checkObject();
+ check.checkInSymtab();
+ check.checkContains("foo");
+ check.checkInSymtab();
+ check.checkContains("bar");
+ check.checkInSymtab();
+ check.checkNotPresent("baz");
+ test_step.dependOn(&check.step);
+
+ return test_step;
+}
+
fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "relocatable-eh-frame", opts);