• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/lld/ELF/

Lines Matching refs:sym

68 static Optional<std::string> getLinkerScriptLocation(const Symbol &sym) {
71 if (cmd->sym == &sym)
76 static std::string getDefinedLocation(const Symbol &sym) {
78 if (sym.file)
79 msg += toString(sym.file);
80 else if (Optional<std::string> loc = getLinkerScriptLocation(sym))
90 static std::string getLocation(InputSectionBase &s, const Symbol &sym,
92 std::string msg = getDefinedLocation(sym) + "\n>>> referenced by ";
93 std::string src = s.getSrcMsg(sym, off);
103 if (rel.sym && !rel.sym->isLocal())
104 hint = "; references " + lld::toString(*rel.sym) +
105 getDefinedLocation(*rel.sym);
154 static unsigned handleMipsTlsRelocation(RelType type, Symbol &sym,
159 c.relocations.push_back({expr, type, offset, addend, &sym});
163 in.mipsGot->addDynTlsEntry(*c.file, sym);
164 c.relocations.push_back({expr, type, offset, addend, &sym});
179 handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
181 if (!sym.isTls())
185 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
190 if (in.got->addDynTlsEntry(sym)) {
191 uint64_t off = in.got->getGlobalDynOffset(sym);
193 {target->tlsDescRel, in.got, off, !sym.isPreemptible, &sym, 0});
196 c.relocations.push_back({expr, type, offset, addend, &sym});
211 bool isLocalInExecutable = !sym.isPreemptible && !config->shared;
223 offset, addend, &sym});
231 {R_ADDEND, target->symbolicRel, in.got->getTlsIndexOff(), 1, &sym});
236 c.relocations.push_back({expr, type, offset, addend, &sym});
244 offset, addend, &sym});
251 if (!sym.isInGot()) {
252 in.got->addEntry(sym);
253 uint64_t off = sym.getGotOffset();
255 {R_ABS, target->tlsOffsetRel, off, 0, &sym});
257 c.relocations.push_back({expr, type, offset, addend, &sym});
264 if (in.got->addDynTlsEntry(sym)) {
265 uint64_t off = in.got->getGlobalDynOffset(sym);
270 {R_ADDEND, target->symbolicRel, off, 1, &sym});
272 mainPart->relaDyn->addReloc(target->tlsModuleIndexRel, in.got, off, &sym);
277 if (sym.isPreemptible)
279 &sym);
282 {R_ABS, target->tlsOffsetRel, offsetOff, 0, &sym});
284 c.relocations.push_back({expr, type, offset, addend, &sym});
290 if (sym.isPreemptible) {
293 offset, addend, &sym});
294 if (!sym.isInGot()) {
295 in.got->addEntry(sym);
296 mainPart->relaDyn->addReloc(target->tlsGotRel, in.got, sym.getGotOffset(),
297 &sym);
302 offset, addend, &sym});
312 c.relocations.push_back({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym});
348 static bool isAbsolute(const Symbol &sym) {
349 if (sym.isUndefWeak())
351 if (const auto *dr = dyn_cast<Defined>(&sym))
356 static bool isAbsoluteValue(const Symbol &sym) {
357 return isAbsolute(sym) || sym.isTls();
391 static bool isStaticLinkTimeConstant(RelExpr e, RelType type, const Symbol &sym,
409 if (sym.isPreemptible)
420 bool absVal = isAbsoluteValue(sym);
436 if (sym.isUndefWeak())
441 if (sym.scriptDefined)
445 toString(sym) + getLocation(s, sym, relOff));
510 Symbol *sym = symtab->find(name);
511 if (auto *alias = dyn_cast_or_null<SharedSymbol>(sym))
522 static void replaceWithDefined(Symbol &sym, SectionBase *sec, uint64_t value,
524 Symbol old = sym;
526 sym.replace(Defined{sym.file, sym.getName(), sym.binding, sym.stOther,
527 sym.type, value, size, sec});
529 sym.pltIndex = old.pltIndex;
530 sym.gotIndex = old.gotIndex;
531 sym.verdefIndex = old.verdefIndex;
532 sym.exportDynamic = true;
533 sym.isUsedInRegularObj = true;
603 for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss))
604 replaceWithDefined(*sym, sec, 0, sym->size);
672 static std::string maybeReportDiscarded(Undefined &sym) {
673 auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file);
674 if (!file || !sym.discardedSecIdx ||
675 file->getSections()[sym.discardedSecIdx] != &InputSection::discarded)
681 if (sym.type == ELF::STT_SECTION) {
684 file->getObj().getSectionName(&objSections[sym.discardedSecIdx]), file);
687 toString(sym);
691 Elf_Shdr_Impl<ELFT> elfSec = objSections[sym.discardedSecIdx - 1];
708 Symbol *sym;
736 // file of sym.
738 static const Symbol *getAlternativeSpelling(const Undefined &sym,
742 if (auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file)) {
743 // If sym is a symbol defined in a discarded section, maybeReportDiscarded()
745 if (file && sym.discardedSecIdx != 0 &&
746 file->getSections()[sym.discardedSecIdx] == &InputSection::discarded)
750 for (const Symbol *s : sym.file->getSymbols())
771 StringRef name = sym.getName();
810 for (Symbol *sym : symtab->symbols())
811 if (!sym->isUndefined() && name.equals_lower(sym->getName()))
812 return sym;
836 for (Symbol *sym : symtab->symbols())
837 if (canSuggestExternCForCXX(name, sym->getName())) {
838 s = sym;
854 Symbol &sym = *undef.sym;
857 switch (sym.visibility) {
869 std::string msg = maybeReportDiscarded<ELFT>(cast<Undefined>(sym));
871 msg = "undefined " + visibility() + "symbol: " + toString(sym);
882 std::string src = sec.getSrcMsg(sym, offset);
896 cast<Undefined>(sym), pre_hint, post_hint)) {
903 if (sym.getName().startswith("_ZTV"))
920 if (UndefinedDiag *canon = firstRef.lookup(undef.sym)) {
924 firstRef[undef.sym] = &undef;
936 static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec,
938 if (!sym.isUndefined() || sym.isWeak())
941 bool canBeExternal = !sym.isLocal() && sym.visibility == STV_DEFAULT;
954 if (cast<Undefined>(sym).discardedSecIdx != 0 &&
961 undefs.push_back({&sym, {{&sec, offset}}, isWarning});
1027 Symbol *sym, int64_t addend, RelExpr expr,
1038 isec->relocations.push_back({expr, type, offsetInSec, addend, sym});
1042 part.relaDyn->addReloc(target->relativeRel, isec, offsetInSec, sym, addend,
1048 RelocationBaseSection *rel, RelType type, Symbol &sym) {
1049 plt->addEntry(sym);
1050 gotPlt->addEntry(sym);
1052 {type, gotPlt, sym.getGotPltOffset(), !sym.isPreemptible, &sym, 0});
1055 static void addGotEntry(Symbol &sym) {
1056 in.got->addEntry(sym);
1058 RelExpr expr = sym.isTls() ? R_TLS : R_ABS;
1059 uint64_t off = sym.getGotOffset();
1069 !sym.isPreemptible && (!config->isPic || isAbsolute(sym));
1071 in.got->relocations.push_back({expr, target->symbolicRel, off, 0, &sym});
1077 if (!sym.isTls() && !sym.isPreemptible && config->isPic && !isAbsolute(sym)) {
1078 addRelativeReloc(in.got, off, &sym, 0, R_ABS, target->symbolicRel);
1082 sym.isTls() ? target->tlsGotRel : target->gotRel, in.got, off, &sym, 0,
1083 sym.isPreemptible ? R_ADDEND : R_ABS, target->symbolicRel);
1089 static bool canDefineSymbolInExecutable(Symbol &sym) {
1095 if ((sym.stOther & 0x3) == STV_DEFAULT)
1102 return ((sym.isFunc() && config->ignoreFunctionAddressEquality) ||
1103 (sym.isObject() && config->ignoreDataAddressEquality));
1121 uint64_t offset, Symbol &sym, const RelTy &rel,
1130 if (isStaticLinkTimeConstant(expr, type, sym, sec, offset) ||
1131 (!config->shared && sym.isUndefWeak())) {
1132 sec.relocations.push_back({expr, type, offset, addend, &sym});
1139 if (expr == R_GOT || (rel == target->symbolicRel && !sym.isPreemptible)) {
1140 addRelativeReloc(&sec, offset, &sym, addend, expr, type);
1145 sec.getPartition().relaDyn->addReloc(rel, &sec, offset, &sym, addend,
1164 in.mipsGot->addEntry(*sec.file, sym, addend, expr);
1172 if (!canDefineSymbolInExecutable(sym)) {
1173 errorOrWarn("cannot preempt symbol: " + toString(sym) +
1174 getLocation(sec, sym, offset));
1178 if (sym.isObject()) {
1180 if (auto *ss = dyn_cast<SharedSymbol>(&sym)) {
1185 getLocation(sec, sym, offset));
1188 sec.relocations.push_back({expr, type, offset, addend, &sym});
1219 if (sym.isFunc()) {
1221 errorOrWarn("symbol '" + toString(sym) +
1223 getLocation(sec, sym, offset));
1224 if (!sym.isInPlt())
1225 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym);
1226 if (!sym.isDefined()) {
1228 sym, in.plt,
1229 target->pltHeaderSize + target->pltEntrySize * sym.pltIndex, 0);
1232 cast<Defined>(sym).value = in.plt->headerSize;
1234 cast<PPC32GlinkSection>(in.plt)->canonical_plts.push_back(&sym);
1237 sym.needsPltAddr = true;
1238 sec.relocations.push_back({expr, type, offset, addend, &sym});
1247 (sym.getName().empty() ? "local symbol"
1248 : "symbol: " + toString(sym)) +
1251 getLocation(sec, sym, offset));
1255 (sym.getName().empty() ? "local symbol" : "symbol " + toString(sym)) +
1256 "; recompile with -fPIC" + getLocation(sec, sym, offset));
1260 errorOrWarn("symbol '" + toString(sym) + "' has no type" +
1261 getLocation(sec, sym, offset));
1269 Symbol &sym = sec.getFile<ELFT>()->getSymbol(symIndex);
1287 if (symIndex != 0 && maybeReportUndefined(sym, sec, rel.r_offset))
1291 RelExpr expr = target->getRelExpr(type, sym, relocatedAddr);
1297 if (sym.isGnuIFunc() && !config->zText && config->warnIfuncTextrel) {
1304 getLocation(sec, sym, offset));
1308 int64_t addend = computeAddend<ELFT>(rel, end, sec, expr, sym.isLocal());
1324 if (type == R_PPC64_TOC16_LO && sym.isSection() && isa<Defined>(sym) &&
1325 cast<Defined>(sym).section->name == ".toc")
1326 ppc64noTocRelax.insert({&sym, addend});
1337 if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) {
1338 if (expr == R_GOT_PC && !isAbsoluteValue(sym)) {
1369 handleTlsRelocation<ELFT>(type, sym, sec, offset, addend, expr)) {
1376 if (sym.isGnuIFunc() && config->zIfuncNoplt) {
1377 sym.exportDynamic = true;
1378 mainPart->relaDyn->addReloc(type, &sec, offset, &sym, addend, R_ADDEND, type);
1384 if (!sym.isGnuIFunc() || sym.isPreemptible) {
1386 if (needsPlt(expr) && !sym.isInPlt())
1387 addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym);
1399 in.mipsGot->addEntry(*sec.file, sym, addend, expr);
1400 } else if (!sym.isInGot()) {
1401 addGotEntry(sym);
1445 if (!sym.isInPlt()) {
1447 sym.isInIplt = true;
1456 auto *directSym = make<Defined>(cast<Defined>(sym));
1459 sym.pltIndex = directSym->pltIndex;
1467 sym.gotInIgot = true;
1471 auto &d = cast<Defined>(sym);
1473 d.value = sym.pltIndex * target->ipltEntrySize;
1479 if (sym.gotInIgot) {
1488 sym.gotInIgot = false;
1489 addGotEntry(sym);
1494 processRelocAux<ELFT>(sec, expr, type, offset, sym, rel, addend);
1868 if (auto *d = dyn_cast<Defined>(rel.sym))
1873 thunkVec = &thunkedSymbols[{rel.sym, addend}];
1895 if (Thunk *t = thunks.lookup(rel.sym)) {
1897 rel.sym->getVA(rel.addend) + getPCBias(rel.type)))
1899 rel.sym = &t->destination;
1901 if (rel.sym->isInPlt())
1956 *rel.sym, rel.addend))
1975 rel.sym = t->getThunkTargetSym();
2008 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) {
2017 Symbol *sym = symtab->find("__tls_get_addr");
2018 if (!sym)
2025 if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) {
2028 *sym);
2031 rel.sym = sym;