diff options
Diffstat (limited to 'lib/std/dynamic_library.zig')
| -rw-r--r-- | lib/std/dynamic_library.zig | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 8f07db68da..38511f7f29 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -1,6 +1,7 @@ const std = @import("std.zig"); const builtin = @import("builtin"); const mem = std.mem; +const heap = std.heap; const testing = std.testing; const elf = std.elf; const windows = std.os.windows; @@ -143,7 +144,7 @@ pub const ElfDynLib = struct { hashtab: [*]posix.Elf_Symndx, versym: ?[*]elf.Versym, verdef: ?*elf.Verdef, - memory: []align(mem.page_size) u8, + memory: []align(heap.min_page_size) u8, pub const Error = ElfDynLibError; @@ -223,7 +224,7 @@ pub const ElfDynLib = struct { // corresponding to the actual LOAD sections. const file_bytes = try posix.mmap( null, - mem.alignForward(usize, size, mem.page_size), + mem.alignForward(usize, size, heap.pageSize()), posix.PROT.READ, .{ .TYPE = .PRIVATE }, fd, @@ -284,10 +285,10 @@ pub const ElfDynLib = struct { elf.PT_LOAD => { // The VirtAddr may not be page-aligned; in such case there will be // extra nonsense mapped before/after the VirtAddr,MemSiz - const aligned_addr = (base + ph.p_vaddr) & ~(@as(usize, mem.page_size) - 1); + const aligned_addr = (base + ph.p_vaddr) & ~(@as(usize, heap.pageSize()) - 1); const extra_bytes = (base + ph.p_vaddr) - aligned_addr; - const extended_memsz = mem.alignForward(usize, ph.p_memsz + extra_bytes, mem.page_size); - const ptr = @as([*]align(mem.page_size) u8, @ptrFromInt(aligned_addr)); + const extended_memsz = mem.alignForward(usize, ph.p_memsz + extra_bytes, heap.pageSize()); + const ptr = @as([*]align(heap.min_page_size) u8, @ptrFromInt(aligned_addr)); const prot = elfToMmapProt(ph.p_flags); if ((ph.p_flags & elf.PF_W) == 0) { // If it does not need write access, it can be mapped from the fd. |
