diff --git a/llvm/include/llvm/Object/XCOFFObjectFile.h b/llvm/include/llvm/Object/XCOFFObjectFile.h --- a/llvm/include/llvm/Object/XCOFFObjectFile.h +++ b/llvm/include/llvm/Object/XCOFFObjectFile.h @@ -130,6 +130,8 @@ struct XCOFFCsectAuxEnt32 { static constexpr uint8_t SymbolTypeMask = 0x07; + static constexpr uint8_t SymbolAlignmentMask = 0xF8; + static constexpr size_t SymbolAlignmentBitOffset = 3; support::ubig32_t SectionOrLength; // If the symbol type is XTY_SD or XTY_CM, the csect @@ -144,9 +146,14 @@ support::ubig32_t StabInfoIndex; support::ubig16_t StabSectNum; + uint16_t getAlignmentLog2() const { + return (SymbolAlignmentAndType & SymbolAlignmentMask) >> + SymbolAlignmentBitOffset; + } + uint8_t getSymbolType() const { return SymbolAlignmentAndType & SymbolTypeMask; - }; + } bool isLabel() const { return getSymbolType() == XCOFF::XTY_LD; } }; diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp --- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp +++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp @@ -22,11 +22,6 @@ namespace { class XCOFFDumper : public ObjDumper { - enum { - SymbolTypeMask = 0x07, - SymbolAlignmentMask = 0xF8, - SymbolAlignmentBitOffset = 3 - }; public: XCOFFDumper(const XCOFFObjectFile &Obj, ScopedPrinter &Writer) @@ -211,17 +206,15 @@ DictScope SymDs(W, "CSECT Auxiliary Entry"); W.printNumber("Index", Obj.getSymbolIndex(reinterpret_cast(AuxEntPtr))); - if ((AuxEntPtr->SymbolAlignmentAndType & SymbolTypeMask) == XCOFF::XTY_LD) + if (AuxEntPtr->isLabel()) W.printNumber("ContainingCsectSymbolIndex", AuxEntPtr->SectionOrLength); else W.printNumber("SectionLen", AuxEntPtr->SectionOrLength); W.printHex("ParameterHashIndex", AuxEntPtr->ParameterHashIndex); W.printHex("TypeChkSectNum", AuxEntPtr->TypeChkSectNum); // Print out symbol alignment and type. - W.printNumber("SymbolAlignmentLog2", - (AuxEntPtr->SymbolAlignmentAndType & SymbolAlignmentMask) >> - SymbolAlignmentBitOffset); - W.printEnum("SymbolType", AuxEntPtr->SymbolAlignmentAndType & SymbolTypeMask, + W.printNumber("SymbolAlignmentLog2", AuxEntPtr->getAlignmentLog2()); + W.printEnum("SymbolType", AuxEntPtr->getSymbolType(), makeArrayRef(CsectSymbolTypeClass)); W.printEnum("StorageMappingClass", static_cast(AuxEntPtr->StorageMappingClass),