diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-16 16:53:04 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-16 16:53:04 +0000 |
| commit | b960325989edaba74f38d7c9f0d9006691c7d46b (patch) | |
| tree | 347e96778d4f4d550d6d8caa8c0ad73be8895997 | |
| parent | 5d005a359e78ca1c572385c6d6d90a0061f5b206 (diff) | |
| download | bcm5719-llvm-b960325989edaba74f38d7c9f0d9006691c7d46b.tar.gz bcm5719-llvm-b960325989edaba74f38d7c9f0d9006691c7d46b.zip | |
Simplify RelocationBaseSection::addReloc.
Now that we have R_ADDEND, UseSymVA was redundant. We only want to
write the symbol virtual address when using an expression other than
R_ADDEND.
llvm-svn: 325360
| -rw-r--r-- | lld/ELF/Relocations.cpp | 12 | ||||
| -rw-r--r-- | lld/ELF/SyntheticSections.cpp | 12 | ||||
| -rw-r--r-- | lld/ELF/SyntheticSections.h | 4 |
3 files changed, 12 insertions, 16 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 9efe6024699..882c172905b 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -725,8 +725,8 @@ template <class ELFT> static void addGotEntry(Symbol &Sym) { Type = Target->RelativeRel; else Type = Target->GotRel; - InX::RelaDyn->addReloc(Type, InX::Got, Off, !Sym.IsPreemptible, &Sym, 0, - R_ABS, Target->GotRel); + InX::RelaDyn->addReloc(Type, InX::Got, Off, &Sym, 0, + Sym.IsPreemptible ? R_ADDEND : R_ABS, Target->GotRel); } // Return true if we can define a symbol in the executable that @@ -776,12 +776,12 @@ static RelExpr processRelocAux(InputSectionBase &Sec, RelExpr Expr, bool IsPreemptibleValue = Sym.IsPreemptible && Expr != R_GOT; if (!IsPreemptibleValue) { - InX::RelaDyn->addReloc(Target->RelativeRel, &Sec, Offset, true, &Sym, - Addend, Expr, Type); + InX::RelaDyn->addReloc(Target->RelativeRel, &Sec, Offset, &Sym, Addend, + Expr, Type); return Expr; } else if (Target->isPicRel(Type)) { - InX::RelaDyn->addReloc(Target->getDynRel(Type), &Sec, Offset, false, &Sym, - Addend, Expr, Type); + InX::RelaDyn->addReloc(Target->getDynRel(Type), &Sec, Offset, &Sym, + Addend, R_ADDEND, Type); // MIPS ABI turns using of GOT and dynamic relocations inside out. // While regular ABI uses dynamic relocations to fill up GOT entries diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 4db4a1f55d9..19f6e41eb5c 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1209,18 +1209,14 @@ void RelocationBaseSection::addReloc(RelType DynType, InputSectionBase *IS, void RelocationBaseSection::addReloc(RelType DynType, InputSectionBase *InputSec, - uint64_t OffsetInSec, bool UseSymVA, - Symbol *Sym, int64_t Addend, RelExpr Expr, + uint64_t OffsetInSec, Symbol *Sym, + int64_t Addend, RelExpr Expr, RelType Type) { // Write the addends to the relocated address if required. We skip // it if the written value would be zero. - if (Config->WriteAddends && (UseSymVA || Addend != 0)) { - // If UseSymVA is true we have to write the symbol address, otherwise just - // the addend. - Expr = UseSymVA ? Expr : R_ADDEND; + if (Config->WriteAddends && (Expr != R_ADDEND || Addend != 0)) InputSec->Relocations.push_back({Expr, Type, OffsetInSec, Addend, Sym}); - } - addReloc({DynType, InputSec, OffsetInSec, UseSymVA, Sym, Addend}); + addReloc({DynType, InputSec, OffsetInSec, Expr != R_ADDEND, Sym, Addend}); } void RelocationBaseSection::addReloc(const DynamicReloc &Reloc) { diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 9e36ba43540..30658aed5af 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -366,8 +366,8 @@ public: // Add a dynamic relocation that might need an addend. This takes care of // writing the addend to the output section if needed. void addReloc(RelType DynType, InputSectionBase *InputSec, - uint64_t OffsetInSec, bool UseSymVA, Symbol *Sym, - int64_t Addend, RelExpr Expr, RelType Type); + uint64_t OffsetInSec, Symbol *Sym, int64_t Addend, RelExpr Expr, + RelType Type); void addReloc(const DynamicReloc &Reloc); bool empty() const override { return Relocs.empty(); } size_t getSize() const override { return Relocs.size() * this->Entsize; } |

