| ... | @@ -23,7 +23,9 @@ pub fn testAll(b: *Build) *Step { | ... | @@ -23,7 +23,9 @@ pub fn testAll(b: *Build) *Step { |
| 23 | // Exercise linker in -r mode | 23 | // Exercise linker in -r mode |
| 24 | elf_step.dependOn(testEmitRelocatable(b, .{ .use_llvm = false, .target = musl_target })); | 24 | elf_step.dependOn(testEmitRelocatable(b, .{ .use_llvm = false, .target = musl_target })); |
| 25 | elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target })); | 25 | elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target })); |
| | 26 | elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target })); |
| 26 | elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target })); | 27 | elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target })); |
| | 28 | elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target })); |
| 27 | | 29 | |
| 28 | // Exercise linker in ar mode | 30 | // Exercise linker in ar mode |
| 29 | elf_step.dependOn(testEmitStaticLib(b, .{ .target = musl_target })); | 31 | elf_step.dependOn(testEmitStaticLib(b, .{ .target = musl_target })); |
| ... | @@ -2141,6 +2143,56 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { | ... | @@ -2141,6 +2143,56 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 2141 | return test_step; | 2143 | return test_step; |
| 2142 | } | 2144 | } |
| 2143 | | 2145 | |
| | 2146 | fn testRelocatableArchive(b: *Build, opts: Options) *Step { |
| | 2147 | const test_step = addTestStep(b, "relocatable-archive", opts); |
| | 2148 | |
| | 2149 | const obj1 = addObject(b, "obj1", opts); |
| | 2150 | addCSourceBytes(obj1, |
| | 2151 | \\void bar(); |
| | 2152 | \\void foo() { |
| | 2153 | \\ bar(); |
| | 2154 | \\} |
| | 2155 | , &.{}); |
| | 2156 | |
| | 2157 | const obj2 = addObject(b, "obj2", opts); |
| | 2158 | addCSourceBytes(obj2, |
| | 2159 | \\void bar() {} |
| | 2160 | , &.{}); |
| | 2161 | |
| | 2162 | const obj3 = addObject(b, "obj3", opts); |
| | 2163 | addCSourceBytes(obj3, |
| | 2164 | \\void baz(); |
| | 2165 | , &.{}); |
| | 2166 | |
| | 2167 | const obj4 = addObject(b, "obj4", opts); |
| | 2168 | addCSourceBytes(obj4, |
| | 2169 | \\void foo(); |
| | 2170 | \\int main() { |
| | 2171 | \\ foo(); |
| | 2172 | \\} |
| | 2173 | , &.{}); |
| | 2174 | |
| | 2175 | const lib = addStaticLibrary(b, "lib", opts); |
| | 2176 | lib.addObject(obj1); |
| | 2177 | lib.addObject(obj2); |
| | 2178 | lib.addObject(obj3); |
| | 2179 | |
| | 2180 | const obj5 = addObject(b, "obj5", opts); |
| | 2181 | obj5.addObject(obj4); |
| | 2182 | obj5.linkLibrary(lib); |
| | 2183 | |
| | 2184 | const check = obj5.checkObject(); |
| | 2185 | check.checkInSymtab(); |
| | 2186 | check.checkContains("foo"); |
| | 2187 | check.checkInSymtab(); |
| | 2188 | check.checkContains("bar"); |
| | 2189 | check.checkInSymtab(); |
| | 2190 | check.checkNotPresent("baz"); |
| | 2191 | test_step.dependOn(&check.step); |
| | 2192 | |
| | 2193 | return test_step; |
| | 2194 | } |
| | 2195 | |
| 2144 | fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { | 2196 | fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2145 | const test_step = addTestStep(b, "relocatable-eh-frame", opts); | 2197 | const test_step = addTestStep(b, "relocatable-eh-frame", opts); |
| 2146 | | 2198 | |
| ... | @@ -2224,6 +2276,33 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { | ... | @@ -2224,6 +2276,33 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { |
| 2224 | return test_step; | 2276 | return test_step; |
| 2225 | } | 2277 | } |
| 2226 | | 2278 | |
| | 2279 | fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step { |
| | 2280 | const test_step = addTestStep(b, "relocatable-no-eh-frame", opts); |
| | 2281 | |
| | 2282 | const obj1 = addObject(b, "obj1", opts); |
| | 2283 | addCSourceBytes(obj1, "int bar() { return 42; }", &.{ |
| | 2284 | "-fno-unwind-tables", |
| | 2285 | "-fno-asynchronous-unwind-tables", |
| | 2286 | }); |
| | 2287 | |
| | 2288 | const obj2 = addObject(b, "obj2", opts); |
| | 2289 | obj2.addObject(obj1); |
| | 2290 | |
| | 2291 | const check1 = obj1.checkObject(); |
| | 2292 | check1.checkStart(); |
| | 2293 | check1.checkExact("section headers"); |
| | 2294 | check1.checkNotPresent(".eh_frame"); |
| | 2295 | test_step.dependOn(&check1.step); |
| | 2296 | |
| | 2297 | const check2 = obj2.checkObject(); |
| | 2298 | check2.checkStart(); |
| | 2299 | check2.checkExact("section headers"); |
| | 2300 | check2.checkNotPresent(".eh_frame"); |
| | 2301 | test_step.dependOn(&check2.step); |
| | 2302 | |
| | 2303 | return test_step; |
| | 2304 | } |
| | 2305 | |
| 2227 | fn testSharedAbsSymbol(b: *Build, opts: Options) *Step { | 2306 | fn testSharedAbsSymbol(b: *Build, opts: Options) *Step { |
| 2228 | const test_step = addTestStep(b, "shared-abs-symbol", opts); | 2307 | const test_step = addTestStep(b, "shared-abs-symbol", opts); |
| 2229 | | 2308 | |