| author | |
| committer | |
| log | 1fb0b5a04429f06d75e22223765fa8723318489e |
| tree | 20cc14e5e2d44827497c0afbbe15d9344852ac16 |
| parent | 72dcad6f020363237bdcd05b3f26f7b67fa9f162 |
| parent | 956caf6eba6d5082f646dff501db0008fb523a1b |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
DynLib.lookup: cast the pointer to the correct alignment2 files changed, 3 insertions(+), 8 deletions(-)
lib/std/dynamic_library.zig+2-2| ... | ... | @@ -348,7 +348,7 @@ pub const WindowsDynLib = struct { |
| 348 | 348 | |
| 349 | 349 | pub fn lookup(self: *WindowsDynLib, comptime T: type, name: [:0]const u8) ?T { |
| 350 | 350 | if (windows.kernel32.GetProcAddress(self.dll, name.ptr)) |addr| { |
| 351 | return @ptrCast(T, addr); | |
| 351 | return @ptrCast(T, @alignCast(@alignOf(@typeInfo(T).Pointer.child), addr)); | |
| 352 | 352 | } else { |
| 353 | 353 | return null; |
| 354 | 354 | } |
| ... | ... | @@ -382,7 +382,7 @@ pub const DlDynlib = struct { |
| 382 | 382 | // dlsym (and other dl-functions) secretly take shadow parameter - return address on stack |
| 383 | 383 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826 |
| 384 | 384 | if (@call(.never_tail, system.dlsym, .{ self.handle, name.ptr })) |symbol| { |
| 385 | return @ptrCast(T, symbol); | |
| 385 | return @ptrCast(T, @alignCast(@alignOf(@typeInfo(T).Pointer.child), symbol)); | |
| 386 | 386 | } else { |
| 387 | 387 | return null; |
| 388 | 388 | } |
test/standalone/load_dynamic_library/build.zig+1-6| ... | ... | @@ -8,12 +8,7 @@ pub fn build(b: *std.Build) void { |
| 8 | 8 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 9 | 9 | const target: std.zig.CrossTarget = .{}; |
| 10 | 10 | |
| 11 | const ok = (builtin.os.tag != .wasi and | |
| 12 | // https://github.com/ziglang/zig/issues/13550 | |
| 13 | (builtin.os.tag != .macos or builtin.cpu.arch != .aarch64) and | |
| 14 | // https://github.com/ziglang/zig/issues/13686 | |
| 15 | (builtin.os.tag != .windows or builtin.cpu.arch != .aarch64)); | |
| 16 | if (!ok) return; | |
| 11 | if (builtin.os.tag == .wasi) return; | |
| 17 | 12 | |
| 18 | 13 | const lib = b.addSharedLibrary(.{ |
| 19 | 14 | .name = "add", |