aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-07-19 15:55:49 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-07-22 16:58:21 +0200
commit39df241df4ac177503d899dd8b53a632e4e29334 (patch)
tree853d25436b0afb913b5165aeb467e1b4817d2eff /src/link/MachO/Object.zig
parenta089a6dc4ff04a10360019185ecaacd0564eb84c (diff)
downloadzig-39df241df4ac177503d899dd8b53a632e4e29334.tar.gz
zig-39df241df4ac177503d899dd8b53a632e4e29334.zip
macho: do not GC local symbols unless reference dead symbols
If a local references another local, we keep it. If it doesn't reference anything, we keep it. Otherwise, we dead strip it.
Diffstat (limited to 'src/link/MachO/Object.zig')
-rw-r--r--src/link/MachO/Object.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index 07237d31aa..37b7d60e71 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -410,7 +410,9 @@ pub fn splitIntoAtomsOneShot(
next_sym_count += atom_syms.len;
assert(atom_syms.len > 0);
- const sym_index = atom_syms[0].index;
+ const sym_index = for (atom_syms) |atom_sym| {
+ if (atom_sym.getSymbol(context).ext()) break atom_sym.index;
+ } else atom_syms[0].index;
const atom_size = blk: {
const end_addr = if (next_sym_count < filtered_syms.len)
filtered_syms[next_sym_count].getSymbol(context).n_value
@@ -570,12 +572,6 @@ fn createAtomFromSubsection(
if (gc_roots) |gcr| {
const is_gc_root = blk: {
if (sect.isDontDeadStrip()) break :blk true;
- if (sect.isDontDeadStripIfReferencesLive()) {
- // TODO if isDontDeadStripIfReferencesLive we should analyse the edges
- // before making it a GC root
- break :blk true;
- }
- if (mem.eql(u8, "__StaticInit", sect.sectName())) break :blk true;
switch (sect.type_()) {
macho.S_MOD_INIT_FUNC_POINTERS,
macho.S_MOD_TERM_FUNC_POINTERS,
@@ -641,3 +637,7 @@ pub fn getSection(self: Object, n_sect: u16) macho.section_64 {
assert(n_sect < seg.sections.items.len);
return seg.sections.items[n_sect];
}
+
+pub fn getAtomForSymbol(self: Object, sym_index: u32) ?*Atom {
+ return self.atom_by_index_table.get(sym_index);
+}