| ... | @@ -22,12 +22,6 @@ output_section_index: u32 = 0, | ... | @@ -22,12 +22,6 @@ output_section_index: u32 = 0, |
| 22 | /// Index of the input section containing this atom's relocs. | 22 | /// Index of the input section containing this atom's relocs. |
| 23 | relocs_section_index: u32 = 0, | 23 | relocs_section_index: u32 = 0, |
| 24 | | 24 | |
| 25 | /// Start index of the relocations belonging to this atom. | | |
| 26 | rel_index: u32 = 0, | | |
| 27 | | | |
| 28 | /// Number of relocations belonging to this atom. | | |
| 29 | rel_num: u32 = 0, | | |
| 30 | | | |
| 31 | /// Index of this atom in the linker's atoms table. | 25 | /// Index of this atom in the linker's atoms table. |
| 32 | atom_index: Index = 0, | 26 | atom_index: Index = 0, |
| 33 | | 27 | |
| ... | @@ -304,11 +298,14 @@ pub fn free(self: *Atom, elf_file: *Elf) void { | ... | @@ -304,11 +298,14 @@ pub fn free(self: *Atom, elf_file: *Elf) void { |
| 304 | | 298 | |
| 305 | pub fn relocs(self: Atom, elf_file: *Elf) []const elf.Elf64_Rela { | 299 | pub fn relocs(self: Atom, elf_file: *Elf) []const elf.Elf64_Rela { |
| 306 | const shndx = self.relocsShndx() orelse return &[0]elf.Elf64_Rela{}; | 300 | const shndx = self.relocsShndx() orelse return &[0]elf.Elf64_Rela{}; |
| 307 | return switch (self.file(elf_file).?) { | 301 | switch (self.file(elf_file).?) { |
| 308 | .zig_object => |x| x.relocs.items[shndx].items, | 302 | .zig_object => |x| return x.relocs.items[shndx].items, |
| 309 | .object => |x| x.relocs.items[self.rel_index..][0..self.rel_num], | 303 | .object => |x| { |
| | 304 | const extras = self.extra(elf_file).?; |
| | 305 | return x.relocs.items[extras.rel_index..][0..extras.rel_count]; |
| | 306 | }, |
| 310 | else => unreachable, | 307 | else => unreachable, |
| 311 | }; | 308 | } |
| 312 | } | 309 | } |
| 313 | | 310 | |
| 314 | pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.Elf64_Rela)) !void { | 311 | pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.Elf64_Rela)) !void { |
| ... | @@ -981,6 +978,8 @@ const AddExtraOpts = struct { | ... | @@ -981,6 +978,8 @@ const AddExtraOpts = struct { |
| 981 | thunk: ?u32 = null, | 978 | thunk: ?u32 = null, |
| 982 | fde_start: ?u32 = null, | 979 | fde_start: ?u32 = null, |
| 983 | fde_count: ?u32 = null, | 980 | fde_count: ?u32 = null, |
| | 981 | rel_index: ?u32 = null, |
| | 982 | rel_count: ?u32 = null, |
| 984 | }; | 983 | }; |
| 985 | | 984 | |
| 986 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) !void { | 985 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) !void { |
| ... | @@ -2206,6 +2205,12 @@ pub const Extra = struct { | ... | @@ -2206,6 +2205,12 @@ pub const Extra = struct { |
| 2206 | | 2205 | |
| 2207 | /// Count of FDEs referencing this atom. | 2206 | /// Count of FDEs referencing this atom. |
| 2208 | fde_count: u32 = 0, | 2207 | fde_count: u32 = 0, |
| | 2208 | |
| | 2209 | /// Start index of relocations belonging to this atom. |
| | 2210 | rel_index: u32 = 0, |
| | 2211 | |
| | 2212 | /// Count of relocations belonging to this atom. |
| | 2213 | rel_count: u32 = 0, |
| 2209 | }; | 2214 | }; |
| 2210 | | 2215 | |
| 2211 | const std = @import("std"); | 2216 | const std = @import("std"); |