| ... | ... | @@ -199,7 +199,7 @@ pub const Node = union(enum) { |
| 199 | 199 | relocation_table: Symbol.SectionNumber, |
| 200 | 200 | relocation_table_entry: Reloc.Index, |
| 201 | 201 | |
| 202 | | image_section: Symbol.Index, // TODO: rename image_section -> section |
| 202 | image_section: Symbol.Index, |
| 203 | 203 | |
| 204 | 204 | /// Images only |
| 205 | 205 | import_directory_table, |
| ... | ... | @@ -603,7 +603,7 @@ pub const LongNamesTable = struct { |
| 603 | 603 | coff: *Coff, |
| 604 | 604 | |
| 605 | 605 | pub fn eql(adapter: Adapter, lhs_key: []const u8, _: void, rhs_index: usize) bool { |
| 606 | | assert(adapter.coff.isArchive()); // TODO: move to helper that uses this |
| 606 | assert(adapter.coff.isArchive()); |
| 607 | 607 | const longnames_slice = Node.known.longnames_member.slice(&adapter.coff.mf); |
| 608 | 608 | const rhs = adapter.coff.long_names_table.entries.values()[rhs_index]; |
| 609 | 609 | return std.mem.eql(u8, longnames_slice[rhs.offset..][0..rhs.len], lhs_key); |
| ... | ... | @@ -763,7 +763,6 @@ pub const ImportTable = struct { |
| 763 | 763 | }; |
| 764 | 764 | |
| 765 | 765 | pub const String = enum(u32) { |
| 766 | | // TODO: Re-order |
| 767 | 766 | @".data" = 0, |
| 768 | 767 | @".idata" = 6, |
| 769 | 768 | @".rdata" = 13, |
| ... | ... | @@ -943,7 +942,6 @@ pub const Symbol = struct { |
| 943 | 942 | // The size of the symbol |
| 944 | 943 | size: u32, |
| 945 | 944 | /// Only valid when .ni == .input_section and .value_tag == .node_offset |
| 946 | | /// TODO: This is only used for name lookups, could just be String, remove `input_symbols`? |
| 947 | 945 | isli: Node.InputSection.LocalIndex, |
| 948 | 946 | /// The next symbol in the list of aliases of this symbol. |
| 949 | 947 | next_alias_si: Symbol.Index, |
| ... | ... | @@ -2919,7 +2917,6 @@ fn addMemberAssumeCapacity(coff: *Coff, kind: std.coff.ArchiveMemberHeader.Kind, |
| 2919 | 2917 | const gpa = comp.gpa; |
| 2920 | 2918 | |
| 2921 | 2919 | // TODO: These two nodes could to be inside a movable node if kind == .coff|.import |
| 2922 | | |
| 2923 | 2920 | const header_ni = try coff.mf.addLastChildNode(gpa, Node.known.file, .{ |
| 2924 | 2921 | .size = @sizeOf(std.coff.ArchiveMemberHeader), |
| 2925 | 2922 | .alignment = .@"2", |
| ... | ... | @@ -3573,7 +3570,6 @@ fn objectSectionMapIndex( |
| 3573 | 3570 | return osmi; |
| 3574 | 3571 | } |
| 3575 | 3572 | |
| 3576 | | // TODO: Include align in attrs and verify the current align is >= requested |
| 3577 | 3573 | fn verifyParentSectionAttributes( |
| 3578 | 3574 | coff: *Coff, |
| 3579 | 3575 | parent: Symbol.SectionNumber, |
| ... | ... | @@ -3727,7 +3723,7 @@ fn addRelocAssumeCapacity( |
| 3727 | 3723 | if (coff.symbolTableSectionAuxEntryPtr(loc_sn.symbol(coff).sti(coff))) |aux_ptr| |
| 3728 | 3724 | coff.targetStore(&aux_ptr.number_of_relocations, new_num_relocations); |
| 3729 | 3725 | |
| 3730 | | // TODO: These need to allocate from a free list (once deleting relocs is supported) (or can we just remove swap?) |
| 3726 | // TODO: These need to allocate from a free list, once deleting relocs is supported |
| 3731 | 3727 | const sri: Section.RelocationIndex = .wrap(old_num_relocations); |
| 3732 | 3728 | const entry = sri.entry(coff, loc_sn).?; |
| 3733 | 3729 | if (sti.unwrap()) |index| coff.targetStore(&entry.symbol_table_index, index); |
| ... | ... | @@ -4509,7 +4505,7 @@ fn loadObject( |
| 4509 | 4505 | }); |
| 4510 | 4506 | |
| 4511 | 4507 | // TODO: What if the same symbol is incorrectly defined twice in this obj? |
| 4512 | | // TODO: Would need to mark this global as pending, or notice it later when .ni != none |
| 4508 | // Would need to mark this global as pending, or notice it later when .ni != none |
| 4513 | 4509 | if (!global_gop.found_existing or global_gop.value_ptr.get(coff).ni == .none) { |
| 4514 | 4510 | symbol.si = global_gop.value_ptr.*; |
| 4515 | 4511 | break :comdat .include; |
| ... | ... | @@ -4554,9 +4550,7 @@ fn loadObject( |
| 4554 | 4550 | const sym = si.get(coff); |
| 4555 | 4551 | const existing_crc = switch (coff.getNode(sym.ni)) { |
| 4556 | 4552 | .input_section => |isi| isi.inputSection(coff).crc, |
| 4557 | | // TODO: Should this result be cached somewhere? |
| 4558 | | // TODO: Is this slice triggering has_content = true un-necessarily? Check section for init data flag. |
| 4559 | | else => std.hash.crc.Crc32Jamcrc.hash(sym.ni.slice(&coff.mf)), |
| 4553 | else => std.hash.crc.Crc32Jamcrc.hash(sym.ni.sliceConst(&coff.mf)), |
| 4560 | 4554 | }; |
| 4561 | 4555 | |
| 4562 | 4556 | if (existing_crc == section.comdat_crc) { |
| ... | ... | @@ -4611,7 +4605,7 @@ fn loadObject( |
| 4611 | 4605 | .pending => unreachable, |
| 4612 | 4606 | } |
| 4613 | 4607 | |
| 4614 | | // TODO: Until we support sorting .pdata, we shouldn't merge these in, the result would be invalid |
| 4608 | // Until we support sorting .pdata, we shouldn't merge these in, the result would be invalid |
| 4615 | 4609 | const section_name = section.name.toSlice(coff); |
| 4616 | 4610 | if (std.mem.startsWith(u8, section_name, ".pdata")) |
| 4617 | 4611 | continue; |
| ... | ... | @@ -4995,7 +4989,6 @@ fn parseArchiveMemberHeader( |
| 4995 | 4989 | }; |
| 4996 | 4990 | } |
| 4997 | 4991 | |
| 4998 | | // TODO: Move to std.coff? |
| 4999 | 4992 | fn parseArchiveMemberHeaderInner( |
| 5000 | 4993 | header: *const std.coff.ArchiveMemberHeader, |
| 5001 | 4994 | opt_longnames: ?[]const u8, |
| ... | ... | @@ -5274,7 +5267,6 @@ fn loadArchive(coff: *Coff, path: std.Build.Cache.Path, fr: *Io.File.Reader) Loa |
| 5274 | 5267 | }; |
| 5275 | 5268 | } else { |
| 5276 | 5269 | member.content.object.size = res.size; |
| 5277 | | // TODO: If .UNKNOWN assert later that it contains no non-undef symbols? |
| 5278 | 5270 | // Microsoft's CRT contains members that set .UNKNOWN but do have undef symbols |
| 5279 | 5271 | if (machine != expected_machine and machine != .UNKNOWN) { |
| 5280 | 5272 | return diags.failParse(path, "machine mismatch in member header '{s}': expected {t}, found {t}", .{ |
| ... | ... | @@ -5859,7 +5851,6 @@ pub fn flush( |
| 5859 | 5851 | if (coff.isImage()) |
| 5860 | 5852 | try coff.reportUndefs(tid); |
| 5861 | 5853 | |
| 5862 | | // Implib generation should instead be done via building a MappedFile progressively |
| 5863 | 5854 | if (comp.emit_implib) |implib_file| |
| 5864 | 5855 | coff.flushImplib(implib_file) catch |err| |
| 5865 | 5856 | return comp.link_diags.fail("flushing implib '{s}' failed: {t}", .{ implib_file, err }); |
| ... | ... | @@ -6080,9 +6071,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6080 | 6071 | try coff.flushMember(pending_mi.key); |
| 6081 | 6072 | break :task; |
| 6082 | 6073 | } |
| 6083 | | // TODO: All the sort / shrink tasks ideally run only once - otherwise it's wasteful |
| 6084 | | // Defer until exports_complete? |
| 6085 | | if (coff.export_table.pending_sort) { |
| 6074 | if (coff.exports_complete and coff.export_table.pending_sort) { |
| 6086 | 6075 | defer coff.export_table.pending_sort = false; |
| 6087 | 6076 | const sub_prog_node = coff.idleProgNode( |
| 6088 | 6077 | tid, |
| ... | ... | @@ -6098,7 +6087,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6098 | 6087 | if (coff.input_sections.items.len > coff.input_section_pending_index) return true; |
| 6099 | 6088 | if (coff.mf.updates.items.len > 0) return true; |
| 6100 | 6089 | if (coff.pending_members.count() > 0) return true; |
| 6101 | | if (coff.export_table.pending_sort) return true; |
| 6090 | if (coff.exports_complete and coff.export_table.pending_sort) return true; |
| 6102 | 6091 | return false; |
| 6103 | 6092 | } |
| 6104 | 6093 | |
| ... | ... | @@ -6578,8 +6567,6 @@ fn flushGlobal(coff: *Coff, gmi: Node.GlobalMapIndex) !bool { |
| 6578 | 6567 | const iat_offset: u32 = @intCast(addr_info.size * iat_symbol_gop.value_ptr.*); |
| 6579 | 6568 | switch (import.kind) { |
| 6580 | 6569 | .iat_ptr => { |
| 6581 | | // TODO: Currently the codegen is wrong for loading the address of these globals, |
| 6582 | | // we generate lea [<iat_ptr>] when it should be mov [<iat_ptr>] |
| 6583 | 6570 | const iat_sym = gop.value_ptr.import_address_table_si.get(coff); |
| 6584 | 6571 | sym.section_number = iat_sym.section_number; |
| 6585 | 6572 | sym.ni = iat_sym.ni; |
| ... | ... | @@ -7166,7 +7153,6 @@ fn flushMember(coff: *Coff, mi: Member.Index) !void { |
| 7166 | 7153 | }; |
| 7167 | 7154 | |
| 7168 | 7155 | // TODO: Does this sort need to also sort by linker input order (if names equal)? |
| 7169 | | |
| 7170 | 7156 | std.sort.pdqContext(0, coff.lib_string_table.items.len, Context{ |
| 7171 | 7157 | .coff = coff, |
| 7172 | 7158 | .indices = coff.secondLinkerMemberIndicesSlice(), |
| ... | ... | @@ -7493,7 +7479,7 @@ pub fn deleteExport(coff: *Coff, exported: Zcu.Exported, name: InternPool.NullTe |
| 7493 | 7479 | _ = exported; |
| 7494 | 7480 | _ = name; |
| 7495 | 7481 | |
| 7496 | | // TODO: Delete from first / second linker member table (remove swap?) |
| 7482 | // TODO: Delete from first / second linker member table |
| 7497 | 7483 | // TODO: Delete from symbol table inside section |
| 7498 | 7484 | } |
| 7499 | 7485 | |
| ... | ... | @@ -7609,7 +7595,6 @@ fn printNodeName( |
| 7609 | 7595 | .input_section => |isi| { |
| 7610 | 7596 | const ioi = isi.input(coff); |
| 7611 | 7597 | const is = isi.inputSection(coff); |
| 7612 | | // TODO: Use only filename from these paths, they are long |
| 7613 | 7598 | try w.print("({f}{f}, {s}", .{ |
| 7614 | 7599 | ioi.path(coff).fmtEscapeString(), |
| 7615 | 7600 | fmtMemberNameString(ioi.memberName(coff)), |