authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-11 07:47:17+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-12 18:12:41-05:00
logb48baeeebbec2f5d06f8ffc5305d2994d8389a72
treebec95d339f8fd6c36676d36eac414000a22133c5
parentaa0fbbcb3917ac988757263e064540e1be3402eb

elf: fix typo in initial section offsets


3 files changed, 7 insertions(+), 4 deletions(-)

src/link/Elf.zig+4-1
......@@ -4531,7 +4531,10 @@ fn allocateAllocSectionsObject(self: *Elf) !void {
45314531 for (self.shdrs.items) |*shdr| {
45324532 if (shdr.sh_type == elf.SHT_NULL) continue;
45334533 if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;
4534 if (shdr.sh_type == elf.SHT_NOBITS) continue;
4534 if (shdr.sh_type == elf.SHT_NOBITS) {
4535 shdr.sh_offset = 0;
4536 continue;
4537 }
45354538 const needed_size = shdr.sh_size;
45364539 if (needed_size > self.allocatedSize(shdr.sh_offset)) {
45374540 shdr.sh_size = 0;
src/link/Elf/Object.zig+1-1
......@@ -251,7 +251,7 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem
251251 .type = @"type",
252252 .flags = flags,
253253 .name = name,
254 .offset = std.math.maxInt(u32),
254 .offset = std.math.maxInt(u64),
255255 });
256256 return out_shndx;
257257}
src/link/Elf/ZigObject.zig+2-2
......@@ -749,14 +749,14 @@ fn getDeclShdrIndex(
749749 .type = elf.SHT_NOBITS,
750750 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
751751 .name = ".tbss",
752 .offset = std.math.maxInt(u32),
752 .offset = std.math.maxInt(u64),
753753 });
754754
755755 break :blk elf_file.sectionByName(".tdata") orelse try elf_file.addSection(.{
756756 .type = elf.SHT_PROGBITS,
757757 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
758758 .name = ".tdata",
759 .offset = std.math.maxInt(u32),
759 .offset = std.math.maxInt(u64),
760760 });
761761 }
762762 if (variable.is_const) break :blk elf_file.zig_data_rel_ro_section_index.?;