Lines Matching refs:atom
49 const DefinedAtom *atom; member
116 void processAtomAttributes(const DefinedAtom *atom);
117 void assignAtomToSection(const DefinedAtom *atom);
159 void appendAtom(SectionInfo *sect, const DefinedAtom *atom);
164 uint16_t descBits(const DefinedAtom* atom);
170 llvm::Error getSymbolTableRegion(const DefinedAtom* atom,
174 uint32_t sectionIndexForAtom(const Atom *atom);
175 void fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
179 struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; }; member
344 SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) { in sectionForAtom() argument
345 if (atom->sectionChoice() == DefinedAtom::sectionBasedOnContent) { in sectionForAtom()
347 DefinedAtom::ContentType type = atom->contentType(); in sectionForAtom()
355 StringRef customName = atom->customSectionName(); in sectionForAtom()
358 const DefinedAtom *firstAtom = sect->atomsAndOffsets.front().atom; in sectionForAtom()
377 void Util::appendAtom(SectionInfo *sect, const DefinedAtom *atom) { in appendAtom() argument
380 DefinedAtom::Alignment atomAlign = atom->alignment(); in appendAtom()
394 AtomInfo ai = {atom, offset}; in appendAtom()
397 sect->size = offset + atom->size(); in appendAtom()
401 for (const DefinedAtom *atom : atomFile.defined()) { in processDefinedAtoms() local
402 processAtomAttributes(atom); in processDefinedAtoms()
403 assignAtomToSection(atom); in processDefinedAtoms()
407 void Util::processAtomAttributes(const DefinedAtom *atom) { in processAtomAttributes() argument
408 if (auto *machoFile = dyn_cast<mach_o::MachOFile>(&atom->file())) { in processAtomAttributes()
429 void Util::assignAtomToSection(const DefinedAtom *atom) { in assignAtomToSection() argument
430 if (atom->contentType() == DefinedAtom::typeMachHeader) { in assignAtomToSection()
431 _machHeaderAliasAtoms.push_back(atom); in assignAtomToSection()
433 AtomInfo ai = {atom, 0}; in assignAtomToSection()
434 sectionForAtom(atom)->atomsAndOffsets.push_back(ai); in assignAtomToSection()
435 } else if (atom->contentType() == DefinedAtom::typeDSOHandle) in assignAtomToSection()
436 _machHeaderAliasAtoms.push_back(atom); in assignAtomToSection()
438 appendAtom(sectionForAtom(atom), atom); in assignAtomToSection()
657 auto addrForAtom = [&] (const Atom &atom) -> uint64_t { in copySectionContent() argument
658 auto pos = _atomToAddress.find(&atom); in copySectionContent()
663 auto sectionAddrForAtom = [&] (const Atom &atom) -> uint64_t { in copySectionContent() argument
666 if (atomInfo.atom == &atom) in copySectionContent()
686 if (!ai.atom->size()) { in copySectionContent()
687 assert(ai.atom->begin() == ai.atom->end() && in copySectionContent()
692 ai.atom->size()); in copySectionContent()
693 _archHandler.generateAtomContent(*ai.atom, r, addrForAtom, in copySectionContent()
744 _atomToAddress[info.atom] = sect->address + info.offsetInSection; in buildAtomToAddressMap()
745 if (lookForEntry && (info.atom->contentType() == DefinedAtom::typeCode) && in buildAtomToAddressMap()
746 (info.atom->size() != 0) && in buildAtomToAddressMap()
747 info.atom->name() == _ctx.entrySymbolName()) { in buildAtomToAddressMap()
748 _entryAtom = info.atom; in buildAtomToAddressMap()
752 << llvm::format("0x%016X", _atomToAddress[info.atom]) in buildAtomToAddressMap()
753 << llvm::format(" 0x%09lX", info.atom) in buildAtomToAddressMap()
755 << info.atom->file().ordinal() in buildAtomToAddressMap()
757 << info.atom->ordinal() in buildAtomToAddressMap()
759 << info.atom->name() in buildAtomToAddressMap()
761 << info.atom->contentType() in buildAtomToAddressMap()
767 for (const Atom *atom : _machHeaderAliasAtoms) { in buildAtomToAddressMap() local
768 _atomToAddress[atom] = _ctx.baseAddress(); in buildAtomToAddressMap()
770 if (auto *definedAtom = dyn_cast<DefinedAtom>(atom)) { in buildAtomToAddressMap()
773 << llvm::format("0x%016X", _atomToAddress[atom]) in buildAtomToAddressMap()
774 << llvm::format(" 0x%09lX", atom) in buildAtomToAddressMap()
787 << llvm::format("0x%016X", _atomToAddress[atom]) in buildAtomToAddressMap()
788 << " atom=" << atom in buildAtomToAddressMap()
789 << " name=" << atom->name() << "\n"); in buildAtomToAddressMap()
808 if (const DefinedAtom *atom = dyn_cast<DefinedAtom>(info.atom)) { in synthesizeDebugNotes() local
814 if (atom->contentType() == DefinedAtom::typeCFI || in synthesizeDebugNotes()
815 atom->contentType() == DefinedAtom::typeCString) in synthesizeDebugNotes()
819 if (&info.atom->file() != objFile) { in synthesizeDebugNotes()
822 dyn_cast<mach_o::MachOFile>(&info.atom->file())) { in synthesizeDebugNotes()
834 atomsNeedingDebugNotes.push_back(info.atom); in synthesizeDebugNotes()
855 for (const DefinedAtom *atom : atomsNeedingDebugNotes) { in synthesizeDebugNotes() local
856 const auto &atomFile = cast<mach_o::MachOFile>(atom->file()); in synthesizeDebugNotes()
912 if (atom->contentType() == DefinedAtom::typeCode) { in synthesizeDebugNotes()
914 _stabs.push_back(mach_o::Stab(atom, N_BNSYM, 1, 0, 0, "")); in synthesizeDebugNotes()
915 _stabs.push_back(mach_o::Stab(atom, N_FUN, 1, 0, 0, atom->name())); in synthesizeDebugNotes()
919 atom->rawContent().size(), "")); in synthesizeDebugNotes()
921 atom->rawContent().size(), "")); in synthesizeDebugNotes()
923 if (atom->scope() == Atom::scopeTranslationUnit) in synthesizeDebugNotes()
924 _stabs.push_back(mach_o::Stab(atom, N_STSYM, 1, 0, 0, atom->name())); in synthesizeDebugNotes()
926 _stabs.push_back(mach_o::Stab(nullptr, N_GSYM, 1, 0, 0, atom->name())); in synthesizeDebugNotes()
947 uint16_t Util::descBits(const DefinedAtom* atom) { in descBits() argument
949 switch (atom->merge()) { in descBits()
963 if (atom->contentType() == lld::DefinedAtom::typeResolver) in descBits()
965 if (atom->contentType() == lld::DefinedAtom::typeMachHeader) in descBits()
967 if (_archHandler.isThumbFunction(*atom)) in descBits()
969 if (atom->deadStrip() == DefinedAtom::deadStripNever && in descBits()
971 if ((atom->contentType() != DefinedAtom::typeInitializerPtr) in descBits()
972 && (atom->contentType() != DefinedAtom::typeTerminatorPtr)) in descBits()
980 return (left.atom->name().compare(right.atom->name()) < 0); in operator ()()
983 llvm::Error Util::getSymbolTableRegion(const DefinedAtom* atom, in getSymbolTableRegion() argument
987 switch (atom->scope()) { in getSymbolTableRegion()
994 _ctx.exportSymbolNamed(atom->name())) { in getSymbolTableRegion()
996 Twine("cannot export hidden symbol ") + atom->name()); in getSymbolTableRegion()
1012 if (_ctx.exportSymbolNamed(atom->name())) { in getSymbolTableRegion()
1045 if (stab.atom) in addSymbols()
1046 sym.value = _atomToAddress[stab.atom]; in addSymbols()
1058 const DefinedAtom *atom = info.atom; in addSymbols() local
1059 if (!atom->name().empty()) { in addSymbols()
1062 if (auto ec = getSymbolTableRegion(atom, inGlobalsRegion, symbolScope)){ in addSymbols()
1066 AtomAndIndex ai = { atom, sect->finalSectionIndex, symbolScope }; in addSymbols()
1070 sym.name = atom->name(); in addSymbols()
1074 sym.desc = descBits(atom); in addSymbols()
1075 sym.value = _atomToAddress[atom]; in addSymbols()
1076 _atomToSymbolIndex[atom] = file.localSymbols.size(); in addSymbols()
1079 } else if (rMode && _archHandler.needsLocalSymbolInRelocatableFile(atom)){ in addSymbols()
1091 sym.value = _atomToAddress[atom]; in addSymbols()
1092 _atomToSymbolIndex[atom] = file.localSymbols.size(); in addSymbols()
1103 sym.name = ai.atom->name(); in addSymbols()
1107 sym.desc = descBits(static_cast<const DefinedAtom*>(ai.atom)); in addSymbols()
1108 sym.value = _atomToAddress[ai.atom]; in addSymbols()
1109 _atomToSymbolIndex[ai.atom] = globalStartIndex + file.globalSymbols.size(); in addSymbols()
1116 for (const UndefinedAtom *atom : atomFile.undefined()) { in addSymbols() local
1117 AtomAndIndex ai = { atom, 0, N_EXT }; in addSymbols()
1120 for (const SharedLibraryAtom *atom : atomFile.sharedLibrary()) { in addSymbols() local
1121 AtomAndIndex ai = { atom, 0, N_EXT }; in addSymbols()
1132 ordinal = dylibOrdinal(dyn_cast<SharedLibraryAtom>(ai.atom)); in addSymbols()
1135 sym.name = ai.atom->name(); in addSymbols()
1141 _atomToSymbolIndex[ai.atom] = file.undefinedSymbols.size() + start; in addSymbols()
1177 for (const Reference *ref : *info.atom) { in addIndirectSymbols()
1198 const Atom *target = targetOfLazyPointer(info.atom); in addIndirectSymbols()
1207 const Atom *target = targetOfStub(info.atom); in addIndirectSymbols()
1283 uint32_t Util::sectionIndexForAtom(const Atom *atom) { in sectionIndexForAtom() argument
1284 uint64_t address = _atomToAddress[atom]; in sectionIndexForAtom()
1297 auto symIndexForAtom = [&] (const Atom &atom) -> uint32_t { in addSectionRelocs() argument
1298 auto pos = _atomToSymbolIndex.find(&atom); in addSectionRelocs()
1304 auto sectIndexForAtom = [&] (const Atom &atom) -> uint32_t { in addSectionRelocs() argument
1305 return sectionIndexForAtom(&atom); in addSectionRelocs()
1309 auto addressForAtom = [&] (const Atom &atom) -> uint64_t { in addSectionRelocs() argument
1310 auto pos = _atomToAddress.find(&atom); in addSectionRelocs()
1318 const DefinedAtom *atom = info.atom; in addSectionRelocs() local
1319 for (const Reference *ref : *atom) { in addSectionRelocs()
1325 _archHandler.appendSectionRelocations(*atom, info.offsetInSection, *ref, in addSectionRelocs()
1344 auto type = info.atom->contentType(); in addFunctionStarts()
1346 addr = _atomToAddress[info.atom]; in addFunctionStarts()
1354 if (!info.atom->size()) in addFunctionStarts()
1356 uint64_t nextAddr = _atomToAddress[info.atom]; in addFunctionStarts()
1357 if (_archHandler.isThumbFunction(*info.atom)) in addFunctionStarts()
1390 for (const Reference *ref : *info.atom) { in buildDataInCodeArray()
1413 entry.length = info.atom->size() - startOffset; in buildDataInCodeArray()
1433 const DefinedAtom *atom = info.atom; in addRebaseAndBindingInfo() local
1434 for (const Reference *ref : *atom) { in addRebaseAndBindingInfo()
1435 uint64_t segmentOffset = _atomToAddress[atom] + ref->offsetInAtom() in addRebaseAndBindingInfo()
1478 fixLazyReferenceImm(atom, offsetInBindInfo, nFile); in addRebaseAndBindingInfo()
1492 void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset, in fixLazyReferenceImm() argument
1494 for (const auto &ref : *atom) { in fixLazyReferenceImm()
1512 if (atomInfo.atom == helperRef->target()) { in fixLazyReferenceImm()
1539 const DefinedAtom *atom = info.atom; in addExportInfo() local
1540 if (atom->scope() != Atom::scopeGlobal) in addExportInfo()
1543 if (!_ctx.exportSymbolNamed(atom->name())) in addExportInfo()
1547 exprt.name = atom->name(); in addExportInfo()
1548 exprt.offset = _atomToAddress[atom] - _ctx.baseAddress(); in addExportInfo()
1550 if (atom->merge() == DefinedAtom::mergeAsWeak) in addExportInfo()