[llvm] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 00:32:48 PST 2023
================
@@ -131,7 +209,119 @@ Error XCOFFDumper::dumpSymbols() {
Sym.Type = SymbolEntRef.getSymbolType();
Sym.StorageClass = SymbolEntRef.getStorageClass();
- Sym.NumberOfAuxEntries = SymbolEntRef.getNumberOfAuxEntries();
+ uint8_t NumOfAuxSym = SymbolEntRef.getNumberOfAuxEntries();
+ Sym.NumberOfAuxEntries = NumOfAuxSym;
+
+ if (NumOfAuxSym) {
+ std::vector<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>> AuxEntTbl;
+ switch (Sym.StorageClass) {
+ case XCOFF::C_FILE: {
+ for (uint8_t I = 1; I <= NumOfAuxSym; ++I) {
+ uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress(
+ SymbolEntRef.getEntryAddress(), I);
+ const XCOFFFileAuxEnt *FileAuxEntPtr =
+ getAuxEntPtr<XCOFFFileAuxEnt>(AuxAddress);
+ auto FileNameOrError = Obj.getCFileName(FileAuxEntPtr);
+ if (!FileNameOrError)
+ return FileNameOrError.takeError();
+
+ dumpFileAuxSym(AuxEntTbl, FileAuxEntPtr->Type, FileNameOrError.get());
+ }
+ break;
+ }
+ case XCOFF::C_STAT: {
+ assert(NumOfAuxSym == 1 && "expected a single aux symbol for C_STAT!");
+ const XCOFFSectAuxEntForStat *AuxEntPtr =
+ getAuxEntPtr<XCOFFSectAuxEntForStat>(
+ XCOFFObjectFile::getAdvancedSymbolEntryAddress(
+ SymbolEntRef.getEntryAddress(), 1));
+ dumpStatAuxSym(AuxEntTbl, *AuxEntPtr);
+ break;
+ }
+ case XCOFF::C_EXT:
+ case XCOFF::C_WEAKEXT:
+ case XCOFF::C_HIDEXT: {
+ for (uint8_t I = 1; I <= NumOfAuxSym; ++I) {
----------------
jh7370 wrote:
Same as above - please move this into a function, as requested before.
https://github.com/llvm/llvm-project/pull/70642
More information about the llvm-commits
mailing list