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))
80 isec->markLive(off);
82 assert(!s->isCoalescedWeak());
88 std::string out = toString(*s) + " from " + toString(s->getFile());
91 entry = entry->prev, indent += 2) {
92 const TinyPtrVector<Defined *> &symbols = entry->isec->symbols;
97 " from " + toString(symbols.front()->getFile());
106 if (s->used)
108 s->used = true;
110 if (!config->whyLive.empty() && config->whyLive.match(s->getName()))
113 if (d->isec())
114 enqueue(d->isec(), d->value, prev);
115 if (d->unwindEntry())
116 enqueue(d->unwindEntry(), 0, prev);
124 return entry->isec;
148 // Mark things reachable from GC roots as live.
156 assert(isec->live && "We mark as live when pushing onto the worklist!");
159 for (const Reloc &r : isec->relocs) {
165 for (Defined *d : getInputSection(entry)->symbols)
169 // S_ATTR_LIVE_SUPPORT sections are live if they point _to_ a live
170 // section. Process them in a second pass.
172 // FIXME: Check if copying all S_ATTR_LIVE_SUPPORT sections into a
174 if (!(isec->getFlags() & S_ATTR_LIVE_SUPPORT) || isec->live)
177 for (const Reloc &r : isec->relocs) {
179 if (s->isLive()) {
182 referentIsec = d->isec();
187 if (referentIsec->isLive(r.addend))
193 // S_ATTR_LIVE_SUPPORT could have marked additional sections live,
194 // which in turn could mark additional S_ATTR_LIVE_SUPPORT sections live.
196 // S_ATTR_LIVE_SUPPORT sections live.
200 // Set live bit on for each reachable chunk. Unmarked (unreachable)
206 if (config->whyLive.empty())
211 if (config->entry)
212 marker->addSym(config->entry);
213 for (Symbol *sym : symtab->getSymbols()) {
215 // -exported_symbol(s_list)
216 if (!config->exportedSymbols.empty() &&
217 config->exportedSymbols.match(defined->getName())) {
218 // NOTE: Even though exporting private externs is an ill-defined
221 // extern symbols as live, irrespective of whether they are autohide.
222 marker->addSym(defined);
227 if (defined->referencedDynamically || defined->noDeadStrip) {
228 marker->addSym(defined);
234 // * -reexported_symbol(s_list)
235 // * -alias_list
236 // * -init
238 // In dylibs and bundles and in executables with -export_dynamic,
241 config->outputType != MH_EXECUTE || config->exportDynamic;
242 if (externsAreRoots && !defined->privateExtern) {
243 marker->addSym(defined);
248 // -u symbols
249 for (Symbol *sym : config->explicitUndefineds)
250 marker->addSym(sym);
254 for (Symbol *sym : objFile->symbols)
256 if (!defined->isExternal() && defined->noDeadStrip)
257 marker->addSym(defined);
259 dyn_cast_or_null<DylibSymbol>(symtab->find("dyld_stub_binder")))
260 marker->addSym(stubBinder);
263 if (isec->getFlags() & S_ATTR_NO_DEAD_STRIP) {
264 marker->enqueue(isec, 0);
269 if (sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS ||
270 sectionType(isec->getFlags()) == S_MOD_TERM_FUNC_POINTERS) {
271 assert(!config->emitInitOffsets ||
272 sectionType(isec->getFlags()) != S_MOD_INIT_FUNC_POINTERS);
273 marker->enqueue(isec, 0);
278 for (ConcatInputSection *isec : in.initOffsets->inputs())
279 marker->enqueue(isec, 0);
281 marker->markTransitively();