Lines Matching +full:keep +full:- +full:a +full:- +full:live

1 //===- MarkLive.cpp -------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
19 #include "mach-o/compact_unwind_encoding.h"
28 // Keep track of the entry that caused us to mark `isec` as live.
35 // Type-erased interface to MarkLiveImpl. Used for adding roots to the liveness
47 // -why_live is a rarely used option, so we don't want support for that flag
48 // to slow down the main -dead_strip code path. As such, we employ templates
66 // We build up a worklist of sections which have been marked as live. We
78 if (isec->isLive(off)) in enqueue()
80 isec->markLive(off); in enqueue()
82 assert(!s->isCoalescedWeak()); in enqueue()
88 std::string out = toString(*s) + " from " + toString(s->getFile()); in printWhyLive()
91 entry = entry->prev, indent += 2) { in printWhyLive()
92 const TinyPtrVector<Defined *> &symbols = entry->isec->symbols; in printWhyLive()
97 " from " + toString(symbols.front()->getFile()); in printWhyLive()
106 if (s->used) in addSym()
108 s->used = true; in addSym()
110 if (!config->whyLive.empty() && config->whyLive.match(s->getName())) in addSym()
113 if (d->isec()) in addSym()
114 enqueue(d->isec(), d->value, prev); in addSym()
115 if (d->unwindEntry()) in addSym()
116 enqueue(d->unwindEntry(), 0, prev); in addSym()
124 return entry->isec; in getInputSection()
148 // Mark things reachable from GC roots as live. in markTransitively()
156 assert(isec->live && "We mark as live when pushing onto the worklist!"); in markTransitively()
159 for (const Reloc &r : isec->relocs) { in markTransitively()
165 for (Defined *d : getInputSection(entry)->symbols) in markTransitively()
169 // S_ATTR_LIVE_SUPPORT sections are live if they point _to_ a live in markTransitively()
170 // section. Process them in a second pass. in markTransitively()
172 // FIXME: Check if copying all S_ATTR_LIVE_SUPPORT sections into a in markTransitively()
174 if (!(isec->getFlags() & S_ATTR_LIVE_SUPPORT) || isec->live) in markTransitively()
177 for (const Reloc &r : isec->relocs) { in markTransitively()
179 if (s->isLive()) { in markTransitively()
182 referentIsec = d->isec(); in markTransitively()
187 if (referentIsec->isLive(r.addend)) in markTransitively()
193 // S_ATTR_LIVE_SUPPORT could have marked additional sections live, in markTransitively()
194 // which in turn could mark additional S_ATTR_LIVE_SUPPORT sections live. in markTransitively()
196 // S_ATTR_LIVE_SUPPORT sections live. in markTransitively()
200 // Set live bit on for each reachable chunk. Unmarked (unreachable)
206 if (config->whyLive.empty()) in markLive()
211 if (config->entry) in markLive()
212 marker->addSym(config->entry); in markLive()
213 for (Symbol *sym : symtab->getSymbols()) { in markLive()
215 // -exported_symbol(s_list) in markLive()
216 if (!config->exportedSymbols.empty() && in markLive()
217 config->exportedSymbols.match(defined->getName())) { in markLive()
218 // NOTE: Even though exporting private externs is an ill-defined in markLive()
221 // extern symbols as live, irrespective of whether they are autohide. in markLive()
222 marker->addSym(defined); in markLive()
227 if (defined->referencedDynamically || defined->noDeadStrip) { in markLive()
228 marker->addSym(defined); in markLive()
234 // * -reexported_symbol(s_list) in markLive()
235 // * -alias_list in markLive()
236 // * -init in markLive()
238 // In dylibs and bundles and in executables with -export_dynamic, in markLive()
241 config->outputType != MH_EXECUTE || config->exportDynamic; in markLive()
242 if (externsAreRoots && !defined->privateExtern) { in markLive()
243 marker->addSym(defined); in markLive()
248 // -u symbols in markLive()
249 for (Symbol *sym : config->explicitUndefineds) in markLive()
250 marker->addSym(sym); in markLive()
254 for (Symbol *sym : objFile->symbols) in markLive()
256 if (!defined->isExternal() && defined->noDeadStrip) in markLive()
257 marker->addSym(defined); in markLive()
259 dyn_cast_or_null<DylibSymbol>(symtab->find("dyld_stub_binder"))) in markLive()
260 marker->addSym(stubBinder); in markLive()
263 if (isec->getFlags() & S_ATTR_NO_DEAD_STRIP) { in markLive()
264 marker->enqueue(isec, 0); in markLive()
269 if (sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS || in markLive()
270 sectionType(isec->getFlags()) == S_MOD_TERM_FUNC_POINTERS) { in markLive()
271 assert(!config->emitInitOffsets || in markLive()
272 sectionType(isec->getFlags()) != S_MOD_INIT_FUNC_POINTERS); in markLive()
273 marker->enqueue(isec, 0); in markLive()
278 for (ConcatInputSection *isec : in.initOffsets->inputs()) in markLive()
279 marker->enqueue(isec, 0); in markLive()
281 marker->markTransitively(); in markLive()