| ... | ... | @@ -18,7 +18,7 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]co |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | for (positionals.items) |obj| { |
| 21 | | parsePositional(elf_file, obj.path) catch |err| switch (err) { |
| 21 | parsePositionalStaticLib(elf_file, obj.path) catch |err| switch (err) { |
| 22 | 22 | error.MalformedObject, |
| 23 | 23 | error.MalformedArchive, |
| 24 | 24 | error.InvalidMachineType, |
| ... | ... | @@ -38,17 +38,12 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]co |
| 38 | 38 | // First, we flush relocatable object file generated with our backends. |
| 39 | 39 | if (elf_file.zigObjectPtr()) |zig_object| { |
| 40 | 40 | try zig_object.resolveSymbols(elf_file); |
| 41 | elf_file.markEhFrameAtomsDead(); |
| 41 | 42 | try elf_file.addCommentString(); |
| 42 | 43 | try elf_file.finalizeMergeSections(); |
| 43 | 44 | zig_object.claimUnresolvedRelocatable(elf_file); |
| 44 | 45 | |
| 45 | | for (elf_file.merge_sections.items) |*msec| { |
| 46 | | if (msec.finalized_subsections.items.len == 0) continue; |
| 47 | | try msec.initOutputSection(elf_file); |
| 48 | | } |
| 49 | | |
| 50 | | try elf_file.initSymtab(); |
| 51 | | try elf_file.initShStrtab(); |
| 46 | try initSections(elf_file); |
| 52 | 47 | try elf_file.sortShdrs(); |
| 53 | 48 | try zig_object.addAtomsToRelaSections(elf_file); |
| 54 | 49 | try elf_file.updateMergeSectionSizes(); |
| ... | ... | @@ -229,17 +224,17 @@ pub fn flushObject(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]const |
| 229 | 224 | if (elf_file.base.hasErrors()) return error.FlushFailure; |
| 230 | 225 | } |
| 231 | 226 | |
| 232 | | fn parsePositional(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 227 | fn parsePositionalStaticLib(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 233 | 228 | if (try Object.isObject(path)) { |
| 234 | | try parseObject(elf_file, path); |
| 229 | try parseObjectStaticLib(elf_file, path); |
| 235 | 230 | } else if (try Archive.isArchive(path)) { |
| 236 | | try parseArchive(elf_file, path); |
| 231 | try parseArchiveStaticLib(elf_file, path); |
| 237 | 232 | } else return error.UnknownFileType; |
| 238 | 233 | // TODO: should we check for LD script? |
| 239 | 234 | // Actually, should we even unpack an archive? |
| 240 | 235 | } |
| 241 | 236 | |
| 242 | | fn parseObject(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 237 | fn parseObjectStaticLib(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 243 | 238 | const gpa = elf_file.base.comp.gpa; |
| 244 | 239 | const handle = try std.fs.cwd().openFile(path, .{}); |
| 245 | 240 | const fh = try elf_file.addFileHandle(handle); |
| ... | ... | @@ -256,7 +251,7 @@ fn parseObject(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 256 | 251 | try object.parseAr(elf_file); |
| 257 | 252 | } |
| 258 | 253 | |
| 259 | | fn parseArchive(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 254 | fn parseArchiveStaticLib(elf_file: *Elf, path: []const u8) Elf.ParseError!void { |
| 260 | 255 | const gpa = elf_file.base.comp.gpa; |
| 261 | 256 | const handle = try std.fs.cwd().openFile(path, .{}); |
| 262 | 257 | const fh = try elf_file.addFileHandle(handle); |