Lines Matching refs:sym
68 static Optional<std::string> getLinkerScriptLocation(const Symbol &sym) { in getLinkerScriptLocation() argument
71 if (cmd->sym == &sym) in getLinkerScriptLocation()
76 static std::string getDefinedLocation(const Symbol &sym) { in getDefinedLocation() argument
78 if (sym.file) in getDefinedLocation()
79 msg += toString(sym.file); in getDefinedLocation()
80 else if (Optional<std::string> loc = getLinkerScriptLocation(sym)) in getDefinedLocation()
90 static std::string getLocation(InputSectionBase &s, const Symbol &sym, in getLocation() argument
92 std::string msg = getDefinedLocation(sym) + "\n>>> referenced by "; in getLocation()
93 std::string src = s.getSrcMsg(sym, off); in getLocation()
103 if (rel.sym && !rel.sym->isLocal()) in reportRangeError()
104 hint = "; references " + lld::toString(*rel.sym) + in reportRangeError()
105 getDefinedLocation(*rel.sym); in reportRangeError()
116 void elf::reportRangeError(uint8_t *loc, int64_t v, int n, const Symbol &sym, in reportRangeError() argument
120 if (!sym.getName().empty()) in reportRangeError()
121 hint = "; references " + lld::toString(sym) + getDefinedLocation(sym); in reportRangeError()
165 static unsigned handleMipsTlsRelocation(RelType type, Symbol &sym, in handleMipsTlsRelocation() argument
170 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleMipsTlsRelocation()
174 in.mipsGot->addDynTlsEntry(*c.file, sym); in handleMipsTlsRelocation()
175 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleMipsTlsRelocation()
190 handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c, in handleTlsRelocation() argument
192 if (!sym.isTls()) in handleTlsRelocation()
196 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr); in handleTlsRelocation()
201 if (in.got->addDynTlsEntry(sym)) { in handleTlsRelocation()
202 uint64_t off = in.got->getGlobalDynOffset(sym); in handleTlsRelocation()
204 {target->tlsDescRel, in.got, off, !sym.isPreemptible, &sym, 0}); in handleTlsRelocation()
207 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
222 bool isLocalInExecutable = !sym.isPreemptible && !config->shared; in handleTlsRelocation()
234 addend, &sym}); in handleTlsRelocation()
242 {R_ADDEND, target->symbolicRel, in.got->getTlsIndexOff(), 1, &sym}); in handleTlsRelocation()
247 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
254 type, offset, addend, &sym}); in handleTlsRelocation()
261 if (!sym.isInGot()) { in handleTlsRelocation()
262 in.got->addEntry(sym); in handleTlsRelocation()
263 uint64_t off = sym.getGotOffset(); in handleTlsRelocation()
265 {R_ABS, target->tlsOffsetRel, off, 0, &sym}); in handleTlsRelocation()
267 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
274 if (in.got->addDynTlsEntry(sym)) { in handleTlsRelocation()
275 uint64_t off = in.got->getGlobalDynOffset(sym); in handleTlsRelocation()
280 {R_ADDEND, target->symbolicRel, off, 1, &sym}); in handleTlsRelocation()
282 mainPart->relaDyn->addReloc(target->tlsModuleIndexRel, in.got, off, &sym); in handleTlsRelocation()
287 if (sym.isPreemptible) in handleTlsRelocation()
289 &sym); in handleTlsRelocation()
292 {R_ABS, target->tlsOffsetRel, offsetOff, 0, &sym}); in handleTlsRelocation()
294 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
300 if (sym.isPreemptible) { in handleTlsRelocation()
303 addend, &sym}); in handleTlsRelocation()
304 if (!sym.isInGot()) { in handleTlsRelocation()
305 in.got->addEntry(sym); in handleTlsRelocation()
306 mainPart->relaDyn->addReloc(target->tlsGotRel, in.got, sym.getGotOffset(), in handleTlsRelocation()
307 &sym); in handleTlsRelocation()
312 addend, &sym}); in handleTlsRelocation()
322 c.relocations.push_back({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym}); in handleTlsRelocation()
358 static bool isAbsolute(const Symbol &sym) { in isAbsolute() argument
359 if (sym.isUndefWeak()) in isAbsolute()
361 if (const auto *dr = dyn_cast<Defined>(&sym)) in isAbsolute()
366 static bool isAbsoluteValue(const Symbol &sym) { in isAbsoluteValue() argument
367 return isAbsolute(sym) || sym.isTls(); in isAbsoluteValue()
401 static bool isStaticLinkTimeConstant(RelExpr e, RelType type, const Symbol &sym, in isStaticLinkTimeConstant() argument
419 if (sym.isPreemptible) in isStaticLinkTimeConstant()
430 bool absVal = isAbsoluteValue(sym); in isStaticLinkTimeConstant()
446 if (sym.isUndefWeak()) in isStaticLinkTimeConstant()
451 if (sym.scriptDefined) in isStaticLinkTimeConstant()
455 toString(sym) + getLocation(s, sym, relOff)); in isStaticLinkTimeConstant()
520 Symbol *sym = symtab->find(name); in getSymbolsAt() local
521 if (auto *alias = dyn_cast_or_null<SharedSymbol>(sym)) in getSymbolsAt()
532 static void replaceWithDefined(Symbol &sym, SectionBase *sec, uint64_t value, in replaceWithDefined() argument
534 Symbol old = sym; in replaceWithDefined()
536 sym.replace(Defined{sym.file, sym.getName(), sym.binding, sym.stOther, in replaceWithDefined()
537 sym.type, value, size, sec}); in replaceWithDefined()
539 sym.pltIndex = old.pltIndex; in replaceWithDefined()
540 sym.gotIndex = old.gotIndex; in replaceWithDefined()
541 sym.verdefIndex = old.verdefIndex; in replaceWithDefined()
542 sym.exportDynamic = true; in replaceWithDefined()
543 sym.isUsedInRegularObj = true; in replaceWithDefined()
613 for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss)) in addCopyRelSymbol()
614 replaceWithDefined(*sym, sec, 0, sym->size); in addCopyRelSymbol()
682 static std::string maybeReportDiscarded(Undefined &sym) { in maybeReportDiscarded() argument
683 auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file); in maybeReportDiscarded()
684 if (!file || !sym.discardedSecIdx || in maybeReportDiscarded()
685 file->getSections()[sym.discardedSecIdx] != &InputSection::discarded) in maybeReportDiscarded()
691 if (sym.type == ELF::STT_SECTION) { in maybeReportDiscarded()
694 file->getObj().getSectionName(objSections[sym.discardedSecIdx]), file); in maybeReportDiscarded()
697 toString(sym); in maybeReportDiscarded()
701 Elf_Shdr_Impl<ELFT> elfSec = objSections[sym.discardedSecIdx - 1]; in maybeReportDiscarded()
718 Symbol *sym; member
748 static const Symbol *getAlternativeSpelling(const Undefined &sym, in getAlternativeSpelling() argument
752 if (auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file)) { in getAlternativeSpelling()
755 if (file && sym.discardedSecIdx != 0 && in getAlternativeSpelling()
756 file->getSections()[sym.discardedSecIdx] == &InputSection::discarded) in getAlternativeSpelling()
760 for (const Symbol *s : sym.file->getSymbols()) in getAlternativeSpelling()
781 StringRef name = sym.getName(); in getAlternativeSpelling()
820 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
821 if (!sym->isUndefined() && name.equals_lower(sym->getName())) in getAlternativeSpelling()
822 return sym; in getAlternativeSpelling()
846 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
847 if (canSuggestExternCForCXX(name, sym->getName())) { in getAlternativeSpelling()
848 s = sym; in getAlternativeSpelling()
864 Symbol &sym = *undef.sym; in reportUndefinedSymbol() local
867 switch (sym.visibility) { in reportUndefinedSymbol()
879 std::string msg = maybeReportDiscarded<ELFT>(cast<Undefined>(sym)); in reportUndefinedSymbol()
881 msg = "undefined " + visibility() + "symbol: " + toString(sym); in reportUndefinedSymbol()
892 std::string src = sec.getSrcMsg(sym, offset); in reportUndefinedSymbol()
906 cast<Undefined>(sym), pre_hint, post_hint)) { in reportUndefinedSymbol()
913 if (sym.getName().startswith("_ZTV")) in reportUndefinedSymbol()
921 error(msg, ErrorTag::SymbolNotFound, {sym.getName()}); in reportUndefinedSymbol()
930 if (UndefinedDiag *canon = firstRef.lookup(undef.sym)) { in reportUndefinedSymbols()
934 firstRef[undef.sym] = &undef; in reportUndefinedSymbols()
946 static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec, in maybeReportUndefined() argument
948 if (!sym.isUndefined()) in maybeReportUndefined()
952 if (*sym.getVersionSuffix() == '@') { in maybeReportUndefined()
953 undefs.push_back({&sym, {{&sec, offset}}, false}); in maybeReportUndefined()
956 if (sym.isWeak()) in maybeReportUndefined()
959 bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT; in maybeReportUndefined()
972 if (cast<Undefined>(sym).discardedSecIdx != 0 && in maybeReportUndefined()
979 undefs.push_back({&sym, {{&sec, offset}}, isWarning}); in maybeReportUndefined()
1045 Symbol *sym, int64_t addend, RelExpr expr, in addRelativeReloc() argument
1056 isec->relocations.push_back({expr, type, offsetInSec, addend, sym}); in addRelativeReloc()
1060 part.relaDyn->addReloc(target->relativeRel, isec, offsetInSec, sym, addend, in addRelativeReloc()
1066 RelocationBaseSection *rel, RelType type, Symbol &sym) { in addPltEntry() argument
1067 plt->addEntry(sym); in addPltEntry()
1068 gotPlt->addEntry(sym); in addPltEntry()
1070 {type, gotPlt, sym.getGotPltOffset(), !sym.isPreemptible, &sym, 0}); in addPltEntry()
1073 static void addGotEntry(Symbol &sym) { in addGotEntry() argument
1074 in.got->addEntry(sym); in addGotEntry()
1076 RelExpr expr = sym.isTls() ? R_TLS : R_ABS; in addGotEntry()
1077 uint64_t off = sym.getGotOffset(); in addGotEntry()
1087 !sym.isPreemptible && (!config->isPic || isAbsolute(sym)); in addGotEntry()
1089 in.got->relocations.push_back({expr, target->symbolicRel, off, 0, &sym}); in addGotEntry()
1095 if (!sym.isTls() && !sym.isPreemptible && config->isPic && !isAbsolute(sym)) { in addGotEntry()
1096 addRelativeReloc(in.got, off, &sym, 0, R_ABS, target->symbolicRel); in addGotEntry()
1100 sym.isTls() ? target->tlsGotRel : target->gotRel, in.got, off, &sym, 0, in addGotEntry()
1101 sym.isPreemptible ? R_ADDEND : R_ABS, target->symbolicRel); in addGotEntry()
1107 static bool canDefineSymbolInExecutable(Symbol &sym) { in canDefineSymbolInExecutable() argument
1113 if ((sym.stOther & 0x3) == STV_DEFAULT) in canDefineSymbolInExecutable()
1120 return ((sym.isFunc() && config->ignoreFunctionAddressEquality) || in canDefineSymbolInExecutable()
1121 (sym.isObject() && config->ignoreDataAddressEquality)); in canDefineSymbolInExecutable()
1139 uint64_t offset, Symbol &sym, const RelTy &rel, in processRelocAux() argument
1148 if (isStaticLinkTimeConstant(expr, type, sym, sec, offset) || in processRelocAux()
1149 (!config->shared && sym.isUndefWeak())) { in processRelocAux()
1150 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1157 if (expr == R_GOT || (rel == target->symbolicRel && !sym.isPreemptible)) { in processRelocAux()
1158 addRelativeReloc(&sec, offset, &sym, addend, expr, type); in processRelocAux()
1163 sec.getPartition().relaDyn->addReloc(rel, &sec, offset, &sym, addend, in processRelocAux()
1182 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in processRelocAux()
1190 if (!canDefineSymbolInExecutable(sym)) { in processRelocAux()
1191 errorOrWarn("cannot preempt symbol: " + toString(sym) + in processRelocAux()
1192 getLocation(sec, sym, offset)); in processRelocAux()
1196 if (sym.isObject()) { in processRelocAux()
1198 if (auto *ss = dyn_cast<SharedSymbol>(&sym)) { in processRelocAux()
1203 getLocation(sec, sym, offset)); in processRelocAux()
1206 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1237 if (sym.isFunc()) { in processRelocAux()
1239 errorOrWarn("symbol '" + toString(sym) + in processRelocAux()
1241 getLocation(sec, sym, offset)); in processRelocAux()
1242 if (!sym.isInPlt()) in processRelocAux()
1243 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); in processRelocAux()
1244 if (!sym.isDefined()) { in processRelocAux()
1246 sym, in.plt, in processRelocAux()
1247 target->pltHeaderSize + target->pltEntrySize * sym.pltIndex, 0); in processRelocAux()
1250 cast<Defined>(sym).value = in.plt->headerSize; in processRelocAux()
1252 cast<PPC32GlinkSection>(in.plt)->canonical_plts.push_back(&sym); in processRelocAux()
1255 sym.needsPltAddr = true; in processRelocAux()
1256 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1265 (sym.getName().empty() ? "local symbol" in processRelocAux()
1266 : "symbol: " + toString(sym)) + in processRelocAux()
1269 getLocation(sec, sym, offset)); in processRelocAux()
1273 (sym.getName().empty() ? "local symbol" : "symbol " + toString(sym)) + in processRelocAux()
1274 "; recompile with -fPIC" + getLocation(sec, sym, offset)); in processRelocAux()
1278 errorOrWarn("symbol '" + toString(sym) + "' has no type" + in processRelocAux()
1279 getLocation(sec, sym, offset)); in processRelocAux()
1287 Symbol &sym = sec.getFile<ELFT>()->getSymbol(symIndex); in scanReloc() local
1305 if (symIndex != 0 && maybeReportUndefined(sym, sec, rel.r_offset)) in scanReloc()
1309 RelExpr expr = target->getRelExpr(type, sym, relocatedAddr); in scanReloc()
1315 if (sym.isGnuIFunc() && !config->zText && config->warnIfuncTextrel) { in scanReloc()
1322 getLocation(sec, sym, offset)); in scanReloc()
1326 int64_t addend = computeAddend<ELFT>(rel, end, sec, expr, sym.isLocal()); in scanReloc()
1342 if (type == R_PPC64_TOC16_LO && sym.isSection() && isa<Defined>(sym) && in scanReloc()
1343 cast<Defined>(sym).section->name == ".toc") in scanReloc()
1344 ppc64noTocRelax.insert({&sym, addend}); in scanReloc()
1351 getLocation(sec, sym, offset)); in scanReloc()
1370 if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) { in scanReloc()
1383 } else if (!isAbsoluteValue(sym)) { in scanReloc()
1402 handleTlsRelocation<ELFT>(type, sym, sec, offset, addend, expr)) { in scanReloc()
1409 if (sym.isGnuIFunc() && config->zIfuncNoplt) { in scanReloc()
1410 sym.exportDynamic = true; in scanReloc()
1411 mainPart->relaDyn->addReloc(type, &sec, offset, &sym, addend, R_ADDEND, type); in scanReloc()
1417 if (!sym.isGnuIFunc() || sym.isPreemptible) { in scanReloc()
1419 if (needsPlt(expr) && !sym.isInPlt()) in scanReloc()
1420 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); in scanReloc()
1432 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in scanReloc()
1433 } else if (!sym.isInGot()) { in scanReloc()
1434 addGotEntry(sym); in scanReloc()
1478 if (!sym.isInPlt()) { in scanReloc()
1480 sym.isInIplt = true; in scanReloc()
1489 auto *directSym = make<Defined>(cast<Defined>(sym)); in scanReloc()
1492 sym.pltIndex = directSym->pltIndex; in scanReloc()
1500 sym.gotInIgot = true; in scanReloc()
1504 auto &d = cast<Defined>(sym); in scanReloc()
1506 d.value = sym.pltIndex * target->ipltEntrySize; in scanReloc()
1512 if (sym.gotInIgot) { in scanReloc()
1521 sym.gotInIgot = false; in scanReloc()
1522 addGotEntry(sym); in scanReloc()
1527 processRelocAux<ELFT>(sec, expr, type, offset, sym, rel, addend); in scanReloc()
1901 if (auto *d = dyn_cast<Defined>(rel.sym)) in getThunk()
1906 thunkVec = &thunkedSymbols[{rel.sym, addend}]; in getThunk()
1928 if (Thunk *t = thunks.lookup(rel.sym)) { in normalizeExistingThunk()
1930 rel.sym->getVA(rel.addend) + getPCBias(rel.type))) in normalizeExistingThunk()
1932 rel.sym = &t->destination; in normalizeExistingThunk()
1934 if (rel.sym->isInPlt()) in normalizeExistingThunk()
1989 *rel.sym, rel.addend)) in createThunks()
2008 rel.sym = t->getThunkTargetSym(); in createThunks()
2041 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonNeedsTLSSymbol()
2050 Symbol *sym = symtab->find("__tls_get_addr"); in hexagonTLSSymbolUpdate() local
2051 if (!sym) in hexagonTLSSymbolUpdate()
2058 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonTLSSymbolUpdate()
2061 *sym); in hexagonTLSSymbolUpdate()
2064 rel.sym = sym; in hexagonTLSSymbolUpdate()