Commit e178580d86

Jakub Konka <kubkon@jakubkonka.com>
2023-09-26 13:54:31
elf: pre-allocate large VM capacity per segment
1 parent 1200a5a
Changed files (1)
src
link
src/link/Elf.zig
@@ -426,7 +426,8 @@ pub fn allocateSegment(self: *Elf, opts: AllocateSegmentOpts) error{OutOfMemory}
     const addr = blk: {
         assert(self.phdr_table_load_index != null);
         const phdr = &self.phdrs.items[index - 1];
-        break :blk mem.alignForward(u64, phdr.p_vaddr + phdr.p_memsz, opts.alignment);
+        const increased_size = padToIdeal(phdr.p_vaddr + phdr.p_memsz);
+        break :blk mem.alignForward(u64, increased_size, opts.alignment);
     };
     log.debug("allocating phdr({d})({c}{c}{c}) from 0x{x} to 0x{x} (0x{x} - 0x{x})", .{
         index,
@@ -1186,10 +1187,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
     // Scan and create missing synthetic entries such as GOT indirection.
     try self.scanRelocs();
 
-    if (build_options.enable_logging) {
-        state_log.debug("{}", .{self.dumpState()});
-    }
-
     // Allocate atoms parsed from input object files, followed by allocating
     // linker-defined synthetic symbols.
     try self.allocateObjects();