diff options
author | zhijian <zhijian@ca.ibm.com> | 2022-11-18 12:10:16 -0500 |
---|---|---|
committer | zhijian <zhijian@ca.ibm.com> | 2022-11-18 12:11:13 -0500 |
commit | 037f5c283a2278ef156189be48db0738323206bd (patch) | |
tree | fe16dd64f02a44f8c9a2dcc76c34f1f53b6d70c8 /llvm/lib/Object/XCOFFObjectFile.cpp | |
parent | 685f671e1d00d2ed93291fd8e1ac34a64df81bab (diff) | |
download | llvm-037f5c283a2278ef156189be48db0738323206bd.zip llvm-037f5c283a2278ef156189be48db0738323206bd.tar.gz llvm-037f5c283a2278ef156189be48db0738323206bd.tar.bz2 |
[XCOFF] llvvm-readobj support display symbol table of loader section of xcoff object file.
Reviewers: James Henderson, Esme Yi
Differential Revision: https://reviews.llvm.org/D135887
Diffstat (limited to 'llvm/lib/Object/XCOFFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/XCOFFObjectFile.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp index c758e35..061c47d 100644 --- a/llvm/lib/Object/XCOFFObjectFile.cpp +++ b/llvm/lib/Object/XCOFFObjectFile.cpp @@ -89,6 +89,34 @@ uint8_t XCOFFRelocation<AddressType>::getRelocatedLength() const { template struct ExceptionSectionEntry<support::ubig32_t>; template struct ExceptionSectionEntry<support::ubig64_t>; +template <typename T> +Expected<StringRef> getLoaderSecSymNameInStrTbl(const T *LoaderSecHeader, + uint64_t Offset) { + if (LoaderSecHeader->LengthOfStrTbl > Offset) + return (reinterpret_cast<const char *>(LoaderSecHeader) + + LoaderSecHeader->OffsetToStrTbl + Offset); + + return createError("entry with offset 0x" + Twine::utohexstr(Offset) + + " in the loader section's string table with size 0x" + + Twine::utohexstr(LoaderSecHeader->LengthOfStrTbl) + + " is invalid"); +} + +Expected<StringRef> LoaderSectionSymbolEntry32::getSymbolName( + const LoaderSectionHeader32 *LoaderSecHeader32) const { + const NameOffsetInStrTbl *NameInStrTbl = + reinterpret_cast<const NameOffsetInStrTbl *>(SymbolName); + if (NameInStrTbl->IsNameInStrTbl != XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC) + return generateXCOFFFixedNameStringRef(SymbolName); + + return getLoaderSecSymNameInStrTbl(LoaderSecHeader32, NameInStrTbl->Offset); +} + +Expected<StringRef> LoaderSectionSymbolEntry64::getSymbolName( + const LoaderSectionHeader64 *LoaderSecHeader64) const { + return getLoaderSecSymNameInStrTbl(LoaderSecHeader64, Offset); +} + uintptr_t XCOFFObjectFile::getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress, uint32_t Distance) { |