[lld] [LLD][COFF] Check both mangled and demangled symbols before adding a lazy archive symbol to the symbol table on ARM64EC (PR #113284)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 02:12:36 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 8ae39c8e34de2d24c46827b324c76bac845c18b0 f7c45ee69a89336fa14182c4e021a6a19da56de8 --extensions h,cpp -- lld/COFF/InputFiles.cpp lld/COFF/InputFiles.h lld/COFF/SymbolTable.cpp lld/COFF/SymbolTable.h lld/COFF/Symbols.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index fdbc1de4be..d932aa9859 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -470,8 +470,8 @@ void ObjFile::initializeSymbols() {
         if (!targetSym.isAnyUndefined()) {
           // If the target is defined, it may be either a guess exit thunk or
           // the actual implementation. If it's the latter, consider the alias
-          // to be part of the implementation and override potential lazy archive
-          // symbols.
+          // to be part of the implementation and override potential lazy
+          // archive symbols.
           StringRef targetName = check(coffObj->getSymbolName(targetSym));
           StringRef name = check(coffObj->getSymbolName(coffSym));
           std::optional<std::string> mangledName =
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index c93f74c692..0020f8d5f6 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -633,15 +633,18 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *f,
 }
 
 // On ARM64EC, a function symbol may appear in both mangled and demangled forms:
-// - ARM64EC archives contain only the mangled name, while the demangled symbol is
+// - ARM64EC archives contain only the mangled name, while the demangled symbol
+// is
 //   defined by the object file as an alias.
-// - x86_64 archives contain only the demangled name (the mangled name is usually
-//   defined by an object referencing the symbol as an alias to a guess exit thunk).
-// - ARM64EC import files contain both the mangled and demangled names for thunks.
-// If more than one archive defines the same function, this could lead to
-// different libraries being used for the same function depending on how they
-// are referenced. Avoid this by checking if the paired symbol is already defined
-// before adding a symbol to the table.
+// - x86_64 archives contain only the demangled name (the mangled name is
+// usually
+//   defined by an object referencing the symbol as an alias to a guess exit
+//   thunk).
+// - ARM64EC import files contain both the mangled and demangled names for
+// thunks. If more than one archive defines the same function, this could lead
+// to different libraries being used for the same function depending on how they
+// are referenced. Avoid this by checking if the paired symbol is already
+// defined before adding a symbol to the table.
 template <typename T>
 bool checkLazyECPair(SymbolTable *symtab, StringRef name, InputFile *f) {
   if (name.starts_with("__imp_"))
@@ -660,7 +663,8 @@ bool checkLazyECPair(SymbolTable *symtab, StringRef name, InputFile *f) {
     return false;
   if (auto u = dyn_cast<Undefined>(sym))
     return !u->weakAlias || u->isAntiDep;
-  // If the symbol is lazy, allow it only if it originates from the same archive.
+  // If the symbol is lazy, allow it only if it originates from the same
+  // archive.
   auto lazy = dyn_cast<T>(sym);
   return lazy && lazy->file == f;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/113284


More information about the llvm-commits mailing list