Commit 4931a291f8
Changed files (4)
src/link/Elf/merge_section.zig
@@ -168,6 +168,7 @@ pub const MergeSubsection = struct {
string_index: u32 = 0,
size: u32 = 0,
alignment: Atom.Alignment = .@"1",
+ entsize: u32 = 0,
alive: bool = false,
pub fn address(msub: MergeSubsection, elf_file: *Elf) i64 {
src/link/Elf/Object.zig
@@ -759,6 +759,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void {
msub.string_index = res.key.pos;
msub.alignment = atom_ptr.alignment;
msub.size = res.key.len;
+ msub.entsize = math.cast(u32, isec.sh_entsize) orelse return error.Overflow;
msub.alive = !elf_file.base.gc_sections or isec.sh_flags & elf.SHF_ALLOC == 0;
res.sub.* = msub_index;
}
src/link/Elf/relocatable.zig
@@ -289,6 +289,14 @@ fn initSections(elf_file: *Elf) !void {
.flags = msec.flags,
});
msec.output_section_index = shndx;
+
+ var entsize = elf_file.mergeSubsection(msec.subsections.items[0]).entsize;
+ for (msec.subsections.items) |index| {
+ const msub = elf_file.mergeSubsection(index);
+ entsize = @min(entsize, msub.entsize);
+ }
+ const shdr = &elf_file.shdrs.items[shndx];
+ shdr.sh_entsize = entsize;
}
const needs_eh_frame = for (elf_file.objects.items) |index| {
src/link/Elf.zig
@@ -3337,6 +3337,7 @@ pub fn addCommentString(self: *Elf) !void {
msub.string_index = res.key.pos;
msub.alignment = .@"1";
msub.size = res.key.len;
+ msub.entsize = 1;
msub.alive = true;
res.sub.* = msub_index;
}
@@ -3428,6 +3429,14 @@ fn initOutputSections(self: *Elf) !void {
.flags = msec.flags,
});
msec.output_section_index = shndx;
+
+ var entsize = self.mergeSubsection(msec.subsections.items[0]).entsize;
+ for (msec.subsections.items) |index| {
+ const msub = self.mergeSubsection(index);
+ entsize = @min(entsize, msub.entsize);
+ }
+ const shdr = &self.shdrs.items[shndx];
+ shdr.sh_entsize = entsize;
}
}