diff options
Diffstat (limited to 'lib/std/dynamic_library.zig')
| -rw-r--r-- | lib/std/dynamic_library.zig | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 38511f7f29..b31fa5ea4d 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -1,7 +1,6 @@ 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; @@ -144,7 +143,7 @@ pub const ElfDynLib = struct { hashtab: [*]posix.Elf_Symndx, versym: ?[*]elf.Versym, verdef: ?*elf.Verdef, - memory: []align(heap.min_page_size) u8, + memory: []align(std.heap.page_size_min) u8, pub const Error = ElfDynLibError; @@ -220,11 +219,13 @@ pub const ElfDynLib = struct { const stat = try file.stat(); const size = std.math.cast(usize, stat.size) orelse return error.FileTooBig; + const page_size = std.heap.pageSize(); + // This one is to read the ELF info. We do more mmapping later // corresponding to the actual LOAD sections. const file_bytes = try posix.mmap( null, - mem.alignForward(usize, size, heap.pageSize()), + mem.alignForward(usize, size, page_size), posix.PROT.READ, .{ .TYPE = .PRIVATE }, fd, @@ -285,10 +286,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, heap.pageSize()) - 1); + const aligned_addr = (base + ph.p_vaddr) & ~(@as(usize, page_size) - 1); const extra_bytes = (base + ph.p_vaddr) - 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 extended_memsz = mem.alignForward(usize, ph.p_memsz + extra_bytes, page_size); + const ptr = @as([*]align(std.heap.page_size_min) 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. |
