aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/XCOFFObjectFile.cpp
diff options
context:
space:
mode:
authorzhijian <zhijian@ca.ibm.com>2022-02-17 11:37:33 -0500
committerzhijian <zhijian@ca.ibm.com>2022-02-17 11:37:33 -0500
commitfd3ba1f862f54811ff9f4663ff298ff02d9c3b70 (patch)
treedcc0175d09c5a86181660b996655c94e05c78c73 /llvm/lib/Object/XCOFFObjectFile.cpp
parent0b57e6c46b707c0e7a123efe82abf3c1e7b5a503 (diff)
downloadllvm-fd3ba1f862f54811ff9f4663ff298ff02d9c3b70.zip
llvm-fd3ba1f862f54811ff9f4663ff298ff02d9c3b70.tar.gz
llvm-fd3ba1f862f54811ff9f4663ff298ff02d9c3b70.tar.bz2
Title: Export unique symbol list with llvm-nm new option "--export-symbols"
Summary: the patch implement of following functionality. 1. export the symbols from archive or object files. 2. sort the export symbols. (based on same symbol name and visibility) 3. delete the duplicate export symbols (based on same symbol name and visibility) 4. print out the unique and sorted export symbols (print the symbol name and visibility). there are two new options are add in the patch 1. --export-symbols (enable the functionality of export unique symbol) 2. --no-rsrc (exclude the symbol name begin with "__rsrc" from be exporting from xcoff object file) Export symbol list for xcoff object file has the same functionality as The patch has the same functionality as https://www.ibm.com/docs/en/xl-c-aix/13.1.0?topic=library-exporting-symbols-createexportlist-utility Reviewers: James Henderson,Fangrui Song Differential Revision: https://reviews.llvm.org/D112735
Diffstat (limited to 'llvm/lib/Object/XCOFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/XCOFFObjectFile.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index f2f6d70..d9ecb0a 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -615,6 +615,16 @@ Expected<uint32_t> XCOFFObjectFile::getSymbolFlags(DataRefImpl Symb) const {
if (XCOFFSym.getSectionNumber() == XCOFF::N_UNDEF)
Result |= SymbolRef::SF_Undefined;
+ // There is no visibility in old 32 bit XCOFF object file interpret.
+ if (is64Bit() || (auxiliaryHeader32() && (auxiliaryHeader32()->getVersion() ==
+ NEW_XCOFF_INTERPRET))) {
+ uint16_t SymType = XCOFFSym.getSymbolType();
+ if ((SymType & VISIBILITY_MASK) == SYM_V_HIDDEN)
+ Result |= SymbolRef::SF_Hidden;
+
+ if ((SymType & VISIBILITY_MASK) == SYM_V_EXPORTED)
+ Result |= SymbolRef::SF_Exported;
+ }
return Result;
}