[llvm] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 01:10:08 PDT 2023
================
@@ -131,7 +200,121 @@ 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) {
+ auto AuxEntTbl = &Sym.AuxEntries;
+ switch (Sym.StorageClass) {
+ case XCOFF::C_FILE: {
+ for (int 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();
+ XCOFFYAML::FileAuxEnt FileAuxSym;
+ FileAuxSym.FileNameOrString = FileNameOrError.get();
+ FileAuxSym.FileStringType = FileAuxEntPtr->Type;
+ AuxEntTbl->push_back(
+ std::make_unique<XCOFFYAML::FileAuxEnt>(FileAuxSym));
+ }
+ 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 (int I = 1; I <= NumOfAuxSym; I++) {
----------------
jh7370 wrote:
Same comments as above.
https://github.com/llvm/llvm-project/pull/70642
More information about the llvm-commits
mailing list