[llvm] Make llvm-nm's --export-symbols option work for ELF (PR #84379)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 13:27:34 PST 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 83feb846482f0100cb29d460d3d8de2690fc32ad e0cf1f6161e5e4240ba0e4163550a3cbe101551e -- llvm/lib/Object/ModuleSymbolTable.cpp llvm/tools/llvm-nm/llvm-nm.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp
index 4cdb2f39ea..48ad4a2a56 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -199,20 +199,20 @@ void ModuleSymbolTable::printSymbolName(raw_ostream &OS, Symbol S) const {
Mang.getNameWithPrefix(OS, GV, false);
}
- static bool isExportedToOtherDSO(const Triple TT, GlobalValue &GV) {
+static bool isExportedToOtherDSO(const Triple TT, GlobalValue &GV) {
// TODO: Add support for other formats
- if (!TT.isOSBinFormatELF())
- // A defintition is exported if its non-local, and its
- // visibility is either DEFAULT or PROTECTED. All other symbols are not
- // exported.
- return !GV.isDeclarationForLinker() && !GV.hasLocalLinkage() &&
- (GV.hasDefaultVisibility() || GV.hasProtectedVisibility());
- else if (!TT.isOSBinFormatXCOFF())
- return true;
+ if (!TT.isOSBinFormatELF())
+ // A defintition is exported if its non-local, and its
+ // visibility is either DEFAULT or PROTECTED. All other symbols are not
+ // exported.
+ return !GV.isDeclarationForLinker() && !GV.hasLocalLinkage() &&
+ (GV.hasDefaultVisibility() || GV.hasProtectedVisibility());
+ else if (!TT.isOSBinFormatXCOFF())
+ return true;
// TODO: Add support for other file formats
return false;
- }
+}
uint32_t ModuleSymbolTable::getSymbolFlags(Symbol S) const {
if (isa<AsmSymbol *>(S))
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 75d01317a2..b8b7ba83c5 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -2395,8 +2395,9 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
}
// Delete symbols which should not be printed from SymolList.
- llvm::erase_if(SymbolList,
- [](const NMSymbol &s) { return !s.shouldPrint(true /*OnlyExported*/); });
+ llvm::erase_if(SymbolList, [](const NMSymbol &s) {
+ return !s.shouldPrint(true /*OnlyExported*/);
+ });
sortSymbolList(SymbolList);
SymbolList.erase(std::unique(SymbolList.begin(), SymbolList.end()),
SymbolList.end());
``````````
</details>
https://github.com/llvm/llvm-project/pull/84379
More information about the llvm-commits
mailing list