summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-01-03 23:26:20 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-01-03 23:26:20 +0000
commitbba410668a7c2b2af2d23a047260e568e5b622ee (patch)
tree2870521a6f0bc79357fbc13df62bc85ba35d33dc
parentbbafd50756b81519617bac03ed6d0ef987f0c45e (diff)
downloadbcm5719-llvm-bba410668a7c2b2af2d23a047260e568e5b622ee.tar.gz
bcm5719-llvm-bba410668a7c2b2af2d23a047260e568e5b622ee.zip
Use references for a few arguments that are never null.
llvm-svn: 321772
-rw-r--r--lld/ELF/Relocations.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 4eb0adb908b..81068686099 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -426,15 +426,15 @@ static RelExpr fromPlt(RelExpr Expr) {
}
// Returns true if a given shared symbol is in a read-only segment in a DSO.
-template <class ELFT> static bool isReadOnly(SharedSymbol *SS) {
+template <class ELFT> static bool isReadOnly(SharedSymbol &SS) {
typedef typename ELFT::Phdr Elf_Phdr;
// Determine if the symbol is read-only by scanning the DSO's program headers.
- const SharedFile<ELFT> &File = SS->getFile<ELFT>();
+ const SharedFile<ELFT> &File = SS.getFile<ELFT>();
for (const Elf_Phdr &Phdr : check(File.getObj().program_headers()))
if ((Phdr.p_type == ELF::PT_LOAD || Phdr.p_type == ELF::PT_GNU_RELRO) &&
- !(Phdr.p_flags & ELF::PF_W) && SS->Value >= Phdr.p_vaddr &&
- SS->Value < Phdr.p_vaddr + Phdr.p_memsz)
+ !(Phdr.p_flags & ELF::PF_W) && SS.Value >= Phdr.p_vaddr &&
+ SS.Value < Phdr.p_vaddr + Phdr.p_memsz)
return true;
return false;
}
@@ -445,15 +445,15 @@ template <class ELFT> static bool isReadOnly(SharedSymbol *SS) {
// them are copied by a copy relocation, all of them need to be copied.
// Otherwise, they would refer different places at runtime.
template <class ELFT>
-static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol *SS) {
+static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol &SS) {
typedef typename ELFT::Sym Elf_Sym;
- SharedFile<ELFT> &File = SS->getFile<ELFT>();
+ SharedFile<ELFT> &File = SS.getFile<ELFT>();
std::vector<SharedSymbol *> Ret;
for (const Elf_Sym &S : File.getGlobalELFSyms()) {
if (S.st_shndx == SHN_UNDEF || S.st_shndx == SHN_ABS ||
- S.st_value != SS->Value)
+ S.st_value != SS.Value)
continue;
StringRef Name = check(S.getName(File.getStringTable()));
Symbol *Sym = Symtab->find(Name);
@@ -505,17 +505,17 @@ static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol *SS) {
// to the variable in .bss. This kind of issue is sometimes very hard to
// debug. What's a solution? Instead of exporting a varaible V from a DSO,
// define an accessor getV().
-template <class ELFT> static void addCopyRelSymbol(SharedSymbol *SS) {
+template <class ELFT> static void addCopyRelSymbol(SharedSymbol &SS) {
// Copy relocation against zero-sized symbol doesn't make sense.
- uint64_t SymSize = SS->getSize();
+ uint64_t SymSize = SS.getSize();
if (SymSize == 0)
- fatal("cannot create a copy relocation for symbol " + toString(*SS));
+ fatal("cannot create a copy relocation for symbol " + toString(SS));
// See if this symbol is in a read-only segment. If so, preserve the symbol's
// memory protection by reserving space in the .bss.rel.ro section.
bool IsReadOnly = isReadOnly<ELFT>(SS);
BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss",
- SymSize, SS->Alignment);
+ SymSize, SS.Alignment);
if (IsReadOnly)
InX::BssRelRo->getParent()->addSection(Sec);
else
@@ -531,7 +531,7 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol *SS) {
Sym->Used = true;
}
- InX::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, SS, 0});
+ InX::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, &SS, 0});
}
static void errorOrWarn(const Twine &Msg) {
@@ -631,7 +631,7 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type,
"'; recompile with -fPIC or remove '-z nocopyreloc'" +
getLocation(S, Sym, RelOff));
- addCopyRelSymbol<ELFT>(B);
+ addCopyRelSymbol<ELFT>(*B);
}
IsConstant = true;
return Expr;
OpenPOWER on IntegriCloud