Skip to content

Commit 3ef8460

Browse files
committed
fix load dynamic library API when linking libc
1 parent 80882bd commit 3ef8460

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/std/dynamic_library.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub const LinuxDynLib = struct {
142142
self.* = undefined;
143143
}
144144

145-
pub fn lookup(self: *LinuxDynLib, comptime T: type, name: []const u8) ?T {
145+
pub fn lookup(self: *LinuxDynLib, comptime T: type, name: [:0]const u8) ?T {
146146
if (self.elf_lib.lookup("", name)) |symbol| {
147147
return @intToPtr(T, symbol);
148148
} else {
@@ -292,7 +292,7 @@ pub const WindowsDynLib = struct {
292292
self.* = undefined;
293293
}
294294

295-
pub fn lookup(self: *DlDynlib, comptime T: type, name: [:0]const u8) ?T {
295+
pub fn lookup(self: *WindowsDynLib, comptime T: type, name: [:0]const u8) ?T {
296296
if (windows.kernel32.GetProcAddress(self.dll, name.ptr)) |addr| {
297297
return @ptrCast(T, addr);
298298
} else {
@@ -324,7 +324,7 @@ pub const DlDynlib = struct {
324324
self.* = undefined;
325325
}
326326

327-
pub fn lookup(self: *DlDynlib, comptime T: type, name: [*:0]const u8) ?T {
327+
pub fn lookup(self: *DlDynlib, comptime T: type, name: [:0]const u8) ?T {
328328
// dlsym (and other dl-functions) secretly take shadow parameter - return address on stack
329329
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826
330330
if (@call(.{ .modifier = .never_tail }, system.dlsym, .{ self.handle, name.ptr })) |symbol| {

0 commit comments

Comments
 (0)