elf: fix typo in initial section offsets

This commit is contained in:
Jakub Konka 2023-11-11 07:47:17 +01:00 committed by Jacob Young
parent aa0fbbcb39
commit b48baeeebb
3 changed files with 7 additions and 4 deletions

View File

@ -4531,7 +4531,10 @@ fn allocateAllocSectionsObject(self: *Elf) !void {
for (self.shdrs.items) |*shdr| {
if (shdr.sh_type == elf.SHT_NULL) continue;
if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;
if (shdr.sh_type == elf.SHT_NOBITS) continue;
if (shdr.sh_type == elf.SHT_NOBITS) {
shdr.sh_offset = 0;
continue;
}
const needed_size = shdr.sh_size;
if (needed_size > self.allocatedSize(shdr.sh_offset)) {
shdr.sh_size = 0;

View File

@ -251,7 +251,7 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem
.type = @"type",
.flags = flags,
.name = name,
.offset = std.math.maxInt(u32),
.offset = std.math.maxInt(u64),
});
return out_shndx;
}

View File

@ -749,14 +749,14 @@ fn getDeclShdrIndex(
.type = elf.SHT_NOBITS,
.flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
.name = ".tbss",
.offset = std.math.maxInt(u32),
.offset = std.math.maxInt(u64),
});
break :blk elf_file.sectionByName(".tdata") orelse try elf_file.addSection(.{
.type = elf.SHT_PROGBITS,
.flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
.name = ".tdata",
.offset = std.math.maxInt(u32),
.offset = std.math.maxInt(u64),
});
}
if (variable.is_const) break :blk elf_file.zig_data_rel_ro_section_index.?;