forked from OSchip/llvm-project
[Mips] Add `const` qualifier to some member functions
No functional changes. llvm-svn: 232362
This commit is contained in:
parent
44e9b094e0
commit
622a4bc83b
|
@ -383,10 +383,10 @@ private:
|
||||||
bool isLocalCall(const Atom *a) const;
|
bool isLocalCall(const Atom *a) const;
|
||||||
bool isDynamic(const Atom *atom) const;
|
bool isDynamic(const Atom *atom) const;
|
||||||
bool requireLA25Stub(const Atom *a) const;
|
bool requireLA25Stub(const Atom *a) const;
|
||||||
bool requirePLTEntry(Reference &ref);
|
bool requirePLTEntry(const Atom *a) const;
|
||||||
bool requireCopy(Reference &ref);
|
bool requireCopy(const Atom *a) const;
|
||||||
bool mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
|
bool mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
const Reference &ref) const;
|
Reference::KindValue refKind) const;
|
||||||
bool hasPLTEntry(const Atom *atom) const;
|
bool hasPLTEntry(const Atom *atom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -550,10 +550,11 @@ void RelocationPass<ELFT>::handleReference(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
static bool isConstrainSym(const MipsELFDefinedAtom<ELFT> &atom, Reference &ref) {
|
static bool isConstrainSym(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
|
Reference::KindValue refKind) {
|
||||||
if ((atom.section()->sh_flags & SHF_ALLOC) == 0)
|
if ((atom.section()->sh_flags & SHF_ALLOC) == 0)
|
||||||
return false;
|
return false;
|
||||||
switch (ref.kindValue()) {
|
switch (refKind) {
|
||||||
case R_MIPS_NONE:
|
case R_MIPS_NONE:
|
||||||
case R_MIPS_JALR:
|
case R_MIPS_JALR:
|
||||||
case R_MICROMIPS_JALR:
|
case R_MICROMIPS_JALR:
|
||||||
|
@ -573,17 +574,18 @@ RelocationPass<ELFT>::collectReferenceInfo(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
return;
|
return;
|
||||||
if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
|
if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
|
||||||
return;
|
return;
|
||||||
if (!isConstrainSym(atom, ref))
|
|
||||||
|
auto refKind = ref.kindValue();
|
||||||
|
if (!isConstrainSym(atom, refKind))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mightBeDynamic(atom, ref))
|
if (mightBeDynamic(atom, refKind))
|
||||||
_rel32Candidates.push_back(&ref);
|
_rel32Candidates.push_back(&ref);
|
||||||
else
|
else
|
||||||
_hasStaticRelocations.insert(ref.target());
|
_hasStaticRelocations.insert(ref.target());
|
||||||
|
|
||||||
if (ref.kindValue() != R_MIPS_CALL16 &&
|
if (refKind != R_MIPS_CALL16 && refKind != R_MICROMIPS_CALL16 &&
|
||||||
ref.kindValue() != R_MICROMIPS_CALL16 && ref.kindValue() != R_MIPS_26 &&
|
refKind != R_MIPS_26 && refKind != R_MICROMIPS_26_S1)
|
||||||
ref.kindValue() != R_MICROMIPS_26_S1)
|
|
||||||
_requiresPtrEquality.insert(ref.target());
|
_requiresPtrEquality.insert(ref.target());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,9 +612,7 @@ static bool isMipsReadonly(const MipsELFDefinedAtom<ELFT> &atom) {
|
||||||
|
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
bool RelocationPass<ELFT>::mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
|
bool RelocationPass<ELFT>::mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
const Reference &ref) const {
|
Reference::KindValue refKind) const {
|
||||||
auto refKind = ref.kindValue();
|
|
||||||
|
|
||||||
if (refKind == R_MIPS_CALL16 || refKind == R_MIPS_GOT16 ||
|
if (refKind == R_MIPS_CALL16 || refKind == R_MIPS_GOT16 ||
|
||||||
refKind == R_MICROMIPS_CALL16 || refKind == R_MICROMIPS_GOT16)
|
refKind == R_MICROMIPS_CALL16 || refKind == R_MICROMIPS_GOT16)
|
||||||
return true;
|
return true;
|
||||||
|
@ -638,25 +638,25 @@ bool RelocationPass<ELFT>::hasPLTEntry(const Atom *atom) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
bool RelocationPass<ELFT>::requirePLTEntry(Reference &ref) {
|
bool RelocationPass<ELFT>::requirePLTEntry(const Atom *a) const {
|
||||||
if (!_hasStaticRelocations.count(ref.target()))
|
if (!_hasStaticRelocations.count(a))
|
||||||
return false;
|
return false;
|
||||||
const auto *sa = dyn_cast<ELFDynamicAtom<ELFT>>(ref.target());
|
const auto *sa = dyn_cast<ELFDynamicAtom<ELFT>>(a);
|
||||||
if (sa && sa->type() != SharedLibraryAtom::Type::Code)
|
if (sa && sa->type() != SharedLibraryAtom::Type::Code)
|
||||||
return false;
|
return false;
|
||||||
const auto *da = dyn_cast<ELFDefinedAtom<ELFT>>(ref.target());
|
const auto *da = dyn_cast<ELFDefinedAtom<ELFT>>(a);
|
||||||
if (da && da->contentType() != DefinedAtom::typeCode)
|
if (da && da->contentType() != DefinedAtom::typeCode)
|
||||||
return false;
|
return false;
|
||||||
if (isLocalCall(ref.target()))
|
if (isLocalCall(a))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
bool RelocationPass<ELFT>::requireCopy(Reference &ref) {
|
bool RelocationPass<ELFT>::requireCopy(const Atom *a) const {
|
||||||
if (!_hasStaticRelocations.count(ref.target()))
|
if (!_hasStaticRelocations.count(a))
|
||||||
return false;
|
return false;
|
||||||
const auto *sa = dyn_cast<ELFDynamicAtom<ELFT>>(ref.target());
|
const auto *sa = dyn_cast<ELFDynamicAtom<ELFT>>(a);
|
||||||
return sa && sa->type() == SharedLibraryAtom::Type::Data;
|
return sa && sa->type() == SharedLibraryAtom::Type::Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,9 +720,9 @@ void RelocationPass<ELFT>::handlePlain(const MipsELFDefinedAtom<ELFT> &atom,
|
||||||
if (!isDynamic(ref.target()))
|
if (!isDynamic(ref.target()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (requirePLTEntry(ref))
|
if (requirePLTEntry(ref.target()))
|
||||||
ref.setTarget(getPLTEntry(ref.target()));
|
ref.setTarget(getPLTEntry(ref.target()));
|
||||||
else if (requireCopy(ref))
|
else if (requireCopy(ref.target()))
|
||||||
ref.setTarget(getObjectEntry(cast<SharedLibraryAtom>(ref.target())));
|
ref.setTarget(getObjectEntry(cast<SharedLibraryAtom>(ref.target())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue