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(...@@ -274,11 +274,15 @@ pub fn createEmpty(
274274
275 .image_base = options.image_base orelse switch (output_mode) {275 .image_base = options.image_base orelse switch (output_mode) {
276 .Exe => switch (target.cpu.arch) {276 .Exe => switch (target.cpu.arch) {
277 .aarch64 => 0x140000000,277 .aarch64, .x86_64 => 0x140000000,
278 .thumb, .x86_64, .x86 => 0x400000,278 .thumb, .x86 => 0x400000,
279 else => unreachable,
280 },
281 .Lib => switch (target.cpu.arch) {
282 .aarch64, .x86_64 => 0x180000000,
283 .thumb, .x86 => 0x10000000,
279 else => unreachable,284 else => unreachable,
280 },285 },
281 .Lib => 0x10000000,
282 .Obj => 0,286 .Obj => 0,
283 },287 },
284288
test/standalone/c_compiler/build.zig-5
...@@ -5,11 +5,6 @@ pub fn build(b: *std.Build) void {...@@ -5,11 +5,6 @@ pub fn build(b: *std.Build) void {
5 const test_step = b.step("test", "Test it");5 const test_step = b.step("test", "Test it");
6 b.default_step = test_step;6 b.default_step = test_step;
77
8 if (builtin.os.tag == .windows) {
9 // https://github.com/ziglang/zig/issues/16965
10 return;
11 }
12
13 add(b, test_step, "test_c_Debug", "test_cpp_Debug", .Debug);8 add(b, test_step, "test_c_Debug", "test_cpp_Debug", .Debug);
14 add(b, test_step, "test_c_ReleaseFast", "test_cpp_ReleaseFast", .ReleaseFast);9 add(b, test_step, "test_c_ReleaseFast", "test_cpp_ReleaseFast", .ReleaseFast);
15 add(b, test_step, "test_c_ReleaseSmall", "test_cpp_ReleaseSmall", .ReleaseSmall);10 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 {...@@ -12,11 +12,6 @@ pub fn build(b: *std.Build) void {
12 else12 else
13 b.resolveTargetQuery(.{ .os_tag = .windows });13 b.resolveTargetQuery(.{ .os_tag = .windows });
1414
15 if (builtin.cpu.arch == .aarch64) {
16 // https://github.com/ziglang/zig/issues/18427
17 return;
18 }
19
20 const exe = b.addExecutable(.{15 const exe = b.addExecutable(.{
21 .name = "main",16 .name = "main",
22 .root_source_file = b.path("main.zig"),17 .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 {...@@ -10,11 +10,6 @@ pub fn build(b: *std.Build) void {
1010
11 if (builtin.os.tag == .wasi) return;11 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
18 const lib = b.addSharedLibrary(.{13 const lib = b.addSharedLibrary(.{
19 .name = "add",14 .name = "add",
20 .root_source_file = b.path("add.zig"),15 .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 {...@@ -4,11 +4,6 @@ pub fn build(b: *std.Build) void {
4 const test_step = b.step("test", "Test it");4 const test_step = b.step("test", "Test it");
5 b.default_step = test_step;5 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
12 const optimize: std.builtin.OptimizeMode = .Debug;7 const optimize: std.builtin.OptimizeMode = .Debug;
13 const target = b.graph.host;8 const target = b.graph.host;
14 const lib = b.addSharedLibrary(.{9 const lib = b.addSharedLibrary(.{