authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2024-10-21 20:24:58-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-21 22:54:52-07:00
log85d87c9ca1f0c0c7fe9efa5ab54e306c6a309de3
treea769d6746e8fac5d0b4bc9bf320a3e6e811a3fbe
parent9f84f7f921d8a74926bb2f0ca1969b7b00f08172

coff: fix incorrect default `image_base` values and re-enable shared library tests on Windows

This was the cause of aarch64-windows shared libraries causing "bad image" errors during load-time linking. I also re-enabled the tests that were surfacing this bug.

5 files changed, 7 insertions(+), 23 deletions(-)

src/link/Coff.zig+7-3
......@@ -274,11 +274,15 @@ pub fn createEmpty(
274274
275275 .image_base = options.image_base orelse switch (output_mode) {
276276 .Exe => switch (target.cpu.arch) {
277 .aarch64 => 0x140000000,
278 .thumb, .x86_64, .x86 => 0x400000,
277 .aarch64, .x86_64 => 0x140000000,
278 .thumb, .x86 => 0x400000,
279 else => unreachable,
280 },
281 .Lib => switch (target.cpu.arch) {
282 .aarch64, .x86_64 => 0x180000000,
283 .thumb, .x86 => 0x10000000,
279284 else => unreachable,
280285 },
281 .Lib => 0x10000000,
282286 .Obj => 0,
283287 },
284288
test/standalone/c_compiler/build.zig-5
......@@ -5,11 +5,6 @@ pub fn build(b: *std.Build) void {
55 const test_step = b.step("test", "Test it");
66 b.default_step = test_step;
77
8 if (builtin.os.tag == .windows) {
9 // https://github.com/ziglang/zig/issues/16965
10 return;
11 }
12
138 add(b, test_step, "test_c_Debug", "test_cpp_Debug", .Debug);
149 add(b, test_step, "test_c_ReleaseFast", "test_cpp_ReleaseFast", .ReleaseFast);
1510 add(b, test_step, "test_c_ReleaseSmall", "test_cpp_ReleaseSmall", .ReleaseSmall);
test/standalone/coff_dwarf/build.zig-5
......@@ -12,11 +12,6 @@ pub fn build(b: *std.Build) void {
1212 else
1313 b.resolveTargetQuery(.{ .os_tag = .windows });
1414
15 if (builtin.cpu.arch == .aarch64) {
16 // https://github.com/ziglang/zig/issues/18427
17 return;
18 }
19
2015 const exe = b.addExecutable(.{
2116 .name = "main",
2217 .root_source_file = b.path("main.zig"),
test/standalone/load_dynamic_library/build.zig-5
......@@ -10,11 +10,6 @@ pub fn build(b: *std.Build) void {
1010
1111 if (builtin.os.tag == .wasi) return;
1212
13 if (builtin.os.tag == .windows) {
14 // https://github.com/ziglang/zig/issues/16960
15 return;
16 }
17
1813 const lib = b.addSharedLibrary(.{
1914 .name = "add",
2015 .root_source_file = b.path("add.zig"),
test/standalone/shared_library/build.zig-5
......@@ -4,11 +4,6 @@ pub fn build(b: *std.Build) void {
44 const test_step = b.step("test", "Test it");
55 b.default_step = test_step;
66
7 if (@import("builtin").os.tag == .windows) {
8 // https://github.com/ziglang/zig/issues/16959
9 return;
10 }
11
127 const optimize: std.builtin.OptimizeMode = .Debug;
138 const target = b.graph.host;
149 const lib = b.addSharedLibrary(.{