authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-09 11:49:04+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-09 11:49:04+01:00
logf607126614ab249dbf8f965ca0911fda560bc580
treef97a48cfada0db7ae0d07cddbf992af16affb714
parent0de5dd2ef144a5a53c5bdbf1d8e45c1d2becd47b

test/link/elf: verify we can output a valid relocatable with .eh_frame section


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

test/link/elf.zig+43
......@@ -24,6 +24,7 @@ pub fn build(b: *Build) void {
2424 // Exercise linker in -r mode
2525 elf_step.dependOn(testEmitRelocatable(b, .{ .use_llvm = false, .target = musl_target }));
2626 elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));
27 elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));
2728
2829 // Exercise linker in ar mode
2930 elf_step.dependOn(testEmitStaticLib(b, .{ .target = musl_target }));
......@@ -2139,6 +2140,48 @@ fn testPreinitArray(b: *Build, opts: Options) *Step {
21392140 return test_step;
21402141}
21412142
2143fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2144 const test_step = addTestStep(b, "relocatable-eh-frame", opts);
2145
2146 const obj = addObject(b, "obj", opts);
2147 addCppSourceBytes(obj,
2148 \\#include <stdexcept>
2149 \\int try_me() {
2150 \\ throw std::runtime_error("Oh no!");
2151 \\}
2152 , &.{});
2153 addCppSourceBytes(obj,
2154 \\extern int try_me();
2155 \\int try_again() {
2156 \\ return try_me();
2157 \\}
2158 , &.{});
2159 obj.linkLibCpp();
2160
2161 const exe = addExecutable(b, "test", opts);
2162 addCppSourceBytes(exe,
2163 \\#include <iostream>
2164 \\#include <stdexcept>
2165 \\extern int try_again();
2166 \\int main() {
2167 \\ try {
2168 \\ try_again();
2169 \\ } catch (const std::exception &e) {
2170 \\ std::cout << "exception=" << e.what() << std::endl;
2171 \\ }
2172 \\ return 0;
2173 \\}
2174 , &.{});
2175 exe.addObject(obj);
2176 exe.linkLibCpp();
2177
2178 const run = addRunArtifact(exe);
2179 run.expectStdOutEqual("exception=Oh no!");
2180 test_step.dependOn(&run.step);
2181
2182 return test_step;
2183}
2184
21422185fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
21432186 const test_step = addTestStep(b, "shared-abs-symbol", opts);
21442187