| ... | @@ -283,6 +283,7 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: elf.Elf64_Shdr) error{O | ... | @@ -283,6 +283,7 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: elf.Elf64_Shdr) error{O |
| 283 | const name = blk: { | 283 | const name = blk: { |
| 284 | const name = self.getString(shdr.sh_name); | 284 | const name = self.getString(shdr.sh_name); |
| 285 | if (elf_file.base.isRelocatable()) break :blk name; | 285 | if (elf_file.base.isRelocatable()) break :blk name; |
| | 286 | if (shdr.sh_flags & elf.SHF_MERGE != 0) break :blk name; |
| 286 | const sh_name_prefixes: []const [:0]const u8 = &.{ | 287 | const sh_name_prefixes: []const [:0]const u8 = &.{ |
| 287 | ".text", ".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss", | 288 | ".text", ".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss", |
| 288 | ".init_array", ".fini_array", ".tbss", ".tdata", ".gcc_except_table", ".ctors", | 289 | ".init_array", ".fini_array", ".tbss", ".tdata", ".gcc_except_table", ".ctors", |
| ... | @@ -740,6 +741,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { | ... | @@ -740,6 +741,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { |
| 740 | | 741 | |
| 741 | for (self.merge_sections.items) |index| { | 742 | for (self.merge_sections.items) |index| { |
| 742 | const imsec = elf_file.inputMergeSection(index) orelse continue; | 743 | const imsec = elf_file.inputMergeSection(index) orelse continue; |
| | 744 | if (imsec.offsets.items.len == 0) continue; |
| 743 | const msec = elf_file.mergeSection(imsec.merge_section_index); | 745 | const msec = elf_file.mergeSection(imsec.merge_section_index); |
| 744 | const atom_ptr = elf_file.atom(imsec.atom_index).?; | 746 | const atom_ptr = elf_file.atom(imsec.atom_index).?; |
| 745 | const isec = atom_ptr.inputShdr(elf_file); | 747 | const isec = atom_ptr.inputShdr(elf_file); |
| ... | @@ -773,6 +775,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { | ... | @@ -773,6 +775,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { |
| 773 | | 775 | |
| 774 | const imsec_index = self.merge_sections.items[esym.st_shndx]; | 776 | const imsec_index = self.merge_sections.items[esym.st_shndx]; |
| 775 | const imsec = elf_file.inputMergeSection(imsec_index) orelse continue; | 777 | const imsec = elf_file.inputMergeSection(imsec_index) orelse continue; |
| | 778 | if (imsec.offsets.items.len == 0) continue; |
| 776 | const msub_index, const offset = imsec.findSubsection(@intCast(esym.st_value)) orelse { | 779 | const msub_index, const offset = imsec.findSubsection(@intCast(esym.st_value)) orelse { |
| 777 | var err = try elf_file.addErrorWithNotes(2); | 780 | var err = try elf_file.addErrorWithNotes(2); |
| 778 | try err.addMsg(elf_file, "invalid symbol value: {x}", .{esym.st_value}); | 781 | try err.addMsg(elf_file, "invalid symbol value: {x}", .{esym.st_value}); |
| ... | @@ -797,6 +800,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { | ... | @@ -797,6 +800,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void { |
| 797 | | 800 | |
| 798 | const imsec_index = self.merge_sections.items[esym.st_shndx]; | 801 | const imsec_index = self.merge_sections.items[esym.st_shndx]; |
| 799 | const imsec = elf_file.inputMergeSection(imsec_index) orelse continue; | 802 | const imsec = elf_file.inputMergeSection(imsec_index) orelse continue; |
| | 803 | if (imsec.offsets.items.len == 0) continue; |
| 800 | const msub_index, const offset = imsec.findSubsection(@intCast(@as(i64, @intCast(esym.st_value)) + rel.r_addend)) orelse { | 804 | const msub_index, const offset = imsec.findSubsection(@intCast(@as(i64, @intCast(esym.st_value)) + rel.r_addend)) orelse { |
| 801 | var err = try elf_file.addErrorWithNotes(1); | 805 | var err = try elf_file.addErrorWithNotes(1); |
| 802 | try err.addMsg(elf_file, "invalid relocation at offset 0x{x}", .{rel.r_offset}); | 806 | try err.addMsg(elf_file, "invalid relocation at offset 0x{x}", .{rel.r_offset}); |