| ... | ... | @@ -23,6 +23,7 @@ pub fn testAll(b: *Build) *Step { |
| 23 | 23 | // Exercise linker in -r mode |
| 24 | 24 | elf_step.dependOn(testEmitRelocatable(b, .{ .use_llvm = false, .target = musl_target })); |
| 25 | 25 | elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target })); |
| 26 | elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target })); |
| 26 | 27 | elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target })); |
| 27 | 28 | |
| 28 | 29 | // Exercise linker in ar mode |
| ... | ... | @@ -2141,6 +2142,56 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 2141 | 2142 | return test_step; |
| 2142 | 2143 | } |
| 2143 | 2144 | |
| 2145 | fn testRelocatableArchive(b: *Build, opts: Options) *Step { |
| 2146 | const test_step = addTestStep(b, "relocatable-archive", opts); |
| 2147 | |
| 2148 | const obj1 = addObject(b, "obj1", opts); |
| 2149 | addCSourceBytes(obj1, |
| 2150 | \\void bar(); |
| 2151 | \\void foo() { |
| 2152 | \\ bar(); |
| 2153 | \\} |
| 2154 | , &.{}); |
| 2155 | |
| 2156 | const obj2 = addObject(b, "obj2", opts); |
| 2157 | addCSourceBytes(obj2, |
| 2158 | \\void bar() {} |
| 2159 | , &.{}); |
| 2160 | |
| 2161 | const obj3 = addObject(b, "obj3", opts); |
| 2162 | addCSourceBytes(obj3, |
| 2163 | \\void baz(); |
| 2164 | , &.{}); |
| 2165 | |
| 2166 | const obj4 = addObject(b, "obj4", opts); |
| 2167 | addCSourceBytes(obj4, |
| 2168 | \\void foo(); |
| 2169 | \\int main() { |
| 2170 | \\ foo(); |
| 2171 | \\} |
| 2172 | , &.{}); |
| 2173 | |
| 2174 | const lib = addStaticLibrary(b, "lib", opts); |
| 2175 | lib.addObject(obj1); |
| 2176 | lib.addObject(obj2); |
| 2177 | lib.addObject(obj3); |
| 2178 | |
| 2179 | const obj5 = addObject(b, "obj5", opts); |
| 2180 | obj5.addObject(obj4); |
| 2181 | obj5.linkLibrary(lib); |
| 2182 | |
| 2183 | const check = obj5.checkObject(); |
| 2184 | check.checkInSymtab(); |
| 2185 | check.checkContains("foo"); |
| 2186 | check.checkInSymtab(); |
| 2187 | check.checkContains("bar"); |
| 2188 | check.checkInSymtab(); |
| 2189 | check.checkNotPresent("baz"); |
| 2190 | test_step.dependOn(&check.step); |
| 2191 | |
| 2192 | return test_step; |
| 2193 | } |
| 2194 | |
| 2144 | 2195 | fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2145 | 2196 | const test_step = addTestStep(b, "relocatable-eh-frame", opts); |
| 2146 | 2197 | |