| ... | @@ -31,12 +31,6 @@ rel_num: u32 = 0, | ... | @@ -31,12 +31,6 @@ rel_num: u32 = 0, |
| 31 | /// Index of this atom in the linker's atoms table. | 31 | /// Index of this atom in the linker's atoms table. |
| 32 | atom_index: Index = 0, | 32 | atom_index: Index = 0, |
| 33 | | 33 | |
| 34 | /// Start index of FDEs referencing this atom. | | |
| 35 | fde_start: u32 = 0, | | |
| 36 | | | |
| 37 | /// End index of FDEs referencing this atom. | | |
| 38 | fde_end: u32 = 0, | | |
| 39 | | | |
| 40 | /// Points to the previous and next neighbors, based on the `text_offset`. | 34 | /// Points to the previous and next neighbors, based on the `text_offset`. |
| 41 | /// This can be used to find, for example, the capacity of this `TextBlock`. | 35 | /// This can be used to find, for example, the capacity of this `TextBlock`. |
| 42 | prev_index: Index = 0, | 36 | prev_index: Index = 0, |
| ... | @@ -360,9 +354,10 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El | ... | @@ -360,9 +354,10 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El |
| 360 | } | 354 | } |
| 361 | | 355 | |
| 362 | pub fn fdes(self: Atom, elf_file: *Elf) []Fde { | 356 | pub fn fdes(self: Atom, elf_file: *Elf) []Fde { |
| 363 | if (self.fde_start == self.fde_end) return &[0]Fde{}; | 357 | if (!self.flags.fde) return &[0]Fde{}; |
| | 358 | const extras = self.extra(elf_file).?; |
| 364 | const object = self.file(elf_file).?.object; | 359 | const object = self.file(elf_file).?.object; |
| 365 | return object.fdes.items[self.fde_start..self.fde_end]; | 360 | return object.fdes.items[extras.fde_start..][0..extras.fde_count]; |
| 366 | } | 361 | } |
| 367 | | 362 | |
| 368 | pub fn markFdesDead(self: Atom, elf_file: *Elf) void { | 363 | pub fn markFdesDead(self: Atom, elf_file: *Elf) void { |
| ... | @@ -984,6 +979,8 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any | ... | @@ -984,6 +979,8 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any |
| 984 | | 979 | |
| 985 | const AddExtraOpts = struct { | 980 | const AddExtraOpts = struct { |
| 986 | thunk: ?u32 = null, | 981 | thunk: ?u32 = null, |
| | 982 | fde_start: ?u32 = null, |
| | 983 | fde_count: ?u32 = null, |
| 987 | }; | 984 | }; |
| 988 | | 985 | |
| 989 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) !void { | 986 | pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) !void { |
| ... | @@ -1046,12 +1043,13 @@ fn format2( | ... | @@ -1046,12 +1043,13 @@ fn format2( |
| 1046 | atom.atom_index, atom.name(elf_file), atom.address(elf_file), | 1043 | atom.atom_index, atom.name(elf_file), atom.address(elf_file), |
| 1047 | atom.output_section_index, atom.alignment, atom.size, | 1044 | atom.output_section_index, atom.alignment, atom.size, |
| 1048 | }); | 1045 | }); |
| 1049 | if (atom.fde_start != atom.fde_end) { | 1046 | if (atom.flags.fde) { |
| 1050 | try writer.writeAll(" : fdes{ "); | 1047 | try writer.writeAll(" : fdes{ "); |
| 1051 | for (atom.fdes(elf_file), atom.fde_start..) |fde, i| { | 1048 | const extras = atom.extra(elf_file).?; |
| | 1049 | for (atom.fdes(elf_file), extras.fde_start..) |fde, i| { |
| 1052 | try writer.print("{d}", .{i}); | 1050 | try writer.print("{d}", .{i}); |
| 1053 | if (!fde.alive) try writer.writeAll("([*])"); | 1051 | if (!fde.alive) try writer.writeAll("([*])"); |
| 1054 | if (i < atom.fde_end - 1) try writer.writeAll(", "); | 1052 | if (i - extras.fde_start < extras.fde_count - 1) try writer.writeAll(", "); |
| 1055 | } | 1053 | } |
| 1056 | try writer.writeAll(" }"); | 1054 | try writer.writeAll(" }"); |
| 1057 | } | 1055 | } |
| ... | @@ -1069,8 +1067,11 @@ pub const Flags = packed struct { | ... | @@ -1069,8 +1067,11 @@ pub const Flags = packed struct { |
| 1069 | /// Specifies if the atom has been visited during garbage collection. | 1067 | /// Specifies if the atom has been visited during garbage collection. |
| 1070 | visited: bool = false, | 1068 | visited: bool = false, |
| 1071 | | 1069 | |
| 1072 | /// Whether this symbol has a range extension thunk. | 1070 | /// Whether this atom has a range extension thunk. |
| 1073 | thunk: bool = false, | 1071 | thunk: bool = false, |
| | 1072 | |
| | 1073 | /// Whether this atom has FDE records. |
| | 1074 | fde: bool = false, |
| 1074 | }; | 1075 | }; |
| 1075 | | 1076 | |
| 1076 | const x86_64 = struct { | 1077 | const x86_64 = struct { |
| ... | @@ -2197,7 +2198,14 @@ const RelocsIterator = struct { | ... | @@ -2197,7 +2198,14 @@ const RelocsIterator = struct { |
| 2197 | }; | 2198 | }; |
| 2198 | | 2199 | |
| 2199 | pub const Extra = struct { | 2200 | pub const Extra = struct { |
| | 2201 | /// Index of the range extension thunk of this atom. |
| 2200 | thunk: u32 = 0, | 2202 | thunk: u32 = 0, |
| | 2203 | |
| | 2204 | /// Start index of FDEs referencing this atom. |
| | 2205 | fde_start: u32 = 0, |
| | 2206 | |
| | 2207 | /// Count of FDEs referencing this atom. |
| | 2208 | fde_count: u32 = 0, |
| 2201 | }; | 2209 | }; |
| 2202 | | 2210 | |
| 2203 | const std = @import("std"); | 2211 | const std = @import("std"); |