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 {...@@ -4531,7 +4531,10 @@ fn allocateAllocSectionsObject(self: *Elf) !void {
4531 for (self.shdrs.items) |*shdr| {4531 for (self.shdrs.items) |*shdr| {
4532 if (shdr.sh_type == elf.SHT_NULL) continue;4532 if (shdr.sh_type == elf.SHT_NULL) continue;
4533 if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;4533 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 }
4535 const needed_size = shdr.sh_size;4538 const needed_size = shdr.sh_size;
4536 if (needed_size > self.allocatedSize(shdr.sh_offset)) {4539 if (needed_size > self.allocatedSize(shdr.sh_offset)) {
4537 shdr.sh_size = 0;4540 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...@@ -251,7 +251,7 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem
251 .type = @"type",251 .type = @"type",
252 .flags = flags,252 .flags = flags,
253 .name = name,253 .name = name,
254 .offset = std.math.maxInt(u32),254 .offset = std.math.maxInt(u64),
255 });255 });
256 return out_shndx;256 return out_shndx;
257}257}
src/link/Elf/ZigObject.zig+2-2
...@@ -749,14 +749,14 @@ fn getDeclShdrIndex(...@@ -749,14 +749,14 @@ fn getDeclShdrIndex(
749 .type = elf.SHT_NOBITS,749 .type = elf.SHT_NOBITS,
750 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,750 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
751 .name = ".tbss",751 .name = ".tbss",
752 .offset = std.math.maxInt(u32),752 .offset = std.math.maxInt(u64),
753 });753 });
754754
755 break :blk elf_file.sectionByName(".tdata") orelse try elf_file.addSection(.{755 break :blk elf_file.sectionByName(".tdata") orelse try elf_file.addSection(.{
756 .type = elf.SHT_PROGBITS,756 .type = elf.SHT_PROGBITS,
757 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,757 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
758 .name = ".tdata",758 .name = ".tdata",
759 .offset = std.math.maxInt(u32),759 .offset = std.math.maxInt(u64),
760 });760 });
761 }761 }
762 if (variable.is_const) break :blk elf_file.zig_data_rel_ro_section_index.?;762 if (variable.is_const) break :blk elf_file.zig_data_rel_ro_section_index.?;