| ... | ... | @@ -122,6 +122,7 @@ dynamic_section_index: ?u16 = null, |
| 122 | 122 | dynstrtab_section_index: ?u16 = null, |
| 123 | 123 | dynsymtab_section_index: ?u16 = null, |
| 124 | 124 | eh_frame_section_index: ?u16 = null, |
| 125 | eh_frame_rela_section_index: ?u16 = null, |
| 125 | 126 | eh_frame_hdr_section_index: ?u16 = null, |
| 126 | 127 | hash_section_index: ?u16 = null, |
| 127 | 128 | gnu_hash_section_index: ?u16 = null, |
| ... | ... | @@ -3583,7 +3584,7 @@ fn initSectionsObject(self: *Elf) !void { |
| 3583 | 3584 | .addralign = ptr_size, |
| 3584 | 3585 | .offset = std.math.maxInt(u64), |
| 3585 | 3586 | }); |
| 3586 | | // _ = try self.addRelaShdr(".rela.eh_frame", self.eh_frame_section_index.?); |
| 3587 | self.eh_frame_rela_section_index = try self.addRelaShdr(".rela.eh_frame", self.eh_frame_section_index.?); |
| 3587 | 3588 | } |
| 3588 | 3589 | |
| 3589 | 3590 | try self.initSymtab(); |
| ... | ... | @@ -3954,6 +3955,7 @@ fn sortShdrs(self: *Elf) !void { |
| 3954 | 3955 | |
| 3955 | 3956 | for (&[_]*?u16{ |
| 3956 | 3957 | &self.eh_frame_section_index, |
| 3958 | &self.eh_frame_rela_section_index, |
| 3957 | 3959 | &self.eh_frame_hdr_section_index, |
| 3958 | 3960 | &self.got_section_index, |
| 3959 | 3961 | &self.symtab_section_index, |
| ... | ... | @@ -4769,6 +4771,9 @@ fn updateSymtabSize(self: *Elf) !void { |
| 4769 | 4771 | for (self.output_sections.keys()) |_| { |
| 4770 | 4772 | nlocals += 1; |
| 4771 | 4773 | } |
| 4774 | if (self.eh_frame_section_index) |_| { |
| 4775 | nlocals += 1; |
| 4776 | } |
| 4772 | 4777 | |
| 4773 | 4778 | for (files.items) |index| { |
| 4774 | 4779 | const file_ptr = self.file(index).?; |
| ... | ... | @@ -5162,9 +5167,26 @@ fn writeSectionSymbols(self: *Elf) void { |
| 5162 | 5167 | }; |
| 5163 | 5168 | ilocal += 1; |
| 5164 | 5169 | } |
| 5170 | |
| 5171 | if (self.eh_frame_section_index) |shndx| { |
| 5172 | const shdr = self.shdrs.items[shndx]; |
| 5173 | const out_sym = &self.symtab.items[ilocal]; |
| 5174 | out_sym.* = .{ |
| 5175 | .st_name = 0, |
| 5176 | .st_value = shdr.sh_addr, |
| 5177 | .st_info = elf.STT_SECTION, |
| 5178 | .st_shndx = @intCast(shndx), |
| 5179 | .st_size = 0, |
| 5180 | .st_other = 0, |
| 5181 | }; |
| 5182 | ilocal += 1; |
| 5183 | } |
| 5165 | 5184 | } |
| 5166 | 5185 | |
| 5167 | 5186 | pub fn sectionSymbolOutputSymtabIndex(self: Elf, shndx: u32) u32 { |
| 5187 | if (self.eh_frame_section_index) |index| { |
| 5188 | if (index == shndx) return @intCast(self.output_sections.keys().len + 1); |
| 5189 | } |
| 5168 | 5190 | return @intCast(self.output_sections.getIndex(shndx).? + 1); |
| 5169 | 5191 | } |
| 5170 | 5192 | |