From 622a4bc83b35d3147a71caa220191a23f37789b7 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Mon, 16 Mar 2015 09:14:34 +0000 Subject: [PATCH] [Mips] Add `const` qualifier to some member functions No functional changes. llvm-svn: 232362 --- .../ReaderWriter/ELF/Mips/MipsRelocationPass.cpp | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp index 6d2ac9e..5bd949d 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp @@ -383,10 +383,10 @@ private: bool isLocalCall(const Atom *a) const; bool isDynamic(const Atom *atom) const; bool requireLA25Stub(const Atom *a) const; - bool requirePLTEntry(Reference &ref); - bool requireCopy(Reference &ref); + bool requirePLTEntry(const Atom *a) const; + bool requireCopy(const Atom *a) const; bool mightBeDynamic(const MipsELFDefinedAtom &atom, - const Reference &ref) const; + Reference::KindValue refKind) const; bool hasPLTEntry(const Atom *atom) const; }; @@ -550,10 +550,11 @@ void RelocationPass::handleReference(const MipsELFDefinedAtom &atom, } template -static bool isConstrainSym(const MipsELFDefinedAtom &atom, Reference &ref) { +static bool isConstrainSym(const MipsELFDefinedAtom &atom, + Reference::KindValue refKind) { if ((atom.section()->sh_flags & SHF_ALLOC) == 0) return false; - switch (ref.kindValue()) { + switch (refKind) { case R_MIPS_NONE: case R_MIPS_JALR: case R_MICROMIPS_JALR: @@ -573,17 +574,18 @@ RelocationPass::collectReferenceInfo(const MipsELFDefinedAtom &atom, return; if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF) return; - if (!isConstrainSym(atom, ref)) + + auto refKind = ref.kindValue(); + if (!isConstrainSym(atom, refKind)) return; - if (mightBeDynamic(atom, ref)) + if (mightBeDynamic(atom, refKind)) _rel32Candidates.push_back(&ref); else _hasStaticRelocations.insert(ref.target()); - if (ref.kindValue() != R_MIPS_CALL16 && - ref.kindValue() != R_MICROMIPS_CALL16 && ref.kindValue() != R_MIPS_26 && - ref.kindValue() != R_MICROMIPS_26_S1) + if (refKind != R_MIPS_CALL16 && refKind != R_MICROMIPS_CALL16 && + refKind != R_MIPS_26 && refKind != R_MICROMIPS_26_S1) _requiresPtrEquality.insert(ref.target()); } @@ -610,9 +612,7 @@ static bool isMipsReadonly(const MipsELFDefinedAtom &atom) { template bool RelocationPass::mightBeDynamic(const MipsELFDefinedAtom &atom, - const Reference &ref) const { - auto refKind = ref.kindValue(); - + Reference::KindValue refKind) const { if (refKind == R_MIPS_CALL16 || refKind == R_MIPS_GOT16 || refKind == R_MICROMIPS_CALL16 || refKind == R_MICROMIPS_GOT16) return true; @@ -638,25 +638,25 @@ bool RelocationPass::hasPLTEntry(const Atom *atom) const { } template -bool RelocationPass::requirePLTEntry(Reference &ref) { - if (!_hasStaticRelocations.count(ref.target())) +bool RelocationPass::requirePLTEntry(const Atom *a) const { + if (!_hasStaticRelocations.count(a)) return false; - const auto *sa = dyn_cast>(ref.target()); + const auto *sa = dyn_cast>(a); if (sa && sa->type() != SharedLibraryAtom::Type::Code) return false; - const auto *da = dyn_cast>(ref.target()); + const auto *da = dyn_cast>(a); if (da && da->contentType() != DefinedAtom::typeCode) return false; - if (isLocalCall(ref.target())) + if (isLocalCall(a)) return false; return true; } template -bool RelocationPass::requireCopy(Reference &ref) { - if (!_hasStaticRelocations.count(ref.target())) +bool RelocationPass::requireCopy(const Atom *a) const { + if (!_hasStaticRelocations.count(a)) return false; - const auto *sa = dyn_cast>(ref.target()); + const auto *sa = dyn_cast>(a); return sa && sa->type() == SharedLibraryAtom::Type::Data; } @@ -720,9 +720,9 @@ void RelocationPass::handlePlain(const MipsELFDefinedAtom &atom, if (!isDynamic(ref.target())) return; - if (requirePLTEntry(ref)) + if (requirePLTEntry(ref.target())) ref.setTarget(getPLTEntry(ref.target())); - else if (requireCopy(ref)) + else if (requireCopy(ref.target())) ref.setTarget(getObjectEntry(cast(ref.target()))); } -- 2.7.4