[lld] b5805b7 - [ELF] ObjFile<ELFT>::initializeSymbols: avoid StringRefZ from undefined symbols

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 15:30:22 PST 2021


Author: Fangrui Song
Date: 2021-12-15T15:30:18-08:00
New Revision: b5805b78472e60166df7c67d8a8b493c19bad59c

URL: https://github.com/llvm/llvm-project/commit/b5805b78472e60166df7c67d8a8b493c19bad59c
DIFF: https://github.com/llvm/llvm-project/commit/b5805b78472e60166df7c67d8a8b493c19bad59c.diff

LOG: [ELF] ObjFile<ELFT>::initializeSymbols: avoid StringRefZ from undefined symbols

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 4cfd51905ac57..1f365056b2b18 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1164,10 +1164,10 @@ template <class ELFT> void ObjFile<ELFT>::initializeSymbols() {
   // being resolved to 
diff erent files.
   for (unsigned i : undefineds) {
     const Elf_Sym &eSym = eSyms[i];
-    StringRefZ name = this->stringTable.data() + eSym.st_name;
-    this->symbols[i]->resolve(Undefined{this, name, eSym.getBinding(),
-                                        eSym.st_other, eSym.getType()});
-    this->symbols[i]->referenced = true;
+    Symbol *sym = this->symbols[i];
+    sym->resolve(Undefined{this, sym->getName(), eSym.getBinding(),
+                           eSym.st_other, eSym.getType()});
+    sym->referenced = true;
   }
 }
 


        


More information about the llvm-commits mailing list