auto *D = dyn_cast<Defined>(&S);
// LA25 is required if target file has PIC code
// or target symbol is a PIC symbol.
- return D && D->isMipsPIC<ELFT>();
+ return D && isMipsPIC<ELFT>(D);
}
template <class ELFT>
Type == R_MICROMIPS_LO16 || Type == R_MICROMIPS_GOT_OFST;
}
+// Return true if the symbol is a PIC function.
+template <class ELFT> bool elf::isMipsPIC(const Defined *Sym) {
+ typedef typename ELFT::Ehdr Elf_Ehdr;
+ if (!Sym->Section || !Sym->isFunc())
+ return false;
+
+ auto *Sec = cast<InputSectionBase>(Sym->Section);
+ const Elf_Ehdr *Hdr = Sec->template getFile<ELFT>()->getObj().getHeader();
+ return (Sym->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC ||
+ (Hdr->e_flags & EF_MIPS_PIC);
+}
+
template <class ELFT> TargetInfo *elf::getMipsTargetInfo() {
static MIPS<ELFT> Target;
return &Target;
template TargetInfo *elf::getMipsTargetInfo<ELF32BE>();
template TargetInfo *elf::getMipsTargetInfo<ELF64LE>();
template TargetInfo *elf::getMipsTargetInfo<ELF64BE>();
+
+template bool elf::isMipsPIC<ELF32LE>(const Defined *);
+template bool elf::isMipsPIC<ELF32BE>(const Defined *);
+template bool elf::isMipsPIC<ELF64LE>(const Defined *);
+template bool elf::isMipsPIC<ELF64BE>(const Defined *);
Verstr);
}
-template <class ELFT> bool Defined::isMipsPIC() const {
- typedef typename ELFT::Ehdr Elf_Ehdr;
- if (!Section || !isFunc())
- return false;
-
- auto *Sec = cast<InputSectionBase>(Section);
- const Elf_Ehdr *Hdr = Sec->template getFile<ELFT>()->getObj().getHeader();
- return (this->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC ||
- (Hdr->e_flags & EF_MIPS_PIC);
-}
-
InputFile *Lazy::fetch() {
if (auto *S = dyn_cast<LazyArchive>(this))
return S->fetch();
return *S;
return B.getName();
}
-
-template bool Defined::template isMipsPIC<ELF32LE>() const;
-template bool Defined::template isMipsPIC<ELF32BE>() const;
-template bool Defined::template isMipsPIC<ELF64LE>() const;
-template bool Defined::template isMipsPIC<ELF64BE>() const;
: Symbol(DefinedKind, Name, IsLocal, StOther, Type), Value(Value),
Size(Size), Section(Section) {}
- // Return true if the symbol is a PIC function.
- template <class ELFT> bool isMipsPIC() const;
-
static bool classof(const Symbol *S) { return S->isDefined(); }
uint64_t Value;
if (Config->Relocatable)
if (auto *D = dyn_cast<Defined>(Sym))
- if (D->isMipsPIC<ELFT>())
+ if (isMipsPIC<ELFT>(D))
ESym->st_other |= STO_MIPS_PIC;
++ESym;
}
std::string toString(elf::RelType Type);
namespace elf {
+class Defined;
class InputFile;
class Symbol;
extern TargetInfo *Target;
TargetInfo *getTarget();
+template <class ELFT> bool isMipsPIC(const Defined *Sym);
+
template <unsigned N>
static void checkInt(uint8_t *Loc, int64_t V, RelType Type) {
if (!llvm::isInt<N>(V))