| ... | ... | @@ -29,6 +29,10 @@ page_size: ?u16 = null, |
| 29 | 29 | file: ?fs.File = null, |
| 30 | 30 | out_path: ?[]const u8 = null, |
| 31 | 31 | |
| 32 | // TODO these args will become obselete once Zld is coalesced with incremental |
| 33 | // linker. |
| 34 | stack_size: u64 = 0, |
| 35 | |
| 32 | 36 | objects: std.ArrayListUnmanaged(*Object) = .{}, |
| 33 | 37 | archives: std.ArrayListUnmanaged(*Archive) = .{}, |
| 34 | 38 | |
| ... | ... | @@ -172,7 +176,11 @@ pub fn closeFiles(self: Zld) void { |
| 172 | 176 | if (self.file) |f| f.close(); |
| 173 | 177 | } |
| 174 | 178 | |
| 175 | | pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8) !void { |
| 179 | const LinkArgs = struct { |
| 180 | stack_size: ?u64 = null, |
| 181 | }; |
| 182 | |
| 183 | pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8, args: LinkArgs) !void { |
| 176 | 184 | if (files.len == 0) return error.NoInputFiles; |
| 177 | 185 | if (out_path.len == 0) return error.EmptyOutputPath; |
| 178 | 186 | |
| ... | ... | @@ -206,6 +214,7 @@ pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8) !void { |
| 206 | 214 | .read = true, |
| 207 | 215 | .mode = if (std.Target.current.os.tag == .windows) 0 else 0o777, |
| 208 | 216 | }); |
| 217 | self.stack_size = args.stack_size orelse 0; |
| 209 | 218 | |
| 210 | 219 | try self.populateMetadata(); |
| 211 | 220 | try self.parseInputFiles(files); |
| ... | ... | @@ -2204,6 +2213,7 @@ fn setEntryPoint(self: *Zld) !void { |
| 2204 | 2213 | const entry_sym = sym.cast(Symbol.Regular) orelse unreachable; |
| 2205 | 2214 | const ec = &self.load_commands.items[self.main_cmd_index.?].Main; |
| 2206 | 2215 | ec.entryoff = @intCast(u32, entry_sym.address - seg.inner.vmaddr); |
| 2216 | ec.stacksize = self.stack_size; |
| 2207 | 2217 | } |
| 2208 | 2218 | |
| 2209 | 2219 | fn writeRebaseInfoTable(self: *Zld) !void { |