Lines Matching refs:sym

67 static Optional<std::string> getLinkerScriptLocation(const Symbol &sym) {  in getLinkerScriptLocation()  argument
70 if (assign->sym == &sym) in getLinkerScriptLocation()
75 static std::string getDefinedLocation(const Symbol &sym) { in getDefinedLocation() argument
77 if (sym.file) in getDefinedLocation()
78 return msg + toString(sym.file); in getDefinedLocation()
79 if (Optional<std::string> loc = getLinkerScriptLocation(sym)) in getDefinedLocation()
89 static std::string getLocation(InputSectionBase &s, const Symbol &sym, in getLocation() argument
91 std::string msg = getDefinedLocation(sym) + "\n>>> referenced by "; in getLocation()
92 std::string src = s.getSrcMsg(sym, off); in getLocation()
102 if (rel.sym && !rel.sym->isSection()) in reportRangeError()
103 hint = "; references " + lld::toString(*rel.sym); in reportRangeError()
106 if (rel.sym && !rel.sym->isSection()) in reportRangeError()
107 hint += getDefinedLocation(*rel.sym); in reportRangeError()
118 void elf::reportRangeError(uint8_t *loc, int64_t v, int n, const Symbol &sym, in reportRangeError() argument
122 if (!sym.getName().empty()) in reportRangeError()
123 hint = "; references " + lld::toString(sym) + getDefinedLocation(sym); in reportRangeError()
179 static bool isAbsolute(const Symbol &sym) { in isAbsolute() argument
180 if (sym.isUndefWeak()) in isAbsolute()
182 if (const auto *dr = dyn_cast<Defined>(&sym)) in isAbsolute()
187 static bool isAbsoluteValue(const Symbol &sym) { in isAbsoluteValue() argument
188 return isAbsolute(sym) || sym.isTls(); in isAbsoluteValue()
278 Symbol *sym = symtab->find(name); in getSymbolsAt() local
279 if (auto *alias = dyn_cast_or_null<SharedSymbol>(sym)) in getSymbolsAt()
297 static void replaceWithDefined(Symbol &sym, SectionBase &sec, uint64_t value, in replaceWithDefined() argument
299 Symbol old = sym; in replaceWithDefined()
301 sym.replace(Defined{sym.file, StringRef(), sym.binding, sym.stOther, in replaceWithDefined()
302 sym.type, value, size, &sec}); in replaceWithDefined()
304 sym.auxIdx = old.auxIdx; in replaceWithDefined()
305 sym.verdefIndex = old.verdefIndex; in replaceWithDefined()
306 sym.exportDynamic = true; in replaceWithDefined()
307 sym.isUsedInRegularObj = true; in replaceWithDefined()
309 sym.needsGot = old.needsGot; in replaceWithDefined()
379 for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss)) in addCopyRelSymbol()
380 replaceWithDefined(*sym, *sec, 0, sym->size); in addCopyRelSymbol()
453 bool isStaticLinkTimeConstant(RelExpr e, RelType type, const Symbol &sym,
455 void processAux(RelExpr expr, RelType type, uint64_t offset, Symbol &sym,
522 static std::string maybeReportDiscarded(Undefined &sym) { in maybeReportDiscarded() argument
523 auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file); in maybeReportDiscarded()
524 if (!file || !sym.discardedSecIdx || in maybeReportDiscarded()
525 file->getSections()[sym.discardedSecIdx] != &InputSection::discarded) in maybeReportDiscarded()
531 if (sym.type == ELF::STT_SECTION) { in maybeReportDiscarded()
534 file->getObj().getSectionName(objSections[sym.discardedSecIdx]), file); in maybeReportDiscarded()
537 toString(sym); in maybeReportDiscarded()
541 Elf_Shdr_Impl<ELFT> elfSec = objSections[sym.discardedSecIdx - 1]; in maybeReportDiscarded()
551 if (sym.nonPrevailing) { in maybeReportDiscarded()
566 Undefined *sym; member
596 static const Symbol *getAlternativeSpelling(const Undefined &sym, in getAlternativeSpelling() argument
600 if (sym.file && sym.file->kind() == InputFile::ObjKind) { in getAlternativeSpelling()
601 auto *file = cast<ELFFileBase>(sym.file); in getAlternativeSpelling()
604 if (file && sym.discardedSecIdx != 0 && in getAlternativeSpelling()
605 file->getSections()[sym.discardedSecIdx] == &InputSection::discarded) in getAlternativeSpelling()
609 for (const Symbol *s : sym.file->getSymbols()) in getAlternativeSpelling()
630 StringRef name = sym.getName(); in getAlternativeSpelling()
669 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
670 if (!sym->isUndefined() && name.equals_insensitive(sym->getName())) in getAlternativeSpelling()
671 return sym; in getAlternativeSpelling()
695 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
696 if (canSuggestExternCForCXX(name, sym->getName())) { in getAlternativeSpelling()
697 s = sym; in getAlternativeSpelling()
712 Undefined &sym = *undef.sym; in reportUndefinedSymbol() local
715 switch (sym.visibility) { in reportUndefinedSymbol()
730 msg = maybeReportDiscarded<ELF32LE>(sym); in reportUndefinedSymbol()
733 msg = maybeReportDiscarded<ELF32BE>(sym); in reportUndefinedSymbol()
736 msg = maybeReportDiscarded<ELF64LE>(sym); in reportUndefinedSymbol()
739 msg = maybeReportDiscarded<ELF64BE>(sym); in reportUndefinedSymbol()
745 msg = "undefined " + visibility() + "symbol: " + toString(sym); in reportUndefinedSymbol()
756 std::string src = sec.getSrcMsg(sym, offset); in reportUndefinedSymbol()
770 getAlternativeSpelling(sym, pre_hint, post_hint)) { in reportUndefinedSymbol()
777 if (sym.getName().startswith("_ZTV")) in reportUndefinedSymbol()
782 sym.getName().startswith("__start_")) { in reportUndefinedSymbol()
791 error(msg, ErrorTag::SymbolNotFound, {sym.getName()}); in reportUndefinedSymbol()
800 if (UndefinedDiag *canon = firstRef.lookup(undef.sym)) { in reportUndefinedSymbols()
804 firstRef[undef.sym] = &undef; in reportUndefinedSymbols()
816 static bool maybeReportUndefined(Undefined &sym, InputSectionBase &sec, in maybeReportUndefined() argument
820 if (sym.hasVersionSuffix) { in maybeReportUndefined()
821 undefs.push_back({&sym, {{&sec, offset}}, false}); in maybeReportUndefined()
824 if (sym.isWeak()) in maybeReportUndefined()
827 bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT; in maybeReportUndefined()
840 if (sym.discardedSecIdx != 0 && (sec.name == ".got2" || sec.name == ".toc")) in maybeReportUndefined()
846 undefs.push_back({&sym, {{&sec, offset}}, isWarning}); in maybeReportUndefined()
867 Symbol &sym, int64_t addend, RelExpr expr, in addRelativeReloc() argument
878 isec.relocations.push_back({expr, type, offsetInSec, addend, &sym}); in addRelativeReloc()
882 part.relaDyn->addRelativeReloc(target->relativeRel, isec, offsetInSec, sym, in addRelativeReloc()
888 RelocationBaseSection &rel, RelType type, Symbol &sym) { in addPltEntry() argument
889 plt.addEntry(sym); in addPltEntry()
890 gotPlt.addEntry(sym); in addPltEntry()
891 rel.addReloc({type, &gotPlt, sym.getGotPltOffset(), in addPltEntry()
892 sym.isPreemptible ? DynamicReloc::AgainstSymbol in addPltEntry()
894 sym, 0, R_ABS}); in addPltEntry()
897 static void addGotEntry(Symbol &sym) { in addGotEntry() argument
898 in.got->addEntry(sym); in addGotEntry()
899 uint64_t off = sym.getGotOffset(); in addGotEntry()
902 if (sym.isPreemptible) { in addGotEntry()
904 DynamicReloc::AgainstSymbol, sym, 0, R_ABS}); in addGotEntry()
910 if (!config->isPic || isAbsolute(sym)) in addGotEntry()
911 in.got->relocations.push_back({R_ABS, target->symbolicRel, off, 0, &sym}); in addGotEntry()
913 addRelativeReloc(*in.got, off, sym, 0, R_ABS, target->symbolicRel); in addGotEntry()
916 static void addTpOffsetGotEntry(Symbol &sym) { in addTpOffsetGotEntry() argument
917 in.got->addEntry(sym); in addTpOffsetGotEntry()
918 uint64_t off = sym.getGotOffset(); in addTpOffsetGotEntry()
919 if (!sym.isPreemptible && !config->isPic) { in addTpOffsetGotEntry()
920 in.got->relocations.push_back({R_TPREL, target->symbolicRel, off, 0, &sym}); in addTpOffsetGotEntry()
924 target->tlsGotRel, *in.got, off, sym, target->symbolicRel); in addTpOffsetGotEntry()
930 static bool canDefineSymbolInExecutable(Symbol &sym) { in canDefineSymbolInExecutable() argument
936 if ((sym.stOther & 0x3) == STV_DEFAULT) in canDefineSymbolInExecutable()
943 return ((sym.isFunc() && config->ignoreFunctionAddressEquality) || in canDefineSymbolInExecutable()
944 (sym.isObject() && config->ignoreDataAddressEquality)); in canDefineSymbolInExecutable()
958 const Symbol &sym, in isStaticLinkTimeConstant() argument
973 if (sym.isPreemptible) in isStaticLinkTimeConstant()
984 bool absVal = isAbsoluteValue(sym); in isStaticLinkTimeConstant()
1000 if (sym.isUndefWeak()) in isStaticLinkTimeConstant()
1005 if (sym.scriptDefined) in isStaticLinkTimeConstant()
1009 toString(sym) + getLocation(sec, sym, relOff)); in isStaticLinkTimeConstant()
1027 Symbol &sym, int64_t addend) const { in processAux() argument
1042 if (isStaticLinkTimeConstant(expr, type, sym, offset) || in processAux()
1043 (!config->isPic && sym.isUndefWeak())) { in processAux()
1044 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processAux()
1051 if (expr == R_GOT || (rel == target.symbolicRel && !sym.isPreemptible)) { in processAux()
1052 addRelativeReloc(sec, offset, sym, addend, expr, type); in processAux()
1057 sec.getPartition().relaDyn->addSymbolReloc(rel, sec, offset, sym, addend, in processAux()
1076 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in processAux()
1084 if (!canDefineSymbolInExecutable(sym)) { in processAux()
1085 errorOrWarn("cannot preempt symbol: " + toString(sym) + in processAux()
1086 getLocation(sec, sym, offset)); in processAux()
1090 if (sym.isObject()) { in processAux()
1092 if (auto *ss = dyn_cast<SharedSymbol>(&sym)) { in processAux()
1097 getLocation(sec, sym, offset)); in processAux()
1098 sym.needsCopy = true; in processAux()
1100 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processAux()
1131 if (sym.isFunc()) { in processAux()
1133 errorOrWarn("symbol '" + toString(sym) + in processAux()
1135 getLocation(sec, sym, offset)); in processAux()
1136 sym.needsCopy = true; in processAux()
1137 sym.needsPlt = true; in processAux()
1138 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processAux()
1144 (sym.getName().empty() ? "local symbol" in processAux()
1145 : "symbol '" + toString(sym) + "'") + in processAux()
1146 "; recompile with -fPIC" + getLocation(sec, sym, offset)); in processAux()
1155 static unsigned handleMipsTlsRelocation(RelType type, Symbol &sym, in handleMipsTlsRelocation() argument
1160 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleMipsTlsRelocation()
1164 in.mipsGot->addDynTlsEntry(*c.file, sym); in handleMipsTlsRelocation()
1165 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleMipsTlsRelocation()
1178 static unsigned handleTlsRelocation(RelType type, Symbol &sym, in handleTlsRelocation() argument
1181 if (!sym.isTls()) in handleTlsRelocation()
1185 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr); in handleTlsRelocation()
1191 sym.needsTlsDesc = true; in handleTlsRelocation()
1192 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1212 bool isLocalInExecutable = !sym.isPreemptible && !config->shared; in handleTlsRelocation()
1224 addend, &sym}); in handleTlsRelocation()
1230 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1238 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1245 sym.needsGotDtprel = true; in handleTlsRelocation()
1246 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1253 sym.needsTlsGd = true; in handleTlsRelocation()
1254 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1260 if (sym.isPreemptible) { in handleTlsRelocation()
1261 sym.needsTlsGdToIe = true; in handleTlsRelocation()
1264 addend, &sym}); in handleTlsRelocation()
1268 addend, &sym}); in handleTlsRelocation()
1279 {R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym}); in handleTlsRelocation()
1281 sym.needsTlsIe = true; in handleTlsRelocation()
1284 addRelativeReloc(c, offset, sym, addend, expr, type); in handleTlsRelocation()
1286 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
1297 Symbol &sym = sec.getFile<ELFT>()->getSymbol(symIndex); in scanOne() local
1315 if (sym.isUndefined() && symIndex != 0 && in scanOne()
1316 maybeReportUndefined(cast<Undefined>(sym), sec, offset)) in scanOne()
1320 RelExpr expr = target.getRelExpr(type, sym, relocatedAddr); in scanOne()
1327 int64_t addend = computeAddend<ELFT>(rel, expr, sym.isLocal()); in scanOne()
1343 if (type == R_PPC64_TOC16_LO && sym.isSection() && isa<Defined>(sym) && in scanOne()
1344 cast<Defined>(sym).section->name == ".toc") in scanOne()
1345 ppc64noTocRelax.insert({&sym, addend}); in scanOne()
1352 getLocation(sec, sym, offset)); in scanOne()
1379 errorOrWarn("relocation " + toString(type) + " against " + toString(sym) + in scanOne()
1381 getLocation(sec, sym, offset)); in scanOne()
1385 handleTlsRelocation(type, sym, sec, offset, addend, expr)) { in scanOne()
1398 if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) { in scanOne()
1411 } else if (!isAbsoluteValue(sym)) { in scanOne()
1418 if (sym.isGnuIFunc() && config->zIfuncNoplt) { in scanOne()
1419 sym.exportDynamic = true; in scanOne()
1420 mainPart->relaDyn->addSymbolReloc(type, sec, offset, sym, addend, type); in scanOne()
1433 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in scanOne()
1435 sym.needsGot = true; in scanOne()
1438 sym.needsPlt = true; in scanOne()
1440 sym.hasDirectReloc = true; in scanOne()
1443 processAux(expr, type, offset, sym, addend); in scanOne()
1521 static bool handleNonPreemptibleIfunc(Symbol &sym) { in handleNonPreemptibleIfunc() argument
1562 if (!sym.isGnuIFunc() || sym.isPreemptible || config->zIfuncNoplt) in handleNonPreemptibleIfunc()
1565 if (!(sym.needsGot || sym.needsPlt || sym.hasDirectReloc)) in handleNonPreemptibleIfunc()
1568 sym.isInIplt = true; in handleNonPreemptibleIfunc()
1574 auto *directSym = makeDefined(cast<Defined>(sym)); in handleNonPreemptibleIfunc()
1578 sym.allocateAux(); in handleNonPreemptibleIfunc()
1581 if (sym.hasDirectReloc) { in handleNonPreemptibleIfunc()
1583 auto &d = cast<Defined>(sym); in handleNonPreemptibleIfunc()
1591 if (sym.needsGot) in handleNonPreemptibleIfunc()
1592 addGotEntry(sym); in handleNonPreemptibleIfunc()
1593 } else if (sym.needsGot) { in handleNonPreemptibleIfunc()
1595 sym.gotInIgot = true; in handleNonPreemptibleIfunc()
1601 auto fn = [](Symbol &sym) { in postScanRelocations() argument
1602 if (handleNonPreemptibleIfunc(sym)) in postScanRelocations()
1604 if (!sym.needsDynReloc()) in postScanRelocations()
1606 sym.allocateAux(); in postScanRelocations()
1608 if (sym.needsGot) in postScanRelocations()
1609 addGotEntry(sym); in postScanRelocations()
1610 if (sym.needsPlt) in postScanRelocations()
1611 addPltEntry(*in.plt, *in.gotPlt, *in.relaPlt, target->pltRel, sym); in postScanRelocations()
1612 if (sym.needsCopy) { in postScanRelocations()
1613 if (sym.isObject()) { in postScanRelocations()
1614 invokeELFT(addCopyRelSymbol, cast<SharedSymbol>(sym)); in postScanRelocations()
1617 assert(!sym.needsCopy); in postScanRelocations()
1619 assert(sym.isFunc() && sym.needsPlt); in postScanRelocations()
1620 if (!sym.isDefined()) { in postScanRelocations()
1621 replaceWithDefined(sym, *in.plt, in postScanRelocations()
1623 target->pltEntrySize * sym.getPltIdx(), in postScanRelocations()
1625 sym.needsCopy = true; in postScanRelocations()
1628 cast<Defined>(sym).value = in.plt->headerSize; in postScanRelocations()
1630 cast<PPC32GlinkSection>(*in.plt).canonical_plts.push_back(&sym); in postScanRelocations()
1636 if (!sym.isTls()) in postScanRelocations()
1638 bool isLocalInExecutable = !sym.isPreemptible && !config->shared; in postScanRelocations()
1640 if (sym.needsTlsDesc) { in postScanRelocations()
1641 in.got->addTlsDescEntry(sym); in postScanRelocations()
1643 target->tlsDescRel, *in.got, in.got->getTlsDescOffset(sym), sym, in postScanRelocations()
1646 if (sym.needsTlsGd) { in postScanRelocations()
1647 in.got->addDynTlsEntry(sym); in postScanRelocations()
1648 uint64_t off = in.got->getGlobalDynOffset(sym); in postScanRelocations()
1652 {R_ADDEND, target->symbolicRel, off, 1, &sym}); in postScanRelocations()
1655 off, sym); in postScanRelocations()
1660 if (sym.isPreemptible) in postScanRelocations()
1662 offsetOff, sym); in postScanRelocations()
1665 {R_ABS, target->tlsOffsetRel, offsetOff, 0, &sym}); in postScanRelocations()
1667 if (sym.needsTlsGdToIe) { in postScanRelocations()
1668 in.got->addEntry(sym); in postScanRelocations()
1670 sym.getGotOffset(), sym); in postScanRelocations()
1672 if (sym.needsGotDtprel) { in postScanRelocations()
1673 in.got->addEntry(sym); in postScanRelocations()
1675 {R_ABS, target->tlsOffsetRel, sym.getGotOffset(), 0, &sym}); in postScanRelocations()
1678 if (sym.needsTlsIe && !sym.needsTlsGdToIe) in postScanRelocations()
1679 addTpOffsetGotEntry(sym); in postScanRelocations()
1693 for (Symbol *sym : symtab->symbols()) in postScanRelocations()
1694 fn(*sym); in postScanRelocations()
1699 for (Symbol *sym : file->getLocalSymbols()) in postScanRelocations()
1700 fn(*sym); in postScanRelocations()
2060 if (auto *d = dyn_cast<Defined>(rel.sym)) in getThunk()
2065 thunkVec = &thunkedSymbols[{rel.sym, keyAddend}]; in getThunk()
2086 if (Thunk *t = thunks.lookup(rel.sym)) { in normalizeExistingThunk()
2087 if (target->inBranchRange(rel.type, src, rel.sym->getVA(rel.addend))) in normalizeExistingThunk()
2089 rel.sym = &t->destination; in normalizeExistingThunk()
2091 if (rel.sym->isInPlt()) in normalizeExistingThunk()
2148 *rel.sym, rel.addend)) in createThunks()
2167 rel.sym = t->getThunkTargetSym(); in createThunks()
2199 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonNeedsTLSSymbol()
2208 Symbol *sym = symtab->find("__tls_get_addr"); in hexagonTLSSymbolUpdate() local
2209 if (!sym) in hexagonTLSSymbolUpdate()
2216 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonTLSSymbolUpdate()
2218 sym->allocateAux(); in hexagonTLSSymbolUpdate()
2220 *sym); in hexagonTLSSymbolUpdate()
2223 rel.sym = sym; in hexagonTLSSymbolUpdate()