diff options
| author | Fangrui Song <i@maskray.me> | 2022-09-04 14:44:58 -0700 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2022-09-04 14:44:58 -0700 |
| commit | 343e26c3f0dab1c7f039185bc994d152c9e526a6 (patch) | |
| tree | 6c70ec228e1a482574fe3f001c88b90d7ffca97e | |
| parent | ba3d29f871e04c6cfc64ed84c478dd1846e6148d (diff) | |
| download | llvm-343e26c3f0dab1c7f039185bc994d152c9e526a6.zip llvm-343e26c3f0dab1c7f039185bc994d152c9e526a6.tar.gz llvm-343e26c3f0dab1c7f039185bc994d152c9e526a6.tar.bz2 | |
[ELF] Remove a redundant identify_magic call. NFC
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 14 | ||||
| -rw-r--r-- | 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<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 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 <typename ELFT> void init(); + template <typename ELFT> void init(InputFile::Kind k); StringRef stringTable; const void *elfShdrs = nullptr; |
