[lld] r248049 - [elf2] Convert if/else cascade into a covered switch. NFC.
Michael J. Spencer via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 14:48:38 PDT 2015
Author: mspencer
Date: Fri Sep 18 16:48:38 2015
New Revision: 248049
URL: http://llvm.org/viewvc/llvm-project?rev=248049&view=rev
Log:
[elf2] Convert if/else cascade into a covered switch. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248049&r1=248048&r2=248049&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Sep 18 16:48:38 2015
@@ -730,18 +730,26 @@ void OutputSection<ELFT>::relocate(
uint32_t Type = RI.getType(IsMips64EL);
uintX_t SymVA;
- if (auto *DR = dyn_cast<DefinedRegular<ELFT>>(Body)) {
- SymVA = getSymVA<ELFT>(DR);
- } else if (auto *DA = dyn_cast<DefinedAbsolute<ELFT>>(Body)) {
- SymVA = DA->Sym.st_value;
- } else if (auto *S = dyn_cast<SharedSymbol<ELFT>>(Body)) {
+
+ switch (Body->kind()) {
+ case SymbolBody::DefinedRegularKind:
+ SymVA = getSymVA<ELFT>(cast<DefinedRegular<ELFT>>(Body));
+ break;
+ case SymbolBody::DefinedAbsoluteKind:
+ SymVA = cast<DefinedAbsolute<ELFT>>(Body)->Sym.st_value;
+ break;
+ case SymbolBody::DefinedCommonKind:
+ continue;
+ case SymbolBody::SharedKind:
if (!relocNeedsGOT(Type))
continue;
- SymVA = GotSec.getEntryAddr(*S);
+ SymVA = GotSec.getEntryAddr(*Body);
Type = R_X86_64_PC32;
- } else {
- // Skip unsupported for now.
+ break;
+ case SymbolBody::UndefinedKind:
continue;
+ case SymbolBody::LazyKind:
+ llvm_unreachable("Lazy symbol reached writer");
}
relocateOne(Buf, RI, Type, BaseAddr, SymVA);
More information about the llvm-commits
mailing list