[PATCH] D60299: ELF: Simplify. NFCI.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 18:31:17 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL357739: ELF: Simplify. NFCI. (authored by pcc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60299?vs=193817&id=193818#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60299/new/

https://reviews.llvm.org/D60299

Files:
  lld/trunk/ELF/InputFiles.cpp


Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -876,7 +876,7 @@
 // Partially parse the shared object file so that we can call
 // getSoName on this object.
 template <class ELFT> void SharedFile<ELFT>::parseDynamic() {
-  const Elf_Shdr *DynamicSec = nullptr;
+  ArrayRef<Elf_Dyn> DynamicTags;
   const ELFFile<ELFT> Obj = this->getObj();
   ArrayRef<Elf_Shdr> Sections = CHECK(Obj.sections(), this);
 
@@ -889,7 +889,8 @@
       this->initSymtab(Sections, &Sec);
       break;
     case SHT_DYNAMIC:
-      DynamicSec = &Sec;
+      DynamicTags =
+          CHECK(Obj.template getSectionContentsAsArray<Elf_Dyn>(&Sec), this);
       break;
     case SHT_GNU_versym:
       this->VersymSec = &Sec;
@@ -904,11 +905,7 @@
     error("SHT_GNU_versym should be associated with symbol table");
 
   // Search for a DT_SONAME tag to initialize this->SoName.
-  if (!DynamicSec)
-    return;
-  ArrayRef<Elf_Dyn> Arr =
-      CHECK(Obj.template getSectionContentsAsArray<Elf_Dyn>(DynamicSec), this);
-  for (const Elf_Dyn &Dyn : Arr) {
+  for (const Elf_Dyn &Dyn : DynamicTags) {
     if (Dyn.d_tag == DT_NEEDED) {
       uint64_t Val = Dyn.getVal();
       if (Val >= this->StringTable.size())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60299.193818.patch
Type: text/x-patch
Size: 1314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190405/ca5da03a/attachment.bin>


More information about the llvm-commits mailing list