diff --git a/llvm/include/llvm/BinaryFormat/XCOFF.h b/llvm/include/llvm/BinaryFormat/XCOFF.h --- a/llvm/include/llvm/BinaryFormat/XCOFF.h +++ b/llvm/include/llvm/BinaryFormat/XCOFF.h @@ -26,8 +26,13 @@ constexpr size_t FileNamePadSize = 6; constexpr size_t NameSize = 8; +constexpr size_t FileHeaderSize32 = 20; +constexpr size_t FileHeaderSize64 = 24; +constexpr size_t SectionHeaderSize32 = 40; +constexpr size_t SectionHeaderSize64 = 72; constexpr size_t SymbolTableEntrySize = 18; constexpr size_t RelocationSerializationSize32 = 10; +constexpr size_t RelocationSerializationSize64 = 14; constexpr uint16_t RelocOverflow = 65535; constexpr uint8_t AllocRegNo = 31; @@ -255,29 +260,6 @@ ///< large code model TOC-relative relocation. }; -struct FileHeader32 { - uint16_t Magic; - uint16_t NumberOfSections; - int32_t TimeStamp; - uint32_t SymbolTableFileOffset; - int32_t NumberOfSymbolTableEntries; - uint16_t AuxiliaryHeaderSize; - uint16_t Flags; -}; - -struct SectionHeader32 { - char Name[XCOFF::NameSize]; - uint32_t PhysicalAddress; - uint32_t VirtualAddress; - uint32_t Size; - uint32_t FileOffsetToData; - uint32_t FileOffsetToRelocations; - uint32_t FileOffsetToLineNumbers; - uint16_t NumberOfRelocations; - uint16_t NumberOfLineNumbers; - int32_t Flags; -}; - enum CFileStringType : uint8_t { XFT_FN = 0, ///< Specifies the source-file name. XFT_CT = 1, ///< Specifies the compiler time stamp. diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -922,8 +922,8 @@ SymbolTableEntryCount = SymbolTableIndex; // Calculate the RawPointer value for each section. - uint64_t RawPointer = sizeof(XCOFF::FileHeader32) + auxiliaryHeaderSize() + - SectionCount * sizeof(XCOFF::SectionHeader32); + uint64_t RawPointer = XCOFF::FileHeaderSize32 + auxiliaryHeaderSize() + + SectionCount * XCOFF::SectionHeaderSize32; for (auto *Sec : Sections) { if (Sec->Index == Section::UninitializedIndex || Sec->IsVirtual) continue;