Skip to content

Commit

Permalink
[LLD][ELF] - Simplify. NFCI.
Browse files Browse the repository at this point in the history
This makes getRISCVPCRelHi20 to be static local helper,
and rotates the 'if' condition.

llvm-svn: 347497
  • Loading branch information
George Rimar committed Nov 23, 2018
1 parent da113f3 commit 0fc5dcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lld/ELF/InputSection.cpp
Expand Up @@ -545,7 +545,7 @@ static uint64_t getARMStaticBase(const Symbol &Sym) {
//
// This function returns the R_RISCV_PCREL_HI20 relocation from
// R_RISCV_PCREL_LO12's symbol and addend.
Relocation *lld::elf::getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
static Relocation *getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
const Defined *D = cast<Defined>(Sym);
InputSection *IS = cast<InputSection>(D->Section);

Expand Down Expand Up @@ -677,11 +677,10 @@ static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A,
return getAArch64Page(Val) - getAArch64Page(P);
}
case R_RISCV_PC_INDIRECT: {
const Relocation *HiRel = getRISCVPCRelHi20(&Sym, A);
if (!HiRel)
return 0;
return getRelocTargetVA(File, HiRel->Type, HiRel->Addend, Sym.getVA(),
*HiRel->Sym, HiRel->Expr);
if (const Relocation *HiRel = getRISCVPCRelHi20(&Sym, A))
return getRelocTargetVA(File, HiRel->Type, HiRel->Addend, Sym.getVA(),
*HiRel->Sym, HiRel->Expr);
return 0;
}
case R_PC: {
uint64_t Dest;
Expand Down
1 change: 0 additions & 1 deletion lld/ELF/InputSection.h
Expand Up @@ -362,7 +362,6 @@ class InputSection : public InputSectionBase {
// The list of all input sections.
extern std::vector<InputSectionBase *> InputSections;

Relocation *getRISCVPCRelHi20(const Symbol *Sym, const uint64_t Addend);
} // namespace elf

std::string toString(const elf::InputSectionBase *);
Expand Down

0 comments on commit 0fc5dcd

Please sign in to comment.