[PATCH] D158004: llvm-nm ignore the Import symbol file for the --export-symbol option.
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 11:34:01 PDT 2023
DiggerLin updated this revision to Diff 550828.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158004/new/
https://reviews.llvm.org/D158004
Files:
llvm/test/tools/llvm-nm/XCOFF/export-symbols.test
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -2262,6 +2262,13 @@
if (error(BufferOrErr.getError(), Filename))
return SymbolList;
+ // Ignore parsing an imported symbol file that begins with #! when we export
+ // symbols.
+ const char *BuffStart = (*BufferOrErr)->getBufferStart();
+ if (ExportSymbols && (*BufferOrErr)->getBufferSize() >= 2 &&
+ BuffStart[0] == '#' && BuffStart[1] == '!')
+ return SymbolList;
+
LLVMContext Context;
LLVMContext *ContextPtr = NoLLVMBitcode ? nullptr : &Context;
Expected<std::unique_ptr<Binary>> BinaryOrErr =
Index: llvm/test/tools/llvm-nm/XCOFF/export-symbols.test
===================================================================
--- llvm/test/tools/llvm-nm/XCOFF/export-symbols.test
+++ llvm/test/tools/llvm-nm/XCOFF/export-symbols.test
@@ -52,6 +52,10 @@
# RUN: yaml2obj -DFLAG=0x2000 --docnum=2 %s -o %t_shared.o
# RUN: llvm-nm --export-symbols %t_shared.o | count 0
+## Test ignoring the parsing an imported symbol file that begins with #!
+# RUN: echo "#!" > imp.txt
+# RUN: llvm-nm --export-symbols imp.txt 2>&1 | FileCheck --allow-empty --implicit-check-not={{.}} %s
+
--- !XCOFF
FileHeader:
MagicNumber: 0x1DF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158004.550828.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/1864ccd7/attachment.bin>
More information about the llvm-commits
mailing list