| author | |
| committer | |
| log | 4931a291f86410d5c43dd9471d23b7e890f91246 |
| tree | 48955a4b157a79cd0cf4c3a19167ea25e008c221 |
| parent | 457d84f45af28362869cc4e91f0c56c3bd052365 |
4 files changed, 19 insertions(+), 0 deletions(-)
src/link/Elf.zig+9| ... | @@ -3337,6 +3337,7 @@ pub fn addCommentString(self: *Elf) !void { | ... | @@ -3337,6 +3337,7 @@ pub fn addCommentString(self: *Elf) !void { |
| 3337 | msub.string_index = res.key.pos; | 3337 | msub.string_index = res.key.pos; |
| 3338 | msub.alignment = .@"1"; | 3338 | msub.alignment = .@"1"; |
| 3339 | msub.size = res.key.len; | 3339 | msub.size = res.key.len; |
| 3340 | msub.entsize = 1; | ||
| 3340 | msub.alive = true; | 3341 | msub.alive = true; |
| 3341 | res.sub.* = msub_index; | 3342 | res.sub.* = msub_index; |
| 3342 | } | 3343 | } |
| ... | @@ -3428,6 +3429,14 @@ fn initOutputSections(self: *Elf) !void { | ... | @@ -3428,6 +3429,14 @@ fn initOutputSections(self: *Elf) !void { |
| 3428 | .flags = msec.flags, | 3429 | .flags = msec.flags, |
| 3429 | }); | 3430 | }); |
| 3430 | msec.output_section_index = shndx; | 3431 | msec.output_section_index = shndx; |
| 3432 | |||
| 3433 | var entsize = self.mergeSubsection(msec.subsections.items[0]).entsize; | ||
| 3434 | for (msec.subsections.items) |index| { | ||
| 3435 | const msub = self.mergeSubsection(index); | ||
| 3436 | entsize = @min(entsize, msub.entsize); | ||
| 3437 | } | ||
| 3438 | const shdr = &self.shdrs.items[shndx]; | ||
| 3439 | shdr.sh_entsize = entsize; | ||
| 3431 | } | 3440 | } |
| 3432 | } | 3441 | } |
| 3433 | 3442 |
src/link/Elf/Object.zig+1| ... | @@ -759,6 +759,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { | ... | @@ -759,6 +759,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { |
| 759 | msub.string_index = res.key.pos; | 759 | msub.string_index = res.key.pos; |
| 760 | msub.alignment = atom_ptr.alignment; | 760 | msub.alignment = atom_ptr.alignment; |
| 761 | msub.size = res.key.len; | 761 | msub.size = res.key.len; |
| 762 | msub.entsize = math.cast(u32, isec.sh_entsize) orelse return error.Overflow; | ||
| 762 | msub.alive = !elf_file.base.gc_sections or isec.sh_flags & elf.SHF_ALLOC == 0; | 763 | msub.alive = !elf_file.base.gc_sections or isec.sh_flags & elf.SHF_ALLOC == 0; |
| 763 | res.sub.* = msub_index; | 764 | res.sub.* = msub_index; |
| 764 | } | 765 | } |
src/link/Elf/merge_section.zig+1| ... | @@ -168,6 +168,7 @@ pub const MergeSubsection = struct { | ... | @@ -168,6 +168,7 @@ pub const MergeSubsection = struct { |
| 168 | string_index: u32 = 0, | 168 | string_index: u32 = 0, |
| 169 | size: u32 = 0, | 169 | size: u32 = 0, |
| 170 | alignment: Atom.Alignment = .@"1", | 170 | alignment: Atom.Alignment = .@"1", |
| 171 | entsize: u32 = 0, | ||
| 171 | alive: bool = false, | 172 | alive: bool = false, |
| 172 | 173 | ||
| 173 | pub fn address(msub: MergeSubsection, elf_file: *Elf) i64 { | 174 | pub fn address(msub: MergeSubsection, elf_file: *Elf) i64 { |
src/link/Elf/relocatable.zig+8| ... | @@ -289,6 +289,14 @@ fn initSections(elf_file: *Elf) !void { | ... | @@ -289,6 +289,14 @@ fn initSections(elf_file: *Elf) !void { |
| 289 | .flags = msec.flags, | 289 | .flags = msec.flags, |
| 290 | }); | 290 | }); |
| 291 | msec.output_section_index = shndx; | 291 | msec.output_section_index = shndx; |
| 292 | |||
| 293 | var entsize = elf_file.mergeSubsection(msec.subsections.items[0]).entsize; | ||
| 294 | for (msec.subsections.items) |index| { | ||
| 295 | const msub = elf_file.mergeSubsection(index); | ||
| 296 | entsize = @min(entsize, msub.entsize); | ||
| 297 | } | ||
| 298 | const shdr = &elf_file.shdrs.items[shndx]; | ||
| 299 | shdr.sh_entsize = entsize; | ||
| 292 | } | 300 | } |
| 293 | 301 | ||
| 294 | const needs_eh_frame = for (elf_file.objects.items) |index| { | 302 | const needs_eh_frame = for (elf_file.objects.items) |index| { |