From 343e26c3f0dab1c7f039185bc994d152c9e526a6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 4 Sep 2022 14:44:58 -0700 Subject: [PATCH] [ELF] Remove a redundant identify_magic call. NFC --- lld/ELF/InputFiles.cpp | 14 ++++++-------- lld/ELF/InputFiles.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 1c642e9..88ba11d 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(); + init(k); break; case ELF32BEKind: - init(); + init(k); break; case ELF64LEKind: - init(); + init(k); break; case ELF64BEKind: - init(); + init(k); break; default: llvm_unreachable("getELFKind"); @@ -475,7 +475,7 @@ static const Elf_Shdr *findSection(ArrayRef sections, uint32_t type) { return nullptr; } -template void ELFFileBase::init() { +template void ELFFileBase::init(InputFile::Kind k) { using Elf_Shdr = typename ELFT::Shdr; using Elf_Sym = typename ELFT::Sym; @@ -490,10 +490,8 @@ template 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 450c029..f426af2 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -196,7 +196,7 @@ public: protected: // Initializes this class's member variables. - template void init(); + template void init(InputFile::Kind k); StringRef stringTable; const void *elfShdrs = nullptr; -- 2.7.4