Skip to content

Commit

Permalink
link/Elf.zig: ensure capacity before appending linker args.
Browse files Browse the repository at this point in the history
fixes e567abb "rework linker inputs"
closes #21801
  • Loading branch information
xxxbxxx authored and alexrp committed Oct 26, 2024
1 parent b1361f2 commit 6a364b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/link/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
if (is_exe_or_dyn_lib) {
// Worst-case, we need an --as-needed argument for every lib, as well
// as one before and one after.
try argv.append("--as-needed");
try argv.ensureUnusedCapacity(2 * self.base.comp.link_inputs.len + 2);
argv.appendAssumeCapacity("--as-needed");
var as_needed = true;

for (self.base.comp.link_inputs) |link_input| switch (link_input) {
Expand Down

0 comments on commit 6a364b4

Please sign in to comment.