[lld] r366057 - [LLD][ELF] - Minor simplification. NFC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 04:47:55 PDT 2019


Author: grimar
Date: Mon Jul 15 04:47:54 2019
New Revision: 366057

URL: http://llvm.org/viewvc/llvm-project?rev=366057&view=rev
Log:
[LLD][ELF] - Minor simplification. NFC.

This removes a call to `object::getSymbol<ELFT>`.
We used this function in a next way: it was given an
array of symbols and index and returned either a symbol
at the index given or a error.

This function was removed in D64631. 
(rL366052, but was reverted because of LLD compilation error
that I didn't know about).

It does not make much sense to keep this function on LLVM side
only for LLD, because having only a list of symbols and the index it
is not able to produce a valueable error message about context anyways.




Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=366057&r1=366056&r2=366057&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Jul 15 04:47:54 2019
@@ -466,9 +466,11 @@ template <class ELFT> void ObjFile<ELFT>
 template <class ELFT>
 StringRef ObjFile<ELFT>::getShtGroupSignature(ArrayRef<Elf_Shdr> sections,
                                               const Elf_Shdr &sec) {
-  const Elf_Sym *sym =
-      CHECK(object::getSymbol<ELFT>(this->getELFSyms<ELFT>(), sec.sh_info), this);
-  StringRef signature = CHECK(sym->getName(this->stringTable), this);
+  typename ELFT::SymRange symbols = this->getELFSyms<ELFT>();
+  if (sec.sh_info >= symbols.size())
+    fatal(toString(this) + ": invalid symbol index");
+  const typename ELFT::Sym &sym = symbols[sec.sh_info];
+  StringRef signature = CHECK(sym.getName(this->stringTable), this);
 
   // As a special case, if a symbol is a section symbol and has no name,
   // we use a section name as a signature.
@@ -477,7 +479,7 @@ StringRef ObjFile<ELFT>::getShtGroupSign
   // standard, but GNU gold 1.14 (the newest version as of July 2017) or
   // older produce such sections as outputs for the -r option, so we need
   // a bug-compatibility.
-  if (signature.empty() && sym->getType() == STT_SECTION)
+  if (signature.empty() && sym.getType() == STT_SECTION)
     return getSectionName(sec);
   return signature;
 }




More information about the llvm-commits mailing list