summaryrefslogtreecommitdiff
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2018-06-11 08:37:19 +0000
committerSimon Atanasyan <simon@atanasyan.com>2018-06-11 08:37:19 +0000
commitac3b50a1b93e7fe075c5d4978dcf57c689126004 (patch)
tree0e88111c3890f3a710f527e5f493066e22410762 /lld/ELF/InputSection.cpp
parentc3cc7debb2b34f3aabd64584b54425670af44706 (diff)
[ELF] Pass a pointer to InputFile to the getRelocTargetVA to escape dereferencing of nullptr. NFC
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index b8e4659b921..33f4f25658f 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -477,7 +477,7 @@ static uint64_t getARMStaticBase(const Symbol &Sym) {
return OS->PtLoad->FirstSec->Addr;
}
-static uint64_t getRelocTargetVA(const InputFile &File, RelType Type, int64_t A,
+static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A,
uint64_t P, const Symbol &Sym, RelExpr Expr) {
switch (Expr) {
case R_INVALID:
@@ -516,9 +516,9 @@ static uint64_t getRelocTargetVA(const InputFile &File, RelType Type, int64_t A,
case R_TLSDESC_CALL:
llvm_unreachable("cannot relocate hint relocs");
case R_MIPS_GOTREL:
- return Sym.getVA(A) - InX::MipsGot->getGp(&File);
+ return Sym.getVA(A) - InX::MipsGot->getGp(File);
case R_MIPS_GOT_GP:
- return InX::MipsGot->getGp(&File) + A;
+ return InX::MipsGot->getGp(File) + A;
case R_MIPS_GOT_GP_PC: {
// R_MIPS_LO16 expression has R_MIPS_GOT_GP_PC type iif the target
// is _gp_disp symbol. In that case we should use the following
@@ -527,7 +527,7 @@ static uint64_t getRelocTargetVA(const InputFile &File, RelType Type, int64_t A,
// microMIPS variants of these relocations use slightly different
// expressions: AHL + GP - P + 3 for %lo() and AHL + GP - P - 1 for %hi()
// to correctly handle less-sugnificant bit of the microMIPS symbol.
- uint64_t V = InX::MipsGot->getGp(&File) + A - P;
+ uint64_t V = InX::MipsGot->getGp(File) + A - P;
if (Type == R_MIPS_LO16 || Type == R_MICROMIPS_LO16)
V += 4;
if (Type == R_MICROMIPS_LO16 || Type == R_MICROMIPS_HI16)
@@ -540,7 +540,7 @@ static uint64_t getRelocTargetVA(const InputFile &File, RelType Type, int64_t A,
// of sum the symbol's value and the addend.
return InX::MipsGot->getVA() +
InX::MipsGot->getPageEntryOffset(File, Sym, A) -
- InX::MipsGot->getGp(&File);
+ InX::MipsGot->getGp(File);
case R_MIPS_GOT_OFF:
case R_MIPS_GOT_OFF32:
// In case of MIPS if a GOT relocation has non-zero addend this addend
@@ -548,14 +548,13 @@ static uint64_t getRelocTargetVA(const InputFile &File, RelType Type, int64_t A,
// That is why we use separate expression type.
return InX::MipsGot->getVA() +
InX::MipsGot->getSymEntryOffset(File, Sym, A) -
- InX::MipsGot->getGp(&File);
+ InX::MipsGot->getGp(File);
case R_MIPS_TLSGD:
- return InX::MipsGot->getVA() +
- InX::MipsGot->getGlobalDynOffset(File, Sym) -
- InX::MipsGot->getGp(&File);
+ return InX::MipsGot->getVA() + InX::MipsGot->getGlobalDynOffset(File, Sym) -
+ InX::MipsGot->getGp(File);
case R_MIPS_TLSLD:
return InX::MipsGot->getVA() + InX::MipsGot->getTlsIndexOffset(File) -
- InX::MipsGot->getGp(&File);
+ InX::MipsGot->getGp(File);
case R_PAGE_PC:
case R_PLT_PAGE_PC: {
uint64_t Dest;
@@ -754,7 +753,7 @@ void InputSectionBase::relocateAlloc(uint8_t *Buf, uint8_t *BufEnd) {
uint64_t AddrLoc = getOutputSection()->Addr + Offset;
RelExpr Expr = Rel.Expr;
uint64_t TargetVA = SignExtend64(
- getRelocTargetVA(*File, Type, Rel.Addend, AddrLoc, *Rel.Sym, Expr),
+ getRelocTargetVA(File, Type, Rel.Addend, AddrLoc, *Rel.Sym, Expr),
Bits);
switch (Expr) {