authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-26 13:54:31+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-27 10:00:20+02:00
loge178580d864407864ebb4d95bb28b041b7b0870a
treeec0324d160ce5d559d27b840269f68a6aee18fd5
parent1200a5a2401cd4a13d818499f9d534c0051c3724

elf: pre-allocate large VM capacity per segment


1 files changed, 2 insertions(+), 5 deletions(-)

src/link/Elf.zig+2-5
...@@ -426,7 +426,8 @@ pub fn allocateSegment(self: *Elf, opts: AllocateSegmentOpts) error{OutOfMemory}...@@ -426,7 +426,8 @@ pub fn allocateSegment(self: *Elf, opts: AllocateSegmentOpts) error{OutOfMemory}
426 const addr = blk: {426 const addr = blk: {
427 assert(self.phdr_table_load_index != null);427 assert(self.phdr_table_load_index != null);
428 const phdr = &self.phdrs.items[index - 1];428 const phdr = &self.phdrs.items[index - 1];
429 break :blk mem.alignForward(u64, phdr.p_vaddr + phdr.p_memsz, opts.alignment);429 const increased_size = padToIdeal(phdr.p_vaddr + phdr.p_memsz);
430 break :blk mem.alignForward(u64, increased_size, opts.alignment);
430 };431 };
431 log.debug("allocating phdr({d})({c}{c}{c}) from 0x{x} to 0x{x} (0x{x} - 0x{x})", .{432 log.debug("allocating phdr({d})({c}{c}{c}) from 0x{x} to 0x{x} (0x{x} - 0x{x})", .{
432 index,433 index,
...@@ -1186,10 +1187,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -1186,10 +1187,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
1186 // Scan and create missing synthetic entries such as GOT indirection.1187 // Scan and create missing synthetic entries such as GOT indirection.
1187 try self.scanRelocs();1188 try self.scanRelocs();
11881189
1189 if (build_options.enable_logging) {
1190 state_log.debug("{}", .{self.dumpState()});
1191 }
1192
1193 // Allocate atoms parsed from input object files, followed by allocating1190 // Allocate atoms parsed from input object files, followed by allocating
1194 // linker-defined synthetic symbols.1191 // linker-defined synthetic symbols.
1195 try self.allocateObjects();1192 try self.allocateObjects();