zld: merge and sort sections

This commit is contained in:
Jakub Konka 2021-03-01 00:16:01 +01:00
parent 44ebf48631
commit b0ee480177
3 changed files with 593 additions and 265 deletions

View File

@ -1227,6 +1227,24 @@ pub const S_ATTR_EXT_RELOC = 0x200;
/// section has local relocation entries
pub const S_ATTR_LOC_RELOC = 0x100;
/// template of initial values for TLVs
pub const S_THREAD_LOCAL_REGULAR = 0x11;
/// template of initial values for TLVs
pub const S_THREAD_LOCAL_ZEROFILL = 0x12;
/// TLV descriptors
pub const S_THREAD_LOCAL_VARIABLES = 0x13;
/// pointers to TLV descriptors
pub const S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14;
/// functions to call to initialize TLV values
pub const S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15;
/// 32-bit offsets to initializers
pub const S_INIT_FUNC_OFFSETS = 0x16;
pub const cpu_type_t = integer_t;
pub const cpu_subtype_t = integer_t;
pub const integer_t = c_int;

View File

@ -24,9 +24,9 @@ segment_cmd_index: ?u16 = null,
symtab_cmd_index: ?u16 = null,
dysymtab_cmd_index: ?u16 = null,
build_version_cmd_index: ?u16 = null,
text_section_index: ?u16 = null,
// __DWARF segment sections
dwarf_debug_info_index: ?u16 = null,
dwarf_debug_abbrev_index: ?u16 = null,
dwarf_debug_str_index: ?u16 = null,
@ -36,13 +36,6 @@ dwarf_debug_ranges_index: ?u16 = null,
symtab: std.ArrayListUnmanaged(macho.nlist_64) = .{},
strtab: std.ArrayListUnmanaged(u8) = .{},
directory: std.AutoHashMapUnmanaged(DirectoryKey, u16) = .{},
pub const DirectoryKey = struct {
segname: [16]u8,
sectname: [16]u8,
};
pub fn deinit(self: *Object) void {
for (self.load_commands.items) |*lc| {
lc.deinit(self.allocator);
@ -50,7 +43,6 @@ pub fn deinit(self: *Object) void {
self.load_commands.deinit(self.allocator);
self.symtab.deinit(self.allocator);
self.strtab.deinit(self.allocator);
self.directory.deinit(self.allocator);
self.allocator.free(self.name);
self.file.close();
}
@ -138,11 +130,6 @@ pub fn readLoadCommands(self: *Object, reader: anytype, offset: ReadOffset) !voi
}
}
try self.directory.putNoClobber(self.allocator, .{
.segname = sect.segname,
.sectname = sect.sectname,
}, index);
sect.offset += offset_mod;
if (sect.reloff > 0)
sect.reloff += offset_mod;

File diff suppressed because it is too large Load Diff