Skip to content

Commit

Permalink
coff: fix incorrect default image_base values and re-enable shared …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
kcbanner authored and andrewrk committed Oct 22, 2024
1 parent 9f84f7f commit 85d87c9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 23 deletions.
10 changes: 7 additions & 3 deletions src/link/Coff.zig
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,15 @@ pub fn createEmpty(

.image_base = options.image_base orelse switch (output_mode) {
.Exe => switch (target.cpu.arch) {
.aarch64 => 0x140000000,
.thumb, .x86_64, .x86 => 0x400000,
.aarch64, .x86_64 => 0x140000000,
.thumb, .x86 => 0x400000,
else => unreachable,
},
.Lib => switch (target.cpu.arch) {
.aarch64, .x86_64 => 0x180000000,
.thumb, .x86 => 0x10000000,
else => unreachable,
},
.Lib => 0x10000000,
.Obj => 0,
},

Expand Down
5 changes: 0 additions & 5 deletions test/standalone/c_compiler/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;

if (builtin.os.tag == .windows) {
// https://github.com/ziglang/zig/issues/16965
return;
}

add(b, test_step, "test_c_Debug", "test_cpp_Debug", .Debug);
add(b, test_step, "test_c_ReleaseFast", "test_cpp_ReleaseFast", .ReleaseFast);
add(b, test_step, "test_c_ReleaseSmall", "test_cpp_ReleaseSmall", .ReleaseSmall);
Expand Down
5 changes: 0 additions & 5 deletions test/standalone/coff_dwarf/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ pub fn build(b: *std.Build) void {
else
b.resolveTargetQuery(.{ .os_tag = .windows });

if (builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/18427
return;
}

const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("main.zig"),
Expand Down
5 changes: 0 additions & 5 deletions test/standalone/load_dynamic_library/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ pub fn build(b: *std.Build) void {

if (builtin.os.tag == .wasi) return;

if (builtin.os.tag == .windows) {
// https://github.com/ziglang/zig/issues/16960
return;
}

const lib = b.addSharedLibrary(.{
.name = "add",
.root_source_file = b.path("add.zig"),
Expand Down
5 changes: 0 additions & 5 deletions test/standalone/shared_library/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;

if (@import("builtin").os.tag == .windows) {
// https://github.com/ziglang/zig/issues/16959
return;
}

const optimize: std.builtin.OptimizeMode = .Debug;
const target = b.graph.host;
const lib = b.addSharedLibrary(.{
Expand Down

0 comments on commit 85d87c9

Please sign in to comment.