[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
Tue Aug 29 08:16:34 PDT 2023
DiggerLin updated this revision to Diff 554356.
DiggerLin marked 3 inline comments as done.
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,14 @@
if (error(BufferOrErr.getError(), Filename))
return SymbolList;
+ // Ignore AIX linker import files (these files start with "#!"), when
+ // exporting symbols.
+ const char *BuffStart = (*BufferOrErr)->getBufferStart();
+ size_t BufferSize = (*BufferOrErr)->getBufferSize();
+ if (ExportSymbols && BufferSize >= 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 that llvm-nm ignores AIX linker import files when using --export-symbols. These start with "#!".
+# RUN: echo -e "#!\n bar\n foo " > %t_imp.txt
+# RUN: llvm-nm --export-symbols %t_imp.txt 2>&1 | count 0
+
--- !XCOFF
FileHeader:
MagicNumber: 0x1DF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158004.554356.patch
Type: text/x-patch
Size: 1385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230829/d810489e/attachment.bin>
More information about the llvm-commits
mailing list