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 return msg + toString(sym.file); in getDefinedLocation()
80 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, target->tlsDescRel); in handleTlsRelocation()
207 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
226 bool isLocalInExecutable = !sym.isPreemptible && !config->shared; in handleTlsRelocation()
238 addend, &sym}); in handleTlsRelocation()
246 {R_ADDEND, target->symbolicRel, in.got->getTlsIndexOff(), 1, &sym}); in handleTlsRelocation()
251 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
258 type, offset, addend, &sym}); in handleTlsRelocation()
265 if (!sym.isInGot()) { in handleTlsRelocation()
266 in.got->addEntry(sym); in handleTlsRelocation()
267 uint64_t off = sym.getGotOffset(); in handleTlsRelocation()
269 {R_ABS, target->tlsOffsetRel, off, 0, &sym}); in handleTlsRelocation()
271 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
278 if (in.got->addDynTlsEntry(sym)) { in handleTlsRelocation()
279 uint64_t off = in.got->getGlobalDynOffset(sym); in handleTlsRelocation()
284 {R_ADDEND, target->symbolicRel, off, 1, &sym}); in handleTlsRelocation()
287 off, sym); in handleTlsRelocation()
292 if (sym.isPreemptible) in handleTlsRelocation()
294 offsetOff, sym); in handleTlsRelocation()
297 {R_ABS, target->tlsOffsetRel, offsetOff, 0, &sym}); in handleTlsRelocation()
299 c.relocations.push_back({expr, type, offset, addend, &sym}); in handleTlsRelocation()
305 if (sym.isPreemptible) { in handleTlsRelocation()
308 addend, &sym}); in handleTlsRelocation()
309 if (!sym.isInGot()) { in handleTlsRelocation()
310 in.got->addEntry(sym); in handleTlsRelocation()
312 sym.getGotOffset(), sym); in handleTlsRelocation()
317 addend, &sym}); in handleTlsRelocation()
327 c.relocations.push_back({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym}); in handleTlsRelocation()
363 static bool isAbsolute(const Symbol &sym) { in isAbsolute() argument
364 if (sym.isUndefWeak()) in isAbsolute()
366 if (const auto *dr = dyn_cast<Defined>(&sym)) in isAbsolute()
371 static bool isAbsoluteValue(const Symbol &sym) { in isAbsoluteValue() argument
372 return isAbsolute(sym) || sym.isTls(); in isAbsoluteValue()
406 static bool isStaticLinkTimeConstant(RelExpr e, RelType type, const Symbol &sym, in isStaticLinkTimeConstant() argument
425 if (sym.isPreemptible) in isStaticLinkTimeConstant()
436 bool absVal = isAbsoluteValue(sym); in isStaticLinkTimeConstant()
452 if (sym.isUndefWeak()) in isStaticLinkTimeConstant()
457 if (sym.scriptDefined) in isStaticLinkTimeConstant()
461 toString(sym) + getLocation(s, sym, relOff)); in isStaticLinkTimeConstant()
526 Symbol *sym = symtab->find(name); in getSymbolsAt() local
527 if (auto *alias = dyn_cast_or_null<SharedSymbol>(sym)) in getSymbolsAt()
545 static void replaceWithDefined(Symbol &sym, SectionBase *sec, uint64_t value, in replaceWithDefined() argument
547 Symbol old = sym; in replaceWithDefined()
549 sym.replace(Defined{sym.file, sym.getName(), sym.binding, sym.stOther, in replaceWithDefined()
550 sym.type, value, size, sec}); in replaceWithDefined()
552 sym.pltIndex = old.pltIndex; in replaceWithDefined()
553 sym.gotIndex = old.gotIndex; in replaceWithDefined()
554 sym.verdefIndex = old.verdefIndex; in replaceWithDefined()
555 sym.exportDynamic = true; in replaceWithDefined()
556 sym.isUsedInRegularObj = true; in replaceWithDefined()
626 for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss)) in addCopyRelSymbol()
627 replaceWithDefined(*sym, sec, 0, sym->size); in addCopyRelSymbol()
695 static std::string maybeReportDiscarded(Undefined &sym) { in maybeReportDiscarded() argument
696 auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file); in maybeReportDiscarded()
697 if (!file || !sym.discardedSecIdx || in maybeReportDiscarded()
698 file->getSections()[sym.discardedSecIdx] != &InputSection::discarded) in maybeReportDiscarded()
704 if (sym.type == ELF::STT_SECTION) { in maybeReportDiscarded()
707 file->getObj().getSectionName(objSections[sym.discardedSecIdx]), file); in maybeReportDiscarded()
710 toString(sym); in maybeReportDiscarded()
714 Elf_Shdr_Impl<ELFT> elfSec = objSections[sym.discardedSecIdx - 1]; in maybeReportDiscarded()
731 Symbol *sym; member
761 static const Symbol *getAlternativeSpelling(const Undefined &sym, in getAlternativeSpelling() argument
765 if (auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file)) { in getAlternativeSpelling()
768 if (file && sym.discardedSecIdx != 0 && in getAlternativeSpelling()
769 file->getSections()[sym.discardedSecIdx] == &InputSection::discarded) in getAlternativeSpelling()
773 for (const Symbol *s : sym.file->getSymbols()) in getAlternativeSpelling()
794 StringRef name = sym.getName(); in getAlternativeSpelling()
833 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
834 if (!sym->isUndefined() && name.equals_insensitive(sym->getName())) in getAlternativeSpelling()
835 return sym; in getAlternativeSpelling()
859 for (Symbol *sym : symtab->symbols()) in getAlternativeSpelling()
860 if (canSuggestExternCForCXX(name, sym->getName())) { in getAlternativeSpelling()
861 s = sym; in getAlternativeSpelling()
877 Symbol &sym = *undef.sym; in reportUndefinedSymbol() local
880 switch (sym.visibility) { in reportUndefinedSymbol()
892 std::string msg = maybeReportDiscarded<ELFT>(cast<Undefined>(sym)); in reportUndefinedSymbol()
894 msg = "undefined " + visibility() + "symbol: " + toString(sym); in reportUndefinedSymbol()
905 std::string src = sec.getSrcMsg(sym, offset); in reportUndefinedSymbol()
919 cast<Undefined>(sym), pre_hint, post_hint)) { in reportUndefinedSymbol()
926 if (sym.getName().startswith("_ZTV")) in reportUndefinedSymbol()
934 error(msg, ErrorTag::SymbolNotFound, {sym.getName()}); in reportUndefinedSymbol()
943 if (UndefinedDiag *canon = firstRef.lookup(undef.sym)) { in reportUndefinedSymbols()
947 firstRef[undef.sym] = &undef; in reportUndefinedSymbols()
959 static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec, in maybeReportUndefined() argument
961 if (!sym.isUndefined()) in maybeReportUndefined()
965 if (*sym.getVersionSuffix() == '@') { in maybeReportUndefined()
966 undefs.push_back({&sym, {{&sec, offset}}, false}); in maybeReportUndefined()
969 if (sym.isWeak()) in maybeReportUndefined()
972 bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT; in maybeReportUndefined()
985 if (cast<Undefined>(sym).discardedSecIdx != 0 && in maybeReportUndefined()
992 undefs.push_back({&sym, {{&sec, offset}}, isWarning}); in maybeReportUndefined()
1058 Symbol &sym, int64_t addend, RelExpr expr, in addRelativeReloc() argument
1069 isec->relocations.push_back({expr, type, offsetInSec, addend, &sym}); in addRelativeReloc()
1073 part.relaDyn->addRelativeReloc(target->relativeRel, isec, offsetInSec, sym, in addRelativeReloc()
1079 RelocationBaseSection *rel, RelType type, Symbol &sym) { in addPltEntry() argument
1080 plt->addEntry(sym); in addPltEntry()
1081 gotPlt->addEntry(sym); in addPltEntry()
1082 rel->addReloc({type, gotPlt, sym.getGotPltOffset(), in addPltEntry()
1083 sym.isPreemptible ? DynamicReloc::AgainstSymbol in addPltEntry()
1085 sym, 0, R_ABS}); in addPltEntry()
1088 static void addGotEntry(Symbol &sym) { in addGotEntry() argument
1089 in.got->addEntry(sym); in addGotEntry()
1091 RelExpr expr = sym.isTls() ? R_TPREL : R_ABS; in addGotEntry()
1092 uint64_t off = sym.getGotOffset(); in addGotEntry()
1102 !sym.isPreemptible && (!config->isPic || isAbsolute(sym)); in addGotEntry()
1104 in.got->relocations.push_back({expr, target->symbolicRel, off, 0, &sym}); in addGotEntry()
1110 if (!sym.isTls() && !sym.isPreemptible && config->isPic) { in addGotEntry()
1111 addRelativeReloc(in.got, off, sym, 0, R_ABS, target->symbolicRel); in addGotEntry()
1115 sym.isTls() ? target->tlsGotRel : target->gotRel, in.got, off, sym, in addGotEntry()
1122 static bool canDefineSymbolInExecutable(Symbol &sym) { in canDefineSymbolInExecutable() argument
1128 if ((sym.stOther & 0x3) == STV_DEFAULT) in canDefineSymbolInExecutable()
1135 return ((sym.isFunc() && config->ignoreFunctionAddressEquality) || in canDefineSymbolInExecutable()
1136 (sym.isObject() && config->ignoreDataAddressEquality)); in canDefineSymbolInExecutable()
1154 uint64_t offset, Symbol &sym, const RelTy &rel, in processRelocAux() argument
1170 if (isStaticLinkTimeConstant(expr, type, sym, sec, offset) || in processRelocAux()
1171 (!config->isPic && sym.isUndefWeak())) { in processRelocAux()
1172 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1179 if (expr == R_GOT || (rel == target->symbolicRel && !sym.isPreemptible)) { in processRelocAux()
1180 addRelativeReloc(&sec, offset, sym, addend, expr, type); in processRelocAux()
1185 sec.getPartition().relaDyn->addSymbolReloc(rel, &sec, offset, sym, addend, in processRelocAux()
1204 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in processRelocAux()
1212 if (!canDefineSymbolInExecutable(sym)) { in processRelocAux()
1213 errorOrWarn("cannot preempt symbol: " + toString(sym) + in processRelocAux()
1214 getLocation(sec, sym, offset)); in processRelocAux()
1218 if (sym.isObject()) { in processRelocAux()
1220 if (auto *ss = dyn_cast<SharedSymbol>(&sym)) { in processRelocAux()
1225 getLocation(sec, sym, offset)); in processRelocAux()
1228 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1259 if (sym.isFunc()) { in processRelocAux()
1261 errorOrWarn("symbol '" + toString(sym) + in processRelocAux()
1263 getLocation(sec, sym, offset)); in processRelocAux()
1264 if (!sym.isInPlt()) in processRelocAux()
1265 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); in processRelocAux()
1266 if (!sym.isDefined()) { in processRelocAux()
1268 sym, in.plt, in processRelocAux()
1269 target->pltHeaderSize + target->pltEntrySize * sym.pltIndex, 0); in processRelocAux()
1272 cast<Defined>(sym).value = in.plt->headerSize; in processRelocAux()
1274 cast<PPC32GlinkSection>(in.plt)->canonical_plts.push_back(&sym); in processRelocAux()
1277 sym.needsPltAddr = true; in processRelocAux()
1278 sec.relocations.push_back({expr, type, offset, addend, &sym}); in processRelocAux()
1287 (sym.getName().empty() ? "local symbol" in processRelocAux()
1288 : "symbol: " + toString(sym)) + in processRelocAux()
1291 getLocation(sec, sym, offset)); in processRelocAux()
1295 (sym.getName().empty() ? "local symbol" : "symbol " + toString(sym)) + in processRelocAux()
1296 "; recompile with -fPIC" + getLocation(sec, sym, offset)); in processRelocAux()
1300 errorOrWarn("symbol '" + toString(sym) + "' has no type" + in processRelocAux()
1301 getLocation(sec, sym, offset)); in processRelocAux()
1309 Symbol &sym = sec.getFile<ELFT>()->getSymbol(symIndex); in scanReloc() local
1327 if (symIndex != 0 && maybeReportUndefined(sym, sec, rel.r_offset)) in scanReloc()
1331 RelExpr expr = target->getRelExpr(type, sym, relocatedAddr); in scanReloc()
1338 int64_t addend = computeAddend<ELFT>(rel, end, sec, expr, sym.isLocal()); in scanReloc()
1354 if (type == R_PPC64_TOC16_LO && sym.isSection() && isa<Defined>(sym) && in scanReloc()
1355 cast<Defined>(sym).section->name == ".toc") in scanReloc()
1356 ppc64noTocRelax.insert({&sym, addend}); in scanReloc()
1363 getLocation(sec, sym, offset)); in scanReloc()
1382 if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) { in scanReloc()
1395 } else if (!isAbsoluteValue(sym)) { in scanReloc()
1415 errorOrWarn("relocation " + toString(type) + " against " + toString(sym) + in scanReloc()
1417 getLocation(sec, sym, offset)); in scanReloc()
1421 type, sym, sec, offset, addend, expr)) { in scanReloc()
1428 if (sym.isGnuIFunc() && config->zIfuncNoplt) { in scanReloc()
1429 sym.exportDynamic = true; in scanReloc()
1430 mainPart->relaDyn->addSymbolReloc(type, &sec, offset, sym, addend, type); in scanReloc()
1436 if (!sym.isGnuIFunc() || sym.isPreemptible) { in scanReloc()
1438 if (needsPlt(expr) && !sym.isInPlt()) in scanReloc()
1439 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); in scanReloc()
1451 in.mipsGot->addEntry(*sec.file, sym, addend, expr); in scanReloc()
1452 } else if (!sym.isInGot()) { in scanReloc()
1453 addGotEntry(sym); in scanReloc()
1497 if (!sym.isInPlt()) { in scanReloc()
1499 sym.isInIplt = true; in scanReloc()
1508 auto *directSym = make<Defined>(cast<Defined>(sym)); in scanReloc()
1511 sym.pltIndex = directSym->pltIndex; in scanReloc()
1519 sym.gotInIgot = true; in scanReloc()
1523 auto &d = cast<Defined>(sym); in scanReloc()
1525 d.value = sym.pltIndex * target->ipltEntrySize; in scanReloc()
1531 if (sym.gotInIgot) { in scanReloc()
1540 sym.gotInIgot = false; in scanReloc()
1541 addGotEntry(sym); in scanReloc()
1546 processRelocAux<ELFT>(sec, expr, type, offset, sym, rel, addend); in scanReloc()
1977 if (auto *d = dyn_cast<Defined>(rel.sym)) in getThunk()
1982 thunkVec = &thunkedSymbols[{rel.sym, keyAddend}]; in getThunk()
2003 if (Thunk *t = thunks.lookup(rel.sym)) { in normalizeExistingThunk()
2004 if (target->inBranchRange(rel.type, src, rel.sym->getVA(rel.addend))) in normalizeExistingThunk()
2006 rel.sym = &t->destination; in normalizeExistingThunk()
2008 if (rel.sym->isInPlt()) in normalizeExistingThunk()
2063 *rel.sym, rel.addend)) in createThunks()
2082 rel.sym = t->getThunkTargetSym(); in createThunks()
2115 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonNeedsTLSSymbol()
2124 Symbol *sym = symtab->find("__tls_get_addr"); in hexagonTLSSymbolUpdate() local
2125 if (!sym) in hexagonTLSSymbolUpdate()
2132 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { in hexagonTLSSymbolUpdate()
2135 *sym); in hexagonTLSSymbolUpdate()
2138 rel.sym = sym; in hexagonTLSSymbolUpdate()