diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-10-13 01:42:27 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-10-13 01:42:27 +0000 |
| commit | 5a2b02c3dfff65584d23ca02058cf95147b5afed (patch) | |
| tree | cd3d4bc6417acc481c823777e8b910535cc15eae | |
| parent | 17819c8bbb0f9874a0b30812645d3411d8ae9c17 (diff) | |
| download | bcm5719-llvm-5a2b02c3dfff65584d23ca02058cf95147b5afed.tar.gz bcm5719-llvm-5a2b02c3dfff65584d23ca02058cf95147b5afed.zip | |
Simplify. NFCI.
llvm-svn: 315659
| -rw-r--r-- | lld/ELF/Relocations.cpp | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index ef9e0d03bb7..46770a318b5 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -802,18 +802,8 @@ template <class ELFT> static void addGotEntry(SymbolBody &Sym, bool Preemptible) { InX::Got->addEntry(Sym); + RelExpr Expr = Sym.isTls() ? R_TLS : R_ABS; uint64_t Off = Sym.getGotOffset(); - RelExpr Expr = R_ABS; - RelType DynType; - - if (Sym.isTls()) { - DynType = Target->TlsGotRel; - Expr = R_TLS; - } else if (!Preemptible && Config->Pic && !isAbsolute(Sym)) { - DynType = Target->RelativeRel; - } else { - DynType = Target->GotRel; - } // If a GOT slot value can be calculated at link-time, which is now, // we can just fill that out. @@ -824,22 +814,29 @@ static void addGotEntry(SymbolBody &Sym, bool Preemptible) { // to just write a value now, but it is a TODO.) bool IsLinkTimeConstant = !Preemptible && (!Config->Pic || isAbsolute(Sym)); if (IsLinkTimeConstant) { - InX::Got->Relocations.push_back({Expr, DynType, Off, 0, &Sym}); - } else { - // Otherwise, we emit a dynamic relocation to .rel[a].dyn so that - // the GOT slot will be fixed at load-time. - In<ELFT>::RelaDyn->addReloc( - {DynType, InX::Got, Off, !Preemptible, &Sym, 0}); - - // REL type relocations don't have addend fields unlike RELAs, and - // their addends are stored to the section to which they are applied. - // So, store addends if we need to. - // - // This is ugly -- the difference between REL and RELA should be - // handled in a better way. It's a TODO. - if (!Config->IsRela) - InX::Got->Relocations.push_back({R_ABS, Target->GotRel, Off, 0, &Sym}); + InX::Got->Relocations.push_back({Expr, Target->GotRel, Off, 0, &Sym}); + return; } + + // Otherwise, we emit a dynamic relocation to .rel[a].dyn so that + // the GOT slot will be fixed at load-time. + RelType Type; + if (Sym.isTls()) + Type = Target->TlsGotRel; + else if (!Preemptible && Config->Pic && !isAbsolute(Sym)) + Type = Target->RelativeRel; + else + Type = Target->GotRel; + In<ELFT>::RelaDyn->addReloc({Type, InX::Got, Off, !Preemptible, &Sym, 0}); + + // REL type relocations don't have addend fields unlike RELAs, and + // their addends are stored to the section to which they are applied. + // So, store addends if we need to. + // + // This is ugly -- the difference between REL and RELA should be + // handled in a better way. It's a TODO. + if (!Config->IsRela) + InX::Got->Relocations.push_back({R_ABS, Target->GotRel, Off, 0, &Sym}); } // The reason we have to do this early scan is as follows |

