authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-26 16:16:34+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-26 16:16:34+02:00
log8bd0687713855a41578605a3e1a6c9686a702bfe
tree60a43c639aa5168413f0c29e2ee0a159aed5ec51
parent29df0ca39db8c336d6bdc7090f6d5f51b7463602

macho: port mechanism for allocating symbols within atoms

such as entire sections represented as a single atom.

1 files changed, 16 insertions(+), 1 deletions(-)

src/link/MachO.zig+16-1
...@@ -1908,8 +1908,23 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64...@@ -1908,8 +1908,23 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64
19081908
1909 // TODO we should check if we need to expand the section or not like we1909 // TODO we should check if we need to expand the section or not like we
1910 // do in `allocateTextBlock`.1910 // do in `allocateTextBlock`.
1911 const n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1);
1911 sym.n_value = vaddr;1912 sym.n_value = vaddr;
1912 sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1);1913 sym.n_sect = n_sect;
1914
1915 // Update each alias (if any)
1916 for (atom.aliases.items) |index| {
1917 const alias_sym = &self.locals.items[index];
1918 alias_sym.n_value = vaddr;
1919 alias_sym.n_sect = n_sect;
1920 }
1921
1922 // Update each symbol contained within the TextBlock
1923 for (atom.contained.items) |sym_at_off| {
1924 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
1925 contained_sym.n_value = vaddr + sym_at_off.offset;
1926 contained_sym.n_sect = n_sect;
1927 }
19131928
1914 if (self.blocks.getPtr(match)) |last| {1929 if (self.blocks.getPtr(match)) |last| {
1915 last.*.next = atom;1930 last.*.next = atom;