Lines Matching refs:Sym
69 static Optional<std::string> getLinkerScriptLocation(const Symbol &Sym) { in getLinkerScriptLocation() argument
72 if (Cmd->Sym == &Sym) in getLinkerScriptLocation()
82 static std::string getLocation(InputSectionBase &S, const Symbol &Sym, in getLocation() argument
85 if (Sym.File) in getLocation()
86 Msg += toString(Sym.File); in getLocation()
87 else if (Optional<std::string> Loc = getLinkerScriptLocation(Sym)) in getLocation()
91 std::string Src = S.getSrcMsg(Sym, Off); in getLocation()
103 static unsigned handleMipsTlsRelocation(RelType Type, Symbol &Sym, in handleMipsTlsRelocation() argument
108 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleMipsTlsRelocation()
112 In.MipsGot->addDynTlsEntry(*C.File, Sym); in handleMipsTlsRelocation()
113 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleMipsTlsRelocation()
134 static unsigned handleARMTlsRelocation(RelType Type, Symbol &Sym, in handleARMTlsRelocation() argument
140 bool NeedDynId = Sym.IsPreemptible || Config->Shared; in handleARMTlsRelocation()
141 bool NeedDynOff = Sym.IsPreemptible; in handleARMTlsRelocation()
156 NeedDynId ? nullptr : &Sym, NeedDynId); in handleARMTlsRelocation()
157 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleARMTlsRelocation()
165 if (In.Got->addDynTlsEntry(Sym)) { in handleARMTlsRelocation()
166 uint64_t Off = In.Got->getGlobalDynOffset(Sym); in handleARMTlsRelocation()
167 AddTlsReloc(Off, Target->TlsModuleIndexRel, &Sym, NeedDynId); in handleARMTlsRelocation()
168 AddTlsReloc(Off + Config->Wordsize, Target->TlsOffsetRel, &Sym, in handleARMTlsRelocation()
171 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleARMTlsRelocation()
180 handleTlsRelocation(RelType Type, Symbol &Sym, InputSectionBase &C, in handleTlsRelocation() argument
182 if (!Sym.isTls()) in handleTlsRelocation()
186 return handleARMTlsRelocation<ELFT>(Type, Sym, C, Offset, Addend, Expr); in handleTlsRelocation()
188 return handleMipsTlsRelocation(Type, Sym, C, Offset, Addend, Expr); in handleTlsRelocation()
192 if (In.Got->addDynTlsEntry(Sym)) { in handleTlsRelocation()
193 uint64_t Off = In.Got->getGlobalDynOffset(Sym); in handleTlsRelocation()
195 {Target->TlsDescRel, In.Got, Off, !Sym.IsPreemptible, &Sym, 0}); in handleTlsRelocation()
198 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
208 Offset, Addend, &Sym}); in handleTlsRelocation()
216 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
224 Offset, Addend, &Sym}); in handleTlsRelocation()
233 C.Relocations.push_back({R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
236 if (!Sym.isInGot()) { in handleTlsRelocation()
237 In.Got->addEntry(Sym); in handleTlsRelocation()
238 uint64_t Off = Sym.getGotOffset(); in handleTlsRelocation()
240 {R_ABS, Target->TlsOffsetRel, Off, 0, &Sym}); in handleTlsRelocation()
242 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
249 if (In.Got->addDynTlsEntry(Sym)) { in handleTlsRelocation()
250 uint64_t Off = In.Got->getGlobalDynOffset(Sym); in handleTlsRelocation()
251 In.RelaDyn->addReloc(Target->TlsModuleIndexRel, In.Got, Off, &Sym); in handleTlsRelocation()
256 if (Sym.IsPreemptible) in handleTlsRelocation()
257 In.RelaDyn->addReloc(Target->TlsOffsetRel, In.Got, OffsetOff, &Sym); in handleTlsRelocation()
260 {R_ABS, Target->TlsOffsetRel, OffsetOff, 0, &Sym}); in handleTlsRelocation()
262 C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
268 if (Sym.IsPreemptible) { in handleTlsRelocation()
271 Offset, Addend, &Sym}); in handleTlsRelocation()
272 if (!Sym.isInGot()) { in handleTlsRelocation()
273 In.Got->addEntry(Sym); in handleTlsRelocation()
274 In.RelaDyn->addReloc(Target->TlsGotRel, In.Got, Sym.getGotOffset(), in handleTlsRelocation()
275 &Sym); in handleTlsRelocation()
280 Offset, Addend, &Sym}); in handleTlsRelocation()
289 !Config->Shared && !Sym.IsPreemptible) { in handleTlsRelocation()
290 C.Relocations.push_back({R_RELAX_TLS_IE_TO_LE, Type, Offset, Addend, &Sym}); in handleTlsRelocation()
326 static bool isAbsolute(const Symbol &Sym) { in isAbsolute() argument
327 if (Sym.isUndefWeak()) in isAbsolute()
329 if (const auto *DR = dyn_cast<Defined>(&Sym)) in isAbsolute()
334 static bool isAbsoluteValue(const Symbol &Sym) { in isAbsoluteValue() argument
335 return isAbsolute(Sym) || Sym.isTls(); in isAbsoluteValue()
371 static bool isStaticLinkTimeConstant(RelExpr E, RelType Type, const Symbol &Sym, in isStaticLinkTimeConstant() argument
385 if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) in isStaticLinkTimeConstant()
393 if (Sym.IsPreemptible) in isStaticLinkTimeConstant()
404 bool AbsVal = isAbsoluteValue(Sym); in isStaticLinkTimeConstant()
422 if (Sym.isUndefWeak()) in isStaticLinkTimeConstant()
426 toString(Sym) + getLocation(S, Sym, RelOff)); in isStaticLinkTimeConstant()
485 typedef typename ELFT::Sym Elf_Sym; in getSymbolsAt()
495 Symbol *Sym = Symtab->find(Name); in getSymbolsAt() local
496 if (auto *Alias = dyn_cast_or_null<SharedSymbol>(Sym)) in getSymbolsAt()
507 static void replaceWithDefined(Symbol &Sym, SectionBase *Sec, uint64_t Value, in replaceWithDefined() argument
509 Symbol Old = Sym; in replaceWithDefined()
510 replaceSymbol<Defined>(&Sym, Sym.File, Sym.getName(), Sym.Binding, in replaceWithDefined()
511 Sym.StOther, Sym.Type, Value, Size, Sec); in replaceWithDefined()
512 Sym.PltIndex = Old.PltIndex; in replaceWithDefined()
513 Sym.GotIndex = Old.GotIndex; in replaceWithDefined()
514 Sym.VerdefIndex = Old.VerdefIndex; in replaceWithDefined()
515 Sym.PPC64BranchltIndex = Old.PPC64BranchltIndex; in replaceWithDefined()
516 Sym.IsPreemptible = true; in replaceWithDefined()
517 Sym.ExportDynamic = true; in replaceWithDefined()
518 Sym.IsUsedInRegularObj = true; in replaceWithDefined()
519 Sym.Used = true; in replaceWithDefined()
583 for (SharedSymbol *Sym : getSymbolsAt<ELFT>(SS)) in addCopyRelSymbol()
584 replaceWithDefined(*Sym, Sec, 0, Sym->Size); in addCopyRelSymbol()
652 static bool maybeReportUndefined(Symbol &Sym, InputSectionBase &Sec, in maybeReportUndefined() argument
654 if (Sym.isLocal() || !Sym.isUndefined() || Sym.isWeak()) in maybeReportUndefined()
658 Sym.computeBinding() != STB_LOCAL && Sym.Visibility == STV_DEFAULT; in maybeReportUndefined()
663 "undefined symbol: " + toString(Sym) + "\n>>> referenced by "; in maybeReportUndefined()
665 std::string Src = Sec.getSrcMsg(Sym, Offset); in maybeReportUndefined()
670 if (Sym.getName().startswith("_ZTV")) in maybeReportUndefined()
746 Symbol *Sym, int64_t Addend, RelExpr Expr, in addRelativeReloc() argument
755 IS->Relocations.push_back({Expr, Type, OffsetInSec, Addend, Sym}); in addRelativeReloc()
759 In.RelaDyn->addReloc(Target->RelativeRel, IS, OffsetInSec, Sym, Addend, Expr, in addRelativeReloc()
765 RelocationBaseSection *Rel, RelType Type, Symbol &Sym) { in addPltEntry() argument
766 Plt->addEntry<ELFT>(Sym); in addPltEntry()
767 GotPlt->addEntry(Sym); in addPltEntry()
769 {Type, GotPlt, Sym.getGotPltOffset(), !Sym.IsPreemptible, &Sym, 0}); in addPltEntry()
772 template <class ELFT> static void addGotEntry(Symbol &Sym) { in addGotEntry() argument
773 In.Got->addEntry(Sym); in addGotEntry()
776 if (Sym.isTls()) in addGotEntry()
778 else if (Sym.isGnuIFunc()) in addGotEntry()
783 uint64_t Off = Sym.getGotOffset(); in addGotEntry()
793 !Sym.IsPreemptible && (!Config->Pic || isAbsolute(Sym)); in addGotEntry()
795 In.Got->Relocations.push_back({Expr, Target->GotRel, Off, 0, &Sym}); in addGotEntry()
801 if (!Sym.isTls() && !Sym.IsPreemptible && Config->Pic && !isAbsolute(Sym)) { in addGotEntry()
802 addRelativeReloc(In.Got, Off, &Sym, 0, R_ABS, Target->GotRel); in addGotEntry()
805 In.RelaDyn->addReloc(Sym.isTls() ? Target->TlsGotRel : Target->GotRel, In.Got, in addGotEntry()
806 Off, &Sym, 0, Sym.IsPreemptible ? R_ADDEND : R_ABS, in addGotEntry()
813 static bool canDefineSymbolInExecutable(Symbol &Sym) { in canDefineSymbolInExecutable() argument
819 if ((Sym.StOther & 0x3) == STV_DEFAULT) in canDefineSymbolInExecutable()
826 return ((Sym.isFunc() && Config->IgnoreFunctionAddressEquality) || in canDefineSymbolInExecutable()
827 (Sym.isObject() && Config->IgnoreDataAddressEquality)); in canDefineSymbolInExecutable()
845 uint64_t Offset, Symbol &Sym, const RelTy &Rel, in processRelocAux() argument
847 if (isStaticLinkTimeConstant(Expr, Type, Sym, Sec, Offset)) { in processRelocAux()
848 Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in processRelocAux()
851 if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) { in processRelocAux()
852 In.RelaDyn->addReloc(Type, &Sec, Offset, &Sym, Addend, R_ADDEND, Type); in processRelocAux()
858 bool IsPreemptibleValue = Sym.IsPreemptible && Expr != R_GOT; in processRelocAux()
861 addRelativeReloc(&Sec, Offset, &Sym, Addend, Expr, Type); in processRelocAux()
864 In.RelaDyn->addReloc(Rel, &Sec, Offset, &Sym, Addend, R_ADDEND, Type); in processRelocAux()
882 In.MipsGot->addEntry(*Sec.File, Sym, Addend, Expr); in processRelocAux()
889 if (!Config->Shared && Sym.isUndefWeak()) { in processRelocAux()
890 Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in processRelocAux()
897 (Sym.getName().empty() ? "local symbol" : "symbol: " + toString(Sym)) + in processRelocAux()
900 getLocation(Sec, Sym, Offset)); in processRelocAux()
907 " cannot be used against symbol " + toString(Sym) + in processRelocAux()
908 "; recompile with -fPIC" + getLocation(Sec, Sym, Offset)); in processRelocAux()
913 if (Sym.isUndefined()) in processRelocAux()
916 if (!canDefineSymbolInExecutable(Sym)) { in processRelocAux()
917 error("cannot preempt symbol: " + toString(Sym) + in processRelocAux()
918 getLocation(Sec, Sym, Offset)); in processRelocAux()
922 if (Sym.isObject()) { in processRelocAux()
924 if (auto *SS = dyn_cast<SharedSymbol>(&Sym)) { in processRelocAux()
929 getLocation(Sec, Sym, Offset)); in processRelocAux()
932 Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in processRelocAux()
936 if (Sym.isFunc()) { in processRelocAux()
965 errorOrWarn("symbol '" + toString(Sym) + in processRelocAux()
967 getLocation(Sec, Sym, Offset)); in processRelocAux()
968 if (!Sym.isInPlt()) in processRelocAux()
969 addPltEntry<ELFT>(In.Plt, In.GotPlt, In.RelaPlt, Target->PltRel, Sym); in processRelocAux()
970 if (!Sym.isDefined()) in processRelocAux()
971 replaceWithDefined(Sym, In.Plt, getPltEntryOffset(Sym.PltIndex), 0); in processRelocAux()
972 Sym.NeedsPltAddr = true; in processRelocAux()
973 Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); in processRelocAux()
977 errorOrWarn("symbol '" + toString(Sym) + "' has no type" + in processRelocAux()
978 getLocation(Sec, Sym, Offset)); in processRelocAux()
985 Symbol &Sym = Sec.getFile<ELFT>()->getRelocTargetSym(Rel); in scanReloc() local
1002 if (maybeReportUndefined(Sym, Sec, Rel.r_offset)) in scanReloc()
1006 RelExpr Expr = Target->getRelExpr(Type, Sym, RelocatedAddr); in scanReloc()
1023 if (Sym.isGnuIFunc() && !Config->ZIfuncnoplt) { in scanReloc()
1031 getLocation(Sec, Sym, Offset)); in scanReloc()
1034 } else if (!Sym.IsPreemptible && Expr == R_GOT_PC && !isAbsoluteValue(Sym)) { in scanReloc()
1036 } else if (!Sym.IsPreemptible) { in scanReloc()
1047 int64_t Addend = computeAddend<ELFT>(Rel, End, Sec, Expr, Sym.isLocal()); in scanReloc()
1052 handleTlsRelocation<ELFT>(Type, Sym, Sec, Offset, Addend, Expr)) { in scanReloc()
1058 if (needsPlt(Expr) && !Sym.isInPlt()) { in scanReloc()
1059 if (Sym.isGnuIFunc() && !Sym.IsPreemptible) in scanReloc()
1061 Sym); in scanReloc()
1063 addPltEntry<ELFT>(In.Plt, In.GotPlt, In.RelaPlt, Target->PltRel, Sym); in scanReloc()
1076 In.MipsGot->addEntry(*Sec.File, Sym, Addend, Expr); in scanReloc()
1077 } else if (!Sym.isInGot()) { in scanReloc()
1078 addGotEntry<ELFT>(Sym); in scanReloc()
1082 processRelocAux<ELFT>(Sec, Expr, Type, Offset, Sym, Rel, Addend); in scanReloc()
1388 std::pair<Thunk *, bool> ThunkCreator::getThunk(Symbol &Sym, RelType Type, in getThunk() argument
1394 if (auto *D = dyn_cast<Defined>(&Sym)) in getThunk()
1398 ThunkVec = &ThunkedSymbols[&Sym]; in getThunk()
1407 Thunk *T = addThunk(Type, Sym); in getThunk()
1417 if (Thunk *T = Thunks.lookup(Rel.Sym)) { in normalizeExistingThunk()
1418 if (Target->inBranchRange(Rel.Type, Src, Rel.Sym->getVA())) in normalizeExistingThunk()
1420 Rel.Sym = &T->Destination; in normalizeExistingThunk()
1421 if (Rel.Sym->isInPlt()) in normalizeExistingThunk()
1481 *Rel.Sym)) in createThunks()
1486 std::tie(T, IsNew) = getThunk(*Rel.Sym, Rel.Type, Src); in createThunks()
1500 Rel.Sym = T->getThunkTargetSym(); in createThunks()