diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 511ce57b3e..62bf6be63a 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1801,7 +1801,6 @@ pub fn initOutputSection(self: *Elf, args: struct { .type = @"type", .flags = flags, .name = try self.insertShString(name), - .offset = std.math.maxInt(u64), }); return out_shndx; } @@ -2867,7 +2866,6 @@ fn initSyntheticSections(self: *Elf) !void { elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC, .addralign = ptr_size, - .offset = std.math.maxInt(u64), }); } if (comp.link_eh_frame_hdr and self.eh_frame_hdr_section_index == null) { @@ -2876,7 +2874,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC, .addralign = 4, - .offset = std.math.maxInt(u64), }); } } @@ -2887,7 +2884,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, .addralign = ptr_size, - .offset = std.math.maxInt(u64), }); } @@ -2897,7 +2893,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, .addralign = @alignOf(u64), - .offset = std.math.maxInt(u64), }); } @@ -2919,7 +2914,6 @@ fn initSyntheticSections(self: *Elf) !void { .flags = elf.SHF_ALLOC, .addralign = @alignOf(elf.Elf64_Rela), .entsize = @sizeOf(elf.Elf64_Rela), - .offset = std.math.maxInt(u64), }); } @@ -2930,7 +2924,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR, .addralign = 16, - .offset = std.math.maxInt(u64), }); } if (self.rela_plt_section_index == null) { @@ -2940,7 +2933,6 @@ fn initSyntheticSections(self: *Elf) !void { .flags = elf.SHF_ALLOC, .addralign = @alignOf(elf.Elf64_Rela), .entsize = @sizeOf(elf.Elf64_Rela), - .offset = std.math.maxInt(u64), }); } } @@ -2951,7 +2943,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR, .addralign = 16, - .offset = std.math.maxInt(u64), }); } @@ -2960,7 +2951,6 @@ fn initSyntheticSections(self: *Elf) !void { .name = try self.insertShString(".copyrel"), .type = elf.SHT_NOBITS, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, - .offset = std.math.maxInt(u64), }); } @@ -2979,7 +2969,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC, .addralign = 1, - .offset = std.math.maxInt(u64), }); } @@ -2991,7 +2980,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_STRTAB, .entsize = 1, .addralign = 1, - .offset = std.math.maxInt(u64), }); } if (self.dynamic_section_index == null) { @@ -3001,7 +2989,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_DYNAMIC, .entsize = @sizeOf(elf.Elf64_Dyn), .addralign = @alignOf(elf.Elf64_Dyn), - .offset = std.math.maxInt(u64), }); } if (self.dynsymtab_section_index == null) { @@ -3012,7 +2999,6 @@ fn initSyntheticSections(self: *Elf) !void { .addralign = @alignOf(elf.Elf64_Sym), .entsize = @sizeOf(elf.Elf64_Sym), .info = 1, - .offset = std.math.maxInt(u64), }); } if (self.hash_section_index == null) { @@ -3022,7 +3008,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_HASH, .addralign = 4, .entsize = 4, - .offset = std.math.maxInt(u64), }); } if (self.gnu_hash_section_index == null) { @@ -3031,7 +3016,6 @@ fn initSyntheticSections(self: *Elf) !void { .flags = elf.SHF_ALLOC, .type = elf.SHT_GNU_HASH, .addralign = 8, - .offset = std.math.maxInt(u64), }); } @@ -3047,7 +3031,6 @@ fn initSyntheticSections(self: *Elf) !void { .type = elf.SHT_GNU_VERSYM, .addralign = @alignOf(elf.Elf64_Versym), .entsize = @sizeOf(elf.Elf64_Versym), - .offset = std.math.maxInt(u64), }); } if (self.verneed_section_index == null) { @@ -3056,7 +3039,6 @@ fn initSyntheticSections(self: *Elf) !void { .flags = elf.SHF_ALLOC, .type = elf.SHT_GNU_VERNEED, .addralign = @alignOf(elf.Elf64_Verneed), - .offset = std.math.maxInt(u64), }); } } @@ -3077,7 +3059,6 @@ pub fn initSymtab(self: *Elf) !void { .type = elf.SHT_SYMTAB, .addralign = if (small_ptr) @alignOf(elf.Elf32_Sym) else @alignOf(elf.Elf64_Sym), .entsize = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym), - .offset = std.math.maxInt(u64), }); } if (self.strtab_section_index == null) { @@ -3086,7 +3067,6 @@ pub fn initSymtab(self: *Elf) !void { .type = elf.SHT_STRTAB, .entsize = 1, .addralign = 1, - .offset = std.math.maxInt(u64), }); } } @@ -3098,7 +3078,6 @@ pub fn initShStrtab(self: *Elf) !void { .type = elf.SHT_STRTAB, .entsize = 1, .addralign = 1, - .offset = std.math.maxInt(u64), }); } } @@ -4760,7 +4739,6 @@ pub fn addRelaShdr(self: *Elf, name: u32, shndx: u32) !u32 { .entsize = entsize, .info = shndx, .addralign = addralign, - .offset = std.math.maxInt(u64), }); } @@ -4772,7 +4750,6 @@ pub const AddSectionOpts = struct { info: u32 = 0, addralign: u64 = 0, entsize: u64 = 0, - offset: u64 = 0, }; pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 { @@ -4784,7 +4761,7 @@ pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 { .sh_type = opts.type, .sh_flags = opts.flags, .sh_addr = 0, - .sh_offset = opts.offset, + .sh_offset = 0, .sh_size = 0, .sh_link = opts.link, .sh_info = opts.info, diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 0901920ee5..846bcac15c 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -130,7 +130,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .entsize = 1, .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_str_section_dirty = true; self.debug_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_str", .@"1", osec); @@ -141,7 +140,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_info"), .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_info_section_dirty = true; self.debug_info_index = try addSectionSymbolWithAtom(self, gpa, ".debug_info", .@"1", osec); @@ -152,7 +150,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_abbrev"), .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_abbrev_section_dirty = true; self.debug_abbrev_index = try addSectionSymbolWithAtom(self, gpa, ".debug_abbrev", .@"1", osec); @@ -163,7 +160,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_aranges"), .type = elf.SHT_PROGBITS, .addralign = 16, - .offset = std.math.maxInt(u64), }); self.debug_aranges_section_dirty = true; self.debug_aranges_index = try addSectionSymbolWithAtom(self, gpa, ".debug_aranges", .@"16", osec); @@ -174,7 +170,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_line"), .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_line_section_dirty = true; self.debug_line_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line", .@"1", osec); @@ -187,7 +182,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .entsize = 1, .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_line_str_section_dirty = true; self.debug_line_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line_str", .@"1", osec); @@ -198,7 +192,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_loclists"), .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_loclists_section_dirty = true; self.debug_loclists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_loclists", .@"1", osec); @@ -209,7 +202,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { .name = try elf_file.insertShString(".debug_rnglists"), .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.debug_rnglists_section_dirty = true; self.debug_rnglists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_rnglists", .@"1", osec); @@ -224,7 +216,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void { elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC, .addralign = ptr_size, - .offset = std.math.maxInt(u64), }); self.eh_frame_section_dirty = true; self.eh_frame_index = try addSectionSymbolWithAtom(self, gpa, ".eh_frame", Atom.Alignment.fromNonzeroByteUnits(ptr_size), osec); @@ -1026,7 +1017,6 @@ pub fn lowerUav( .type = elf.SHT_PROGBITS, .addralign = 1, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, - .offset = std.math.maxInt(u64), }); self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec); break :osec osec; @@ -1166,7 +1156,6 @@ fn getNavShdrIndex( .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR, .name = try elf_file.insertShString(".text"), .addralign = 1, - .offset = std.math.maxInt(u64), }); self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec); return osec; @@ -1200,7 +1189,6 @@ fn getNavShdrIndex( .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS, .name = try elf_file.insertShString(".tdata"), .addralign = 1, - .offset = std.math.maxInt(u64), }); self.tdata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".tdata"), osec); return osec; @@ -1213,7 +1201,6 @@ fn getNavShdrIndex( .type = elf.SHT_PROGBITS, .addralign = 1, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, - .offset = std.math.maxInt(u64), }); self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec); return osec; @@ -1228,7 +1215,6 @@ fn getNavShdrIndex( .type = elf.SHT_PROGBITS, .addralign = ptr_size, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, - .offset = std.math.maxInt(u64), }); self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec); return osec; @@ -1268,7 +1254,6 @@ fn getNavShdrIndex( .type = elf.SHT_PROGBITS, .addralign = ptr_size, .flags = elf.SHF_ALLOC | elf.SHF_WRITE, - .offset = std.math.maxInt(u64), }); self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec); return osec; @@ -1521,7 +1506,6 @@ pub fn updateFunc( .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR, .type = elf.SHT_PROGBITS, .addralign = 1, - .offset = std.math.maxInt(u64), }); self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec); break :osec osec; @@ -1697,7 +1681,6 @@ fn updateLazySymbol( .type = elf.SHT_PROGBITS, .addralign = 1, .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR, - .offset = std.math.maxInt(u64), }); self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec); break :osec osec; @@ -1710,7 +1693,6 @@ fn updateLazySymbol( .type = elf.SHT_PROGBITS, .addralign = 1, .flags = elf.SHF_ALLOC, - .offset = std.math.maxInt(u64), }); self.rodata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".rodata"), osec); break :osec osec; diff --git a/src/link/Elf/relocatable.zig b/src/link/Elf/relocatable.zig index b9f065a2ab..8768c1d754 100644 --- a/src/link/Elf/relocatable.zig +++ b/src/link/Elf/relocatable.zig @@ -295,7 +295,6 @@ fn initSections(elf_file: *Elf) !void { elf.SHT_PROGBITS, .flags = elf.SHF_ALLOC, .addralign = elf_file.ptrWidthBytes(), - .offset = std.math.maxInt(u64), }); } elf_file.eh_frame_rela_section_index = elf_file.sectionByName(".rela.eh_frame") orelse @@ -324,7 +323,6 @@ fn initComdatGroups(elf_file: *Elf) !void { .type = elf.SHT_GROUP, .entsize = @sizeOf(u32), .addralign = @alignOf(u32), - .offset = std.math.maxInt(u64), }), .cg_ref = .{ .index = @intCast(cg_index), .file = index }, };