Lines Matching +full:abs +full:- +full:flat
1 //===- InputFiles.cpp -----------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains functions to parse Mach-O object files. In this comment,
10 // we describe the Mach-O file structure and how we parse it.
12 // Mach-O is not very different from ELF or COFF. The notion of symbols,
13 // sections and relocations exists in Mach-O as it does in ELF and COFF.
17 // output files. When we merge or garbage-collect sections, we treat each
18 // section as an atomic unit. In Mach-O, that's not the case. Sections can
20 // garbage-collecting. Therefore, Mach-O's subsections are more similar to
21 // ELF/COFF's sections than Mach-O's sections are.
30 // Mach-O. All references within a section need to be explicitly represented as
33 // than they were in object files. To represent that, Mach-O relocations can
36 // Non-scattered relocations refer to an unnamed location if r_extern is not set
40 // and COFF for Mach-O.
42 //===----------------------------------------------------------------------===//
93 if (f->getName().ends_with(".tbd")) in toString()
94 return (f->getName() + "(" + dylibFile->installName + ")").str(); in toString()
96 if (f->archiveName.empty()) in toString()
97 return std::string(f->getName()); in toString()
98 return (f->archiveName + "(" + path::filename(f->getName()) + ")").str(); in toString()
120 const char *hdr = input->mb.getBufferStart(); in getPlatformInfos()
126 info.target.Platform = static_cast<PlatformType>(cmd->platform); in getPlatformInfos()
127 info.target.MinDeployment = decodeVersion(cmd->minos); in getPlatformInfos()
134 switch (cmd->cmd) { in getPlatformInfos()
148 info.target.MinDeployment = decodeVersion(cmd->version); in getPlatformInfos()
162 removeSimulator(config->platform()); in checkCompatibility()
175 getPlatformName(config->platform())); in checkCompatibility()
179 if (it->target.MinDeployment > config->platformInfo.target.MinDeployment) in checkCompatibility()
181 it->target.MinDeployment.getAsString() + in checkCompatibility()
183 config->platformInfo.target.MinDeployment.getAsString()); in checkCompatibility()
191 std::tie(cpuType, std::ignore) = getCPUTypeFromArchitecture(config->arch()); in compatWithTargetArch()
193 if (hdr->cputype != cpuType) { in compatWithTargetArch()
195 getArchitectureFromCpuType(hdr->cputype, hdr->cpusubtype); in compatWithTargetArch()
196 auto msg = config->errorForArchMismatch in compatWithTargetArch()
202 getArchitectureName(config->arch())); in compatWithTargetArch()
215 // Open a given file path and return it as a memory-mapped file.
220 return entry->second; in readFile()
229 MemoryBufferRef mbref = mb->getMemBufferRef(); in readFile()
232 // If this is a regular non-fat file, return it. in readFile()
236 read32be(&hdr->magic) != FAT_MAGIC) { in readFile()
238 tar->append(relativeToRoot(path), mbref.getBuffer()); in readFile()
253 for (uint32_t i = 0, n = read32be(&hdr->nfat_arch); i < n; ++i) { in readFile()
266 if (cpuType != static_cast<uint32_t>(target->cpuType) || in readFile()
267 cpuSubtype != target->cpuSubtype) { in readFile()
277 tar->append(relativeToRoot(path), mbref.getBuffer()); in readFile()
282 auto targetArchName = getArchName(target->cpuType, target->cpuSubtype); in readFile()
291 // Some sections comprise of fixed-size records, so instead of splitting them at
297 // used by the Mach-O format.
301 return target->wordSize == 8 ? 32 : 20; in getRecordSize()
303 if (!config->dedupStrings) in getRecordSize()
307 return target->wordSize == 8 ? 32 : 16; in getRecordSize()
309 if (config->icfLevel == ICFLevel::none) in getRecordSize()
313 return target->wordSize; in getRecordSize()
316 return target->wordSize; in getRecordSize()
362 auto splitRecords = [&](size_t recordSize) -> void { in parseSections()
380 name == section_names::objcMethname || config->dedupStrings; in parseSections()
384 cast<CStringInputSection>(isec)->splitIntoPieces(); in parseSections()
398 if (config->callGraphProfileSort && name == section_names::cgProfile) in parseSections()
414 if (isDebugSection(isec->getFlags()) && in parseSections()
415 isec->getSegName() == segment_names::dwarf) { in parseSections()
435 uint64_t fullLength = length + (off - frameOff); in splitEhFrames()
437 // We hard-code an alignment of 1 here because we don't actually want our in splitEhFrames()
461 [](uint64_t value, const Section *sec) { return value < sec->addr; })); in findContainingSection()
462 *offset -= (*it)->addr; in findContainingSection()
482 *offset -= it->offset; in findContainingSubsection()
483 return it->isec; in findContainingSubsection()
489 auto it = llvm::lower_bound(isec->symbols, off, [](Defined *d, uint64_t off) { in findSymbolAtOffset()
490 return d->value < off; in findSymbolAtOffset()
493 if (it == isec->symbols.end() || (*it)->value != off) { in findSymbolAtOffset()
494 assert(isec->wasCoalesced); in findSymbolAtOffset()
503 const RelocAttrs &relocAttrs = target->getRelocAttrs(rel.r_type); in validateRelocationInfo()
517 "be PC-relative")); in validateRelocationInfo()
520 error(message("not allowed in thread-local section, must be UNSIGNED")); in validateRelocationInfo()
542 // Paired relocations serve as Mach-O's method for attaching a in parseRelocations()
560 // to store addends in the instruction-stream bytes that would otherwise in parseRelocations()
568 target->hasAttr(relInfo.r_type, RelocAttrBits::SUBTRAHEND); in parseRelocations()
570 if (target->hasAttr(relInfo.r_type, RelocAttrBits::ADDEND)) { in parseRelocations()
580 int64_t embeddedAddend = target->getEmbeddedAddend(mb, sec.offset, relInfo); in parseRelocations()
594 sectionHeaders[relInfo.r_symbolnum - 1]; in parseRelocations()
600 // FIXME This logic was written around x86_64 behavior -- ARM64 doesn't in parseRelocations()
602 // the arch-specific .cpp file. in parseRelocations()
603 assert(target->hasAttr(r.type, RelocAttrBits::BYTE4)); in parseRelocations()
604 referentOffset = sec.addr + relInfo.r_address + 4 + totalAddend - in parseRelocations()
607 // The addend for a non-pcrel relocation is its absolute address. in parseRelocations()
608 referentOffset = totalAddend - referentSecHead.addr; in parseRelocations()
610 r.referent = findContainingSubsection(*sections[relInfo.r_symbolnum - 1], in parseRelocations()
616 // Though not required by the Mach-O format, clang and gcc seem to emit in parseRelocations()
618 // unsorted relocations (in `-r` mode), so we have a fallback for that in parseRelocations()
621 while (subsecIt != subsections.rend() && subsecIt->offset > r.offset) in parseRelocations()
624 subsecIt->offset + subsecIt->isec->getSize() <= r.offset) { in parseRelocations()
630 subsec = subsecIt->isec; in parseRelocations()
631 r.offset -= subsecIt->offset; in parseRelocations()
633 subsec->relocs.push_back(r); in parseRelocations()
639 assert(target->hasAttr(minuendInfo.r_type, RelocAttrBits::UNSIGNED) && in parseRelocations()
648 totalAddend - sectionHeaders[minuendInfo.r_symbolnum - 1].addr; in parseRelocations()
650 *sections[minuendInfo.r_symbolnum - 1], &referentOffset); in parseRelocations()
653 subsec->relocs.push_back(p); in parseRelocations()
668 // either reported (for non-weak symbols) or merged in createDefined()
671 // N_PEXT: llvm-mc does not emit these, but `ld -r` (wherein ld64 emits in createDefined()
672 // object files) may produce them. LLD does not yet support -r. in createDefined()
673 // These are translation-unit scoped, identical to the `0` case. in createDefined()
674 // 0: Translation-unit scoped. These are not in the symbol table during in createDefined()
682 // -load_hidden makes us treat global symbols as linkage unit scoped. in createDefined()
691 // * inline function F in a TU built with -fvisibility-inlines-hidden in createDefined()
694 // -fvisibility-inlines-hidden. in createDefined()
697 // -fvisibility-inlines-hidden. in createDefined()
707 // with ld64's semantics, because it means the non-private-extern in createDefined()
711 // that's privateExtern -- neither makes it into the dynamic symbol table, in createDefined()
721 return symtab->addDefined( in createDefined()
722 name, isec->getFile(), isec, value, size, sym.n_desc & N_WEAK_DEF, in createDefined()
728 name, isec->getFile(), isec, value, size, sym.n_desc & N_WEAK_DEF, in createDefined()
742 return symtab->addDefined(name, file, nullptr, sym.n_value, /*size=*/0, in createAbsolute()
765 ? symtab->addUndefined(name, this, sym.n_desc & N_WEAK_REF) in parseNonSectionSymbol()
766 : symtab->addCommon(name, this, sym.n_value, in parseNonSectionSymbol()
772 // Not much point in making local aliases -- relocs in the current file can in parseNonSectionSymbol()
817 Subsections &subsections = sections[sym.n_sect - 1]->subsections; in parseSymbols()
821 symbolsBySection[sym.n_sect - 1].push_back(i); in parseSymbols()
830 Subsections &subsections = sections[i]->subsections; in parseSymbols()
840 if (sections[i]->doneSplitting) { in parseSymbols()
845 uint64_t symbolOffset = sym.n_value - sectionAddr; in parseSymbols()
854 createDefined(sym, name, isec, 0, isec->getSize(), forceHidden); in parseSymbols()
858 sections[i]->doneSplitting = true; in parseSymbols()
860 auto getSymName = [strtab](const NList& sym) -> StringRef { in parseSymbols()
885 size_t symbolOffset = sym.n_value - subsecAddr; in parseSymbols()
888 ? nList[symbolIndices[j + 1]].n_value - sym.n_value in parseSymbols()
889 : isec->data.size() - symbolOffset; in parseSymbols()
891 // 1. If the input file does not use subsections-via-symbols. in parseSymbols()
899 isec->hasAltEntry = symbolOffset != 0; in parseSymbols()
907 nextIsec->wasCoalesced = false; in parseSymbols()
908 if (isZeroFill(isec->getFlags())) { in parseSymbols()
909 // Zero-fill sections have NULL data.data() non-zero data.size() in parseSymbols()
910 nextIsec->data = {nullptr, isec->data.size() - symbolOffset}; in parseSymbols()
911 isec->data = {nullptr, symbolOffset}; in parseSymbols()
913 nextIsec->data = isec->data.slice(symbolOffset); in parseSymbols()
914 isec->data = isec->data.slice(0, symbolOffset); in parseSymbols()
924 nextIsec->align = MinAlign(sectionAlign, sym.n_value); in parseSymbols()
925 subsections.push_back({sym.n_value - sectionAddr, nextIsec}); in parseSymbols()
949 isec->live = true; in OpaqueFile()
960 cmd->cmdsize - sizeof(linker_option_command)}; in parseLinkerOptions()
961 parseLCLinkerOption(LCLinkerOptions, this, cmd->count, data); in parseLinkerOptions()
971 this->archiveName = std::string(archiveName); in ObjFile()
972 this->compatArch = compatArch; in ObjFile()
974 if (target->wordSize == 8) in ObjFile()
979 if (target->wordSize == 8) in ObjFile()
1011 reinterpret_cast<const SectionHeader *>(c + 1), c->nsects}; in parse()
1018 ArrayRef<NList> nList(reinterpret_cast<const NList *>(buf + c->symoff), in parse()
1019 c->nsyms); in parse()
1020 const char *strtab = reinterpret_cast<const char *>(buf) + c->stroff; in parse()
1021 bool subsectionsViaSymbols = hdr->flags & MH_SUBSECTIONS_VIA_SYMBOLS; in parse()
1028 if (!sections[i]->subsections.empty()) in parse()
1036 Section **s = StringSwitch<Section **>(sec->name) in parse()
1065 ArrayRef<NList> nList(reinterpret_cast<const NList *>(buf + c->symoff), in parseLazy()
1066 c->nsyms); in parseLazy()
1067 const char *strtab = reinterpret_cast<const char *>(buf) + c->stroff; in parseLazy()
1073 symbols[i] = symtab->addLazyObject(name, *this); in parseLazy()
1085 // We do not re-use the context from getDwarf() here as that function in parseDebugInfo()
1098 const DWARFContext::compile_unit_range &units = ctx->compile_units(); in parseDebugInfo()
1102 compileUnit = it != units.end() ? it->get() : nullptr; in parseDebugInfo()
1111 return {reinterpret_cast<const data_in_code_entry *>(buf + c->dataoff), in getDataInCode()
1112 c->datasize / sizeof(data_in_code_entry)}; in getDataInCode()
1119 return {buf + cmd->dataoff, cmd->datasize}; in getOptimizationHints()
1147 isec->data = isec->data.slice(target->wordSize, 8 + target->wordSize); in registerCompactUnwind()
1148 uint32_t encoding = read32le(isec->data.data() + sizeof(uint32_t)); in registerCompactUnwind()
1149 // llvm-mc omits CU entries for functions that need DWARF encoding, but in registerCompactUnwind()
1150 // `ld -r` doesn't. We can ignore them because we will re-synthesize these in registerCompactUnwind()
1153 target->modeDwarfEncoding) in registerCompactUnwind()
1157 for (auto it = isec->relocs.begin(); it != isec->relocs.end();) { in registerCompactUnwind()
1168 if (sym->getFile() != this) { in registerCompactUnwind()
1172 add += sym->value; in registerCompactUnwind()
1173 referentIsec = cast<ConcatInputSection>(sym->isec()); in registerCompactUnwind()
1183 if (referentIsec->getSegName() != segment_names::text) in registerCompactUnwind()
1184 error(isec->getLocation(r.offset) + " references section " + in registerCompactUnwind()
1185 referentIsec->getName() + " which is not in segment __TEXT"); in registerCompactUnwind()
1187 // However, unwind info operates on a per-symbol basis, so we search for in registerCompactUnwind()
1194 d->originalUnwindEntry = isec; in registerCompactUnwind()
1199 // this keeps dead-stripping simple. in registerCompactUnwind()
1206 // UnwindInfoSection takes care of this by re-duplicating the CUEs so that in registerCompactUnwind()
1212 it = isec->relocs.erase(it); in registerCompactUnwind()
1227 return target->wordSize; in pointerEncodingToSize()
1241 // pain. We instead take advantage of our knowledge of how llvm-mc encodes in parseCIE()
1291 const auto *personalityReloc = isec->getRelocAt(personalityAddrOff); in parseCIE()
1294 cie.personalitySymbol = personalityReloc->referent.get<macho::Symbol *>(); in parseCIE()
1304 // Concretely, we expect our relocations to write the value of `PC -
1311 // For example, for arm64, llvm-mc emits relocations for the target function
1320 // <target function address - (ltmp + pcrel offset)>
1323 // If any of the FDEs in `multiple FDEs` get dead-stripped, then `FDE start`
1327 // the reloc to be `target function address - (EH_Frame + new pcrel offset)`.
1329 // If `Invert` is set, then we instead expect `target_addr - PC` to be written
1337 assert(target->hasAttr(subtrahend.type, RelocAttrBits::SUBTRAHEND)); in targetSymFromCanonicalSubtractor()
1338 assert(target->hasAttr(minuend.type, RelocAttrBits::UNSIGNED)); in targetSymFromCanonicalSubtractor()
1339 // Note: pcSym may *not* be exactly at the PC; there's usually a non-zero in targetSymFromCanonicalSubtractor()
1351 if (pcSym->isec() == isec) { in targetSymFromCanonicalSubtractor()
1352 if (pcSym->value - (Invert ? -1 : 1) * minuend.addend != subtrahend.offset) in targetSymFromCanonicalSubtractor()
1358 // `oldSym->value + oldOffset == newSym + newOffset`. However, we don't in targetSymFromCanonicalSubtractor()
1362 pcReloc.referent = isec->symbols[0]; in targetSymFromCanonicalSubtractor()
1363 assert(isec->symbols[0]->value == 0); in targetSymFromCanonicalSubtractor()
1364 minuend.addend = pcReloc.offset * (Invert ? 1LL : -1LL); in targetSymFromCanonicalSubtractor()
1377 // general-purpose (and verbose) DWARF unwind info found in __eh_frame.
1382 // While parsing, we also look for what MC calls "abs-ified" relocations -- they
1388 // relocations. This is the case when e.g. it's the output of `ld -r`. We only
1389 // look for the "abs-ified" relocation if an explicit relocation is absent.
1399 if (isec->symbols.size() == 0) in registerEhFrames()
1400 make<Defined>("EH_Frame", isec->getFile(), isec, /*value=*/0, in registerEhFrames()
1401 isec->getSize(), /*isWeakDef=*/false, /*isExternal=*/false, in registerEhFrames()
1405 else if (isec->symbols[0]->value != 0) in registerEhFrames()
1408 EhReader reader(this, isec->data, subsec.offset); in registerEhFrames()
1417 isec->relocs, [=](const Reloc &r) { return r.offset == cieOffOff; }); in registerEhFrames()
1419 if (cieOffRelocIt != isec->relocs.end()) { in registerEhFrames()
1423 ->isec(); in registerEhFrames()
1427 // embedded in the section data (AKA an "abs-ified" reloc.). Parse that in registerEhFrames()
1433 uint32_t cieOff = isecOff + dataOff - cieMinuend; in registerEhFrames()
1439 ehRelocator.makeNegativePcRel(cieOffOff, cieIsec->symbols[0], in registerEhFrames()
1466 auto funcAddrRelocIt = isec->relocs.end(); in registerEhFrames()
1467 auto lsdaAddrRelocIt = isec->relocs.end(); in registerEhFrames()
1468 for (auto it = isec->relocs.begin(); it != isec->relocs.end(); ++it) { in registerEhFrames()
1469 if (it->offset == funcAddrOff) in registerEhFrames()
1471 else if (lsdaAddrOpt && it->offset == lsdaAddrOff) in registerEhFrames()
1476 if (funcAddrRelocIt != isec->relocs.end()) { in registerEhFrames()
1482 // infrequently (only when handling the output of `ld -r`). in registerEhFrames()
1483 if (funcSym->isec()) in registerEhFrames()
1484 funcSym = findSymbolAtOffset(cast<ConcatInputSection>(funcSym->isec()), in registerEhFrames()
1485 funcSym->value); in registerEhFrames()
1488 ehRelocator.makePcRel(funcAddrOff, funcSym, target->p2WordSize); in registerEhFrames()
1491 if (!funcSym || funcSym->getFile() != this || funcSym->unwindEntry()) { in registerEhFrames()
1493 // -dead_strip being enabled. in registerEhFrames()
1494 isec->live = false; in registerEhFrames()
1499 if (lsdaAddrRelocIt != isec->relocs.end()) { in registerEhFrames()
1501 targetSymFromCanonicalSubtractor(isec, lsdaAddrRelocIt)->isec(); in registerEhFrames()
1507 ehRelocator.makePcRel(lsdaAddrOff, lsdaIsec, target->p2WordSize); in registerEhFrames()
1511 funcSym->originalUnwindEntry = isec; in registerEhFrames()
1518 // dead-stripping will just work as usual, and S_ATTR_LIVE_SUPPORT will only in registerEhFrames()
1519 // serve to incorrectly prevent us from dead-stripping duplicate FDEs for a in registerEhFrames()
1521 // let dead-stripping proceed correctly. in registerEhFrames()
1526 const char *unitName = compileUnit->getUnitDIE().getShortName(); in sourceFile()
1535 SmallString<261> dir(compileUnit->getCompilationDir()); in sourceFile()
1571 // processing a given TBD file, we store that top-level document in
1572 // currentTopLevelTapi. When processing re-exports, we search its children for
1574 // themselves don't point to further documents, i.e. this is a two-level tree.
1576 // Re-exports can either refer to on-disk files, or to documents within .tbd
1581 // 1. Install name basename in -F / -L directories. in findDylib()
1588 for (StringRef dir : config->frameworkSearchPaths) { in findDylib()
1596 stem, config->librarySearchPaths, {".tbd", ".dylib", ".so"})) in findDylib()
1602 for (StringRef root : config->systemLibraryRoots) in findDylib()
1609 // TODO: Handle -dylib_file in findDylib()
1613 if (config->outputType == MH_EXECUTE && in findDylib()
1615 // ld64 allows overriding this with the undocumented flag -executable_path. in findDylib()
1618 path::append(newPath, path::parent_path(config->outputFile), path); in findDylib()
1621 fs::real_path(umbrella->getName(), newPath); in findDylib()
1626 for (StringRef rpath : umbrella->rpaths) { in findDylib()
1629 fs::real_path(umbrella->getName(), newPath); in findDylib()
1641 make_pointee_range(currentTopLevelTapi->documents())) { in findDylib()
1646 file->parseReexports(child); in findDylib()
1658 // If a re-exported dylib is public (lives in /usr/lib or
1660 // should bind to its symbols directly instead of via the re-exporting umbrella
1663 if (!config->implicitDylibs) in isImplicitlyLinked()
1682 error(toString(this) + ": unable to locate re-export with install name " + in loadReexport()
1693 this->umbrella = umbrella; in DylibFile()
1700 currentVersion = read32le(&c->dylib.current_version); in DylibFile()
1701 compatibilityVersion = read32le(&c->dylib.compatibility_version); in DylibFile()
1703 reinterpret_cast<const char *>(cmd) + read32le(&c->dylib.name); in DylibFile()
1711 if (config->printEachFile) in DylibFile()
1715 deadStrippable = hdr->flags & MH_DEAD_STRIPPABLE_DYLIB; in DylibFile()
1720 checkAppExtensionSafety(hdr->flags & MH_APP_EXTENSION_SAFE); in DylibFile()
1723 StringRef rpath{reinterpret_cast<const char *>(cmd) + cmd->path}; in DylibFile()
1731 : this->umbrella; in DylibFile()
1745 parseExportedSymbols(dyldInfo->export_off, dyldInfo->export_size); in DylibFile()
1747 parseExportedSymbols(exportsTrie->dataoff, exportsTrie->datasize); in DylibFile()
1772 if (exportingFile->hiddenSymbols.contains(CachedHashStringRef(entry.name))) in parseExportedSymbols()
1779 symtab->addDylib(entry.name, exportingFile, isWeakDef, isTlv)); in parseExportedSymbols()
1786 target->headerSize; in parseLoadCommands()
1787 for (uint32_t i = 0, n = hdr->ncmds; i < n; ++i) { in parseLoadCommands()
1789 p += cmd->cmdsize; in parseLoadCommands()
1791 if (!(hdr->flags & MH_NO_REEXPORTED_DYLIBS) && in parseLoadCommands()
1792 cmd->cmd == LC_REEXPORT_DYLIB) { in parseLoadCommands()
1795 reinterpret_cast<const char *>(c) + read32le(&c->dylib.name); in parseLoadCommands()
1801 // MH_NO_REEXPORTED_DYLIBS loaded for -flat_namespace)? in parseLoadCommands()
1802 if (config->namespaceKind == NamespaceKind::flat && in parseLoadCommands()
1803 cmd->cmd == LC_LOAD_DYLIB) { in parseLoadCommands()
1806 reinterpret_cast<const char *>(c) + read32le(&c->dylib.name); in parseLoadCommands()
1810 "' loaded from '" + toString(this) + "' for -flat_namespace"); in parseLoadCommands()
1824 // Catalyst outputs can link against implicitly linked macOS-only libraries. in skipPlatformCheckForCatalyst()
1825 if (config->platform() != PLATFORM_MACCATALYST || explicitlyLinked) in skipPlatformCheckForCatalyst()
1828 MachO::Target(config->arch(), PLATFORM_MACOS)); in skipPlatformCheckForCatalyst()
1848 if (config->forceExactCpuSubtypeMatch) in isTargetPlatformArchCompatible()
1869 this->umbrella = umbrella; in DylibFile()
1875 if (config->printEachFile) in DylibFile()
1881 config->platformInfo.target) && in DylibFile()
1884 std::string(config->platformInfo.target)); in DylibFile()
1895 const Twine &name) -> void { in DylibFile()
1897 if (exportingFile->hiddenSymbols.contains(CachedHashStringRef(savedName))) in DylibFile()
1900 symbols.push_back(symtab->addDylib(savedName, exportingFile, in DylibFile()
1908 if (!isArchABICompatible(symbol->getArchitectures(), config->arch())) in DylibFile()
1910 if (handleLDSymbol(symbol->getName())) in DylibFile()
1913 switch (symbol->getKind()) { in DylibFile()
1921 // interface.symbols() order is non-deterministic. in DylibFile()
1923 [](auto *l, auto *r) { return l->getName() < r->getName(); }); in DylibFile()
1927 switch (symbol->getKind()) { in DylibFile()
1929 addSymbol(*symbol, symbol->getName()); in DylibFile()
1932 // XXX ld64 only creates these symbols when -ObjC is passed in. We may in DylibFile()
1934 addSymbol(*symbol, objc::symbol_names::klass + symbol->getName()); in DylibFile()
1935 addSymbol(*symbol, objc::symbol_names::metaclass + symbol->getName()); in DylibFile()
1938 addSymbol(*symbol, objc::symbol_names::ehtype + symbol->getName()); in DylibFile()
1941 addSymbol(*symbol, objc::symbol_names::ivar + symbol->getName()); in DylibFile()
1952 this->umbrella = umbrella;
1961 isTargetPlatformArchCompatible(targets, config->platformInfo.target)) in parseReexports()
1975 if (dylib->isReferenced()) in isExplicitlyLinked()
1985 if (dylib->installName == installName) { in getSyntheticDylib()
1992 dylib->installName = saver().save(installName); in getSyntheticDylib()
1993 dylib->currentVersion = currentVersion; in getSyntheticDylib()
1994 dylib->compatibilityVersion = compatVersion; in getSyntheticDylib()
2020 // <platformstr> $ <startversion> $ <endversion> $ <symbol-name> $ in handleLDPreviousSymbol()
2039 platform != static_cast<unsigned>(config->platform())) in handleLDPreviousSymbol()
2054 if (config->platformInfo.target.MinDeployment < start || in handleLDPreviousSymbol()
2055 config->platformInfo.target.MinDeployment >= end) in handleLDPreviousSymbol()
2087 dylib->symbols.push_back(symtab->addDylib( in handleLDPreviousSymbol()
2093 this->installName = saver().save(installName); in handleLDPreviousSymbol()
2094 this->compatibilityVersion = newCompatibilityVersion; in handleLDPreviousSymbol()
2106 else if (version == config->platformInfo.target.MinDeployment) in handleLDInstallNameSymbol()
2107 this->installName = saver().save(installName); in handleLDInstallNameSymbol()
2124 shouldHide = versionTup == config->platformInfo.target.MinDeployment; in handleLDHideSymbol()
2130 exportingFile->hiddenSymbols.insert(CachedHashStringRef(symbolName)); in handleLDHideSymbol()
2134 if (config->applicationExtension && !dylibIsAppExtensionSafe) in checkAppExtensionSafety()
2135 warn("using '-application_extension' with unsafe dylib: " + toString(this)); in checkAppExtensionSafety()
2139 : InputFile(ArchiveKind, f->getMemoryBufferRef()), file(std::move(f)), in ArchiveFile()
2143 // Avoid calling getMemoryBufferRef() on zero-symbol archive in addLazySymbols()
2145 if (file->isEmpty() || file->getNumberOfSymbols() == 0) in addLazySymbols()
2149 auto child = file->child_begin(err); in addLazySymbols()
2150 // Ignore the I/O error here - will be reported later. in addLazySymbols()
2152 Expected<MemoryBufferRef> mbOrErr = child->getMemoryBufferRef(); in addLazySymbols()
2156 if (identify_magic(mbOrErr->getBuffer()) == file_magic::macho_object) { in addLazySymbols()
2157 if (target->wordSize == 8) in addLazySymbols()
2160 mbOrErr->getBufferStart())); in addLazySymbols()
2164 mbOrErr->getBufferStart())); in addLazySymbols()
2171 for (const object::Archive::Symbol &sym : file->symbols()) in addLazySymbols()
2172 symtab->addLazyArchive(sym.getName(), this, sym); in addLazySymbols()
2178 if (config->zeroModTime) in loadArchiveMember()
2230 // ld64 doesn't demangle sym here even with -demangle. in fetch()
2242 return symtab->addUndefined(name, &file, /*isWeakRef=*/objSym.isWeak()); in createBitcodeSymbol()
2252 error(name + " has protected visibility, which is not supported by Mach-O"); in createBitcodeSymbol()
2261 return symtab->addCommon(name, &file, objSym.getCommonSize(), in createBitcodeSymbol()
2264 return symtab->addDefined(name, &file, /*isec=*/nullptr, /*value=*/0, in createBitcodeSymbol()
2275 this->archiveName = std::string(archiveName); in BitcodeFile()
2276 this->compatArch = compatArch; in BitcodeFile()
2278 if (config->thinLTOIndexOnly) in BitcodeFile()
2309 symbols.resize(obj->symbols().size()); in parse()
2313 for (auto it : llvm::enumerate(obj->symbols())) in parse()
2316 for (auto it : llvm::enumerate(obj->symbols())) in parse()
2322 symbols.resize(obj->symbols().size()); in parseLazy()
2323 for (const auto &[i, objSym] : llvm::enumerate(obj->symbols())) { in parseLazy()
2325 symbols[i] = symtab->addLazyObject(saver().save(objSym.getName()), *this); in parseLazy()
2333 auto [suffix, repl] = config->thinLTOObjectSuffixReplace; in replaceThinLTOSuffix()
2346 bitcode->parse(); in extract()
2349 if (target->wordSize == 8) in extract()