[lld] 343e26c - [ELF] Remove a redundant identify_magic call. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 4 14:45:06 PDT 2022
Author: Fangrui Song
Date: 2022-09-04T14:44:58-07:00
New Revision: 343e26c3f0dab1c7f039185bc994d152c9e526a6
URL: https://github.com/llvm/llvm-project/commit/343e26c3f0dab1c7f039185bc994d152c9e526a6
DIFF: https://github.com/llvm/llvm-project/commit/343e26c3f0dab1c7f039185bc994d152c9e526a6.diff
LOG: [ELF] Remove a redundant identify_magic call. NFC
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 1c642e908b2a..88ba11d30653 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -451,16 +451,16 @@ ELFFileBase::ELFFileBase(Kind k, MemoryBufferRef mb) : InputFile(k, mb) {
switch (ekind) {
case ELF32LEKind:
- init<ELF32LE>();
+ init<ELF32LE>(k);
break;
case ELF32BEKind:
- init<ELF32BE>();
+ init<ELF32BE>(k);
break;
case ELF64LEKind:
- init<ELF64LE>();
+ init<ELF64LE>(k);
break;
case ELF64BEKind:
- init<ELF64BE>();
+ init<ELF64BE>(k);
break;
default:
llvm_unreachable("getELFKind");
@@ -475,7 +475,7 @@ static const Elf_Shdr *findSection(ArrayRef<Elf_Shdr> sections, uint32_t type) {
return nullptr;
}
-template <class ELFT> void ELFFileBase::init() {
+template <class ELFT> void ELFFileBase::init(InputFile::Kind k) {
using Elf_Shdr = typename ELFT::Shdr;
using Elf_Sym = typename ELFT::Sym;
@@ -490,10 +490,8 @@ template <class ELFT> void ELFFileBase::init() {
numELFShdrs = sections.size();
// Find a symbol table.
- bool isDSO =
- (identify_magic(mb.getBuffer()) == file_magic::elf_shared_object);
const Elf_Shdr *symtabSec =
- findSection(sections, isDSO ? SHT_DYNSYM : SHT_SYMTAB);
+ findSection(sections, k == SharedKind ? SHT_DYNSYM : SHT_SYMTAB);
if (!symtabSec)
return;
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 450c0295e13e..f426af24734b 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -196,7 +196,7 @@ class ELFFileBase : public InputFile {
protected:
// Initializes this class's member variables.
- template <typename ELFT> void init();
+ template <typename ELFT> void init(InputFile::Kind k);
StringRef stringTable;
const void *elfShdrs = nullptr;
More information about the llvm-commits
mailing list