[ELF] Simplify code with invokeELFT. NFC

This commit is contained in:
Fangrui Song 2022-02-01 09:53:28 -08:00
parent c935f6e048
commit 17a39aecd1
2 changed files with 3 additions and 34 deletions

View File

@ -13,6 +13,7 @@
#include "SymbolTable.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/DWARF.h"
#include "llvm/ADT/STLExtras.h"
@ -217,24 +218,7 @@ template <class ELFT> static void doParseFile(InputFile *file) {
}
// Add symbols in File to the symbol table.
void elf::parseFile(InputFile *file) {
switch (config->ekind) {
case ELF32LEKind:
doParseFile<ELF32LE>(file);
return;
case ELF32BEKind:
doParseFile<ELF32BE>(file);
return;
case ELF64LEKind:
doParseFile<ELF64LE>(file);
return;
case ELF64BEKind:
doParseFile<ELF64BE>(file);
return;
default:
llvm_unreachable("unknown ELFT");
}
}
void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }
// Concatenates arguments to construct a string representing an error location.
static std::string createFileLineMsg(StringRef path, unsigned line) {

View File

@ -83,22 +83,7 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
if (!zlib::isAvailable())
error(toString(file) + ": contains a compressed section, " +
"but zlib is not available");
switch (config->ekind) {
case ELF32LEKind:
parseCompressedHeader<ELF32LE>();
break;
case ELF32BEKind:
parseCompressedHeader<ELF32BE>();
break;
case ELF64LEKind:
parseCompressedHeader<ELF64LE>();
break;
case ELF64BEKind:
parseCompressedHeader<ELF64BE>();
break;
default:
llvm_unreachable("unknown ELFT");
}
invokeELFT(parseCompressedHeader);
}
}