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 @@ -29,6 +29,8 @@ constexpr size_t NameSize = 8; constexpr size_t FileHeaderSize32 = 20; constexpr size_t FileHeaderSize64 = 24; +constexpr size_t AuxFileHeaderSize32 = 72; +constexpr size_t AuxFileHeaderSize64 = 110; constexpr size_t SectionHeaderSize32 = 40; constexpr size_t SectionHeaderSize64 = 72; constexpr size_t SymbolTableEntrySize = 18; diff --git a/llvm/include/llvm/ObjectYAML/XCOFFYAML.h b/llvm/include/llvm/ObjectYAML/XCOFFYAML.h --- a/llvm/include/llvm/ObjectYAML/XCOFFYAML.h +++ b/llvm/include/llvm/ObjectYAML/XCOFFYAML.h @@ -29,6 +29,38 @@ llvm::yaml::Hex16 Flags; }; +struct AuxiliaryHeader { + Optional Magic; + Optional Version; + Optional TextStartAddr; + Optional DataStartAddr; + Optional TOCAnchorAddr; + Optional SecNumOfEntryPoint; + Optional SecNumOfText; + Optional SecNumOfData; + Optional SecNumOfTOC; + Optional SecNumOfLoader; + Optional SecNumOfBSS; + Optional MaxAlignOfText; + Optional MaxAlignOfData; + Optional ModuleType; + Optional CpuFlag; + Optional CpuType; + Optional TextPageSize; + Optional DataPageSize; + Optional StackPageSize; + Optional FlagAndTDataAlignment; + Optional TextSize; + Optional InitDataSize; + Optional BssDataSize; + Optional EntryPointAddr; + Optional MaxStackSize; + Optional MaxDataSize; + Optional SecNumOfTData; + Optional SecNumOfTBSS; + Optional Flag; +}; + struct Relocation { llvm::yaml::Hex64 VirtualAddress; llvm::yaml::Hex64 SymbolIndex; @@ -70,6 +102,7 @@ struct Object { FileHeader Header; + Optional AuxHeader; std::vector
Sections; std::vector Symbols; StringTable StrTbl; @@ -97,6 +130,9 @@ static void mapping(IO &IO, XCOFFYAML::FileHeader &H); }; +template <> struct MappingTraits { + static void mapping(IO &IO, XCOFFYAML::AuxiliaryHeader &AuxHdr); +}; template <> struct MappingTraits { static void mapping(IO &IO, XCOFFYAML::Symbol &S); diff --git a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp --- a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp @@ -42,11 +42,13 @@ private: bool nameShouldBeInStringTable(StringRef SymbolName); bool initFileHeader(uint64_t CurrentOffset); + void initAuxFileHeader(); bool initSectionHeader(uint64_t &CurrentOffset); bool initRelocations(uint64_t &CurrentOffset); bool initStringTable(); bool assignAddressesAndIndices(); void writeFileHeader(); + void writeAuxFileHeader(); void writeSectionHeader(); bool writeSectionData(); bool writeRelocations(); @@ -65,6 +67,7 @@ {StringRef("N_ABS"), XCOFF::N_ABS}, {StringRef("N_UNDEF"), XCOFF::N_UNDEF}}; XCOFFYAML::FileHeader InitFileHdr = Obj.Header; + XCOFFYAML::AuxiliaryHeader InitAuxFileHdr; std::vector InitSections = Obj.Sections; }; @@ -232,22 +235,84 @@ return true; } +void XCOFFWriter::initAuxFileHeader() { + InitAuxFileHdr = *Obj.AuxHeader; + // In general, an object file might contain multiple sections of a given type, + // but in a loadable module, there must be exactly one .text, .data, .bss, and + // .loader section. A loadable object might also have one .tdata section and + // one .tbss section. + // Set these section-related values if not set explicitly. We assume that the + // input YAML matches the format of the loadable object. But if input sections + // still have same type, the first section with that type prevails. + for (uint16_t I = 0, E = InitSections.size(); I < E; ++I) { + switch (InitSections[I].Flags) { + case XCOFF::STYP_TEXT: + if (!InitAuxFileHdr.TextSize) + InitAuxFileHdr.TextSize = InitSections[I].Size; + if (!InitAuxFileHdr.TextStartAddr) + InitAuxFileHdr.TextStartAddr = InitSections[I].Address; + if (!InitAuxFileHdr.SecNumOfText) + InitAuxFileHdr.SecNumOfText = I + 1; + break; + case XCOFF::STYP_DATA: + if (!InitAuxFileHdr.InitDataSize) + InitAuxFileHdr.InitDataSize = InitSections[I].Size; + if (!InitAuxFileHdr.DataStartAddr) + InitAuxFileHdr.DataStartAddr = InitSections[I].Address; + if (!InitAuxFileHdr.SecNumOfData) + InitAuxFileHdr.SecNumOfData = I + 1; + break; + case XCOFF::STYP_BSS: + if (!InitAuxFileHdr.BssDataSize) + InitAuxFileHdr.BssDataSize = InitSections[I].Size; + if (!InitAuxFileHdr.SecNumOfBSS) + InitAuxFileHdr.SecNumOfBSS = I + 1; + break; + case XCOFF::STYP_TDATA: + if (!InitAuxFileHdr.SecNumOfTData) + InitAuxFileHdr.SecNumOfTData = I + 1; + break; + case XCOFF::STYP_TBSS: + if (!InitAuxFileHdr.SecNumOfTData) + InitAuxFileHdr.SecNumOfTData = I + 1; + break; + case XCOFF::STYP_LOADER: + if (!InitAuxFileHdr.SecNumOfLoader) + InitAuxFileHdr.SecNumOfLoader = I + 1; + break; + default: + break; + } + } +} + bool XCOFFWriter::assignAddressesAndIndices() { uint64_t FileHdrSize = Is64Bit ? XCOFF::FileHeaderSize64 : XCOFF::FileHeaderSize32; + uint64_t AuxFileHdrSize = 0; + if (Obj.AuxHeader) + AuxFileHdrSize = Obj.Header.AuxHeaderSize + ? Obj.Header.AuxHeaderSize + : (Is64Bit ? XCOFF::AuxFileHeaderSize64 + : XCOFF::AuxFileHeaderSize32); uint64_t SecHdrSize = Is64Bit ? XCOFF::SectionHeaderSize64 : XCOFF::SectionHeaderSize32; - uint64_t CurrentOffset = FileHdrSize /* TODO: + auxiliaryHeaderSize() */ + - InitSections.size() * SecHdrSize; + uint64_t CurrentOffset = + FileHdrSize + AuxFileHdrSize + InitSections.size() * SecHdrSize; // Calculate section header info. if (!initSectionHeader(CurrentOffset)) return false; + InitFileHdr.AuxHeaderSize = AuxFileHdrSize; // Calculate file header info. if (!initFileHeader(CurrentOffset)) return false; + // Initialize the auxiliary file header. + if (Obj.AuxHeader) + initAuxFileHeader(); + // Initialize the string table. return initStringTable(); } @@ -261,7 +326,7 @@ W.write(Obj.Header.SymbolTableOffset ? Obj.Header.SymbolTableOffset : InitFileHdr.SymbolTableOffset); - W.write(Obj.Header.AuxHeaderSize); + W.write(InitFileHdr.AuxHeaderSize); W.write(Obj.Header.Flags); W.write(Obj.Header.NumberOfSymTableEntries ? Obj.Header.NumberOfSymTableEntries @@ -273,11 +338,138 @@ W.write(Obj.Header.NumberOfSymTableEntries ? Obj.Header.NumberOfSymTableEntries : InitFileHdr.NumberOfSymTableEntries); - W.write(Obj.Header.AuxHeaderSize); + W.write(InitFileHdr.AuxHeaderSize); W.write(Obj.Header.Flags); } } +void XCOFFWriter::writeAuxFileHeader() { + W.write(InitAuxFileHdr.Magic ? (uint16_t)*InitAuxFileHdr.Magic : 1); + W.write(InitAuxFileHdr.Version ? (uint16_t)*InitAuxFileHdr.Version + : 1); + if (Is64Bit) { + // Reserved for debugger. + W.OS.write_zeros(4); + W.write(InitAuxFileHdr.TextStartAddr + ? (uint64_t)*InitAuxFileHdr.TextStartAddr + : 0); + W.write(InitAuxFileHdr.DataStartAddr + ? (uint64_t)*InitAuxFileHdr.DataStartAddr + : 0); + W.write(InitAuxFileHdr.TOCAnchorAddr + ? (uint64_t)*InitAuxFileHdr.TOCAnchorAddr + : 0); + } else { + W.write( + InitAuxFileHdr.TextSize ? (uint32_t)*InitAuxFileHdr.TextSize : 0); + W.write(InitAuxFileHdr.InitDataSize + ? (uint32_t)*InitAuxFileHdr.InitDataSize + : 0); + W.write( + InitAuxFileHdr.BssDataSize ? (uint32_t)*InitAuxFileHdr.BssDataSize : 0); + W.write(InitAuxFileHdr.EntryPointAddr + ? (uint32_t)*InitAuxFileHdr.EntryPointAddr + : 0); + W.write(InitAuxFileHdr.TextStartAddr + ? (uint32_t)*InitAuxFileHdr.TextStartAddr + : 0); + W.write(InitAuxFileHdr.DataStartAddr + ? (uint32_t)*InitAuxFileHdr.DataStartAddr + : 0); + W.write(InitAuxFileHdr.TOCAnchorAddr + ? (uint32_t)*InitAuxFileHdr.TOCAnchorAddr + : 0); + } + W.write(InitAuxFileHdr.SecNumOfEntryPoint + ? (uint16_t)*InitAuxFileHdr.SecNumOfEntryPoint + : 0); + W.write( + InitAuxFileHdr.SecNumOfText ? (uint16_t)*InitAuxFileHdr.SecNumOfText : 0); + W.write( + InitAuxFileHdr.SecNumOfData ? (uint16_t)*InitAuxFileHdr.SecNumOfData : 0); + W.write( + InitAuxFileHdr.SecNumOfTOC ? (uint16_t)*InitAuxFileHdr.SecNumOfTOC : 0); + W.write(InitAuxFileHdr.SecNumOfLoader + ? (uint16_t)*InitAuxFileHdr.SecNumOfLoader + : 0); + W.write( + InitAuxFileHdr.SecNumOfBSS ? (uint16_t)*InitAuxFileHdr.SecNumOfBSS : 0); + W.write(InitAuxFileHdr.MaxAlignOfText + ? (uint16_t)*InitAuxFileHdr.MaxAlignOfText + : 0); + W.write(InitAuxFileHdr.MaxAlignOfData + ? (uint16_t)*InitAuxFileHdr.MaxAlignOfData + : 0); + W.write( + InitAuxFileHdr.ModuleType ? (uint16_t)*InitAuxFileHdr.ModuleType : 0); + W.write(InitAuxFileHdr.CpuFlag ? (uint8_t)*InitAuxFileHdr.CpuFlag + : 0); + // Reserved for CUP type. + W.write(0); + if (Is64Bit) { + W.write(InitAuxFileHdr.TextPageSize + ? (uint8_t)*InitAuxFileHdr.TextPageSize + : 0); + W.write(InitAuxFileHdr.DataPageSize + ? (uint8_t)*InitAuxFileHdr.DataPageSize + : 0); + W.write(InitAuxFileHdr.StackPageSize + ? (uint8_t)*InitAuxFileHdr.StackPageSize + : 0); + W.write(InitAuxFileHdr.FlagAndTDataAlignment + ? (uint8_t)*InitAuxFileHdr.FlagAndTDataAlignment + : 128); + W.write( + InitAuxFileHdr.TextSize ? (uint64_t)*InitAuxFileHdr.TextSize : 0); + W.write(InitAuxFileHdr.InitDataSize + ? (uint64_t)*InitAuxFileHdr.InitDataSize + : 0); + W.write( + InitAuxFileHdr.BssDataSize ? (uint64_t)*InitAuxFileHdr.BssDataSize : 0); + W.write(InitAuxFileHdr.EntryPointAddr + ? (uint64_t)*InitAuxFileHdr.EntryPointAddr + : 0); + W.write(InitAuxFileHdr.MaxStackSize + ? (uint64_t)*InitAuxFileHdr.MaxStackSize + : 0); + W.write( + InitAuxFileHdr.MaxDataSize ? (uint64_t)*InitAuxFileHdr.MaxDataSize : 0); + } else { + W.write(InitAuxFileHdr.MaxStackSize + ? (uint32_t)*InitAuxFileHdr.MaxStackSize + : 0); + W.write( + InitAuxFileHdr.MaxDataSize ? (uint32_t)*InitAuxFileHdr.MaxDataSize : 0); + // Reserved for debugger. + W.OS.write_zeros(4); + W.write(InitAuxFileHdr.TextPageSize + ? (uint8_t)*InitAuxFileHdr.TextPageSize + : 0); + W.write(InitAuxFileHdr.DataPageSize + ? (uint8_t)*InitAuxFileHdr.DataPageSize + : 0); + W.write(InitAuxFileHdr.StackPageSize + ? (uint8_t)*InitAuxFileHdr.StackPageSize + : 0); + W.write(InitAuxFileHdr.FlagAndTDataAlignment + ? (uint8_t)*InitAuxFileHdr.FlagAndTDataAlignment + : 0); + } + W.write(InitAuxFileHdr.SecNumOfTData + ? (uint16_t)*InitAuxFileHdr.SecNumOfTData + : 0); + W.write( + InitAuxFileHdr.SecNumOfTBSS ? (uint16_t)*InitAuxFileHdr.SecNumOfTBSS : 0); + if (Is64Bit) { + W.write(InitAuxFileHdr.Flag ? (uint16_t)*InitAuxFileHdr.Flag + : 32768); + if (InitFileHdr.AuxHeaderSize > XCOFF::AuxFileHeaderSize64) + W.OS.write_zeros(InitFileHdr.AuxHeaderSize - XCOFF::AuxFileHeaderSize64); + } else if (InitFileHdr.AuxHeaderSize > XCOFF::AuxFileHeaderSize32) { + W.OS.write_zeros(InitFileHdr.AuxHeaderSize - XCOFF::AuxFileHeaderSize32); + } +} + void XCOFFWriter::writeSectionHeader() { for (uint16_t I = 0, E = Obj.Sections.size(); I < E; ++I) { XCOFFYAML::Section YamlSec = Obj.Sections[I]; @@ -468,6 +660,8 @@ return false; StartOffset = W.OS.tell(); writeFileHeader(); + if (Obj.AuxHeader) + writeAuxFileHeader(); if (!Obj.Sections.empty()) { writeSectionHeader(); if (!writeSectionData()) diff --git a/llvm/lib/ObjectYAML/XCOFFYAML.cpp b/llvm/lib/ObjectYAML/XCOFFYAML.cpp --- a/llvm/lib/ObjectYAML/XCOFFYAML.cpp +++ b/llvm/lib/ObjectYAML/XCOFFYAML.cpp @@ -118,6 +118,37 @@ IO.mapOptional("Flags", FileHdr.Flags); } +void MappingTraits::mapping( + IO &IO, XCOFFYAML::AuxiliaryHeader &AuxHdr) { + IO.mapOptional("Magic", AuxHdr.Magic); + IO.mapOptional("Version", AuxHdr.Version); + IO.mapOptional("TextStartAddr", AuxHdr.TextStartAddr); + IO.mapOptional("DataStartAddr", AuxHdr.DataStartAddr); + IO.mapOptional("TOCAnchorAddr", AuxHdr.TOCAnchorAddr); + IO.mapOptional("TextSectionSize", AuxHdr.TextSize); + IO.mapOptional("DataSectionSize", AuxHdr.InitDataSize); + IO.mapOptional("BssSectionSize", AuxHdr.BssDataSize); + IO.mapOptional("SecNumOfEntryPoint", AuxHdr.SecNumOfEntryPoint); + IO.mapOptional("SecNumOfText", AuxHdr.SecNumOfText); + IO.mapOptional("SecNumOfData", AuxHdr.SecNumOfData); + IO.mapOptional("SecNumOfTOC", AuxHdr.SecNumOfTOC); + IO.mapOptional("SecNumOfLoader", AuxHdr.SecNumOfLoader); + IO.mapOptional("SecNumOfBSS", AuxHdr.SecNumOfBSS); + IO.mapOptional("MaxAlignOfText", AuxHdr.MaxAlignOfText); + IO.mapOptional("MaxAlignOfData", AuxHdr.MaxAlignOfData); + IO.mapOptional("ModuleType", AuxHdr.CpuFlag); + IO.mapOptional("TextPageSize", AuxHdr.TextPageSize); + IO.mapOptional("DataPageSize", AuxHdr.DataPageSize); + IO.mapOptional("StackPageSize", AuxHdr.StackPageSize); + IO.mapOptional("FlagAndTDataAlignment", AuxHdr.FlagAndTDataAlignment); + IO.mapOptional("EntryPointAddr", AuxHdr.EntryPointAddr); + IO.mapOptional("MaxStackSize", AuxHdr.MaxStackSize); + IO.mapOptional("MaxDataSize", AuxHdr.MaxDataSize); + IO.mapOptional("SecNumOfTData", AuxHdr.SecNumOfTData); + IO.mapOptional("SecNumOfTBSS", AuxHdr.SecNumOfTBSS); + IO.mapOptional("Flag", AuxHdr.Flag); +} + void MappingTraits::mapping(IO &IO, XCOFFYAML::Relocation &R) { IO.mapOptional("Address", R.VirtualAddress); @@ -162,6 +193,7 @@ void MappingTraits::mapping(IO &IO, XCOFFYAML::Object &Obj) { IO.mapTag("!XCOFF", true); IO.mapRequired("FileHeader", Obj.Header); + IO.mapOptional("AuxiliaryHeader", Obj.AuxHeader); IO.mapOptional("Sections", Obj.Sections); IO.mapOptional("Symbols", Obj.Symbols); IO.mapOptional("StringTable", Obj.StrTbl); diff --git a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-32.yaml b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-32.yaml --- a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-32.yaml +++ b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-32.yaml @@ -0,0 +1,65 @@ +## Test that we can explicitly specify all fields of the auxiliary file header. +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj --auxiliary-header %t | FileCheck %s + +# CHECK: AuxiliaryHeader { +# CHECK-NEXT: Magic: 0x10B +# CHECK-NEXT: Version: 0x1 +# CHECK-NEXT: Size of .text section: 0x6 +# CHECK-NEXT: Size of .data section: 0x15 +# CHECK-NEXT: Size of .bss section: 0x4 +# CHECK-NEXT: Entry point address: 0x2824 +# CHECK-NEXT: .text section start address: 0x1128 +# CHECK-NEXT: .data section start address: 0x2740 +# CHECK-NEXT: TOC anchor address: 0x2844 +# CHECK-NEXT: Section number of entryPoint: 2 +# CHECK-NEXT: Section number of .text: 1 +# CHECK-NEXT: Section number of .data: 2 +# CHECK-NEXT: Section number of TOC: 2 +# CHECK-NEXT: Section number of loader data: 4 +# CHECK-NEXT: Section number of .bss: 3 +# CHECK-NEXT: Maxium alignment of .text: 0x7 +# CHECK-NEXT: Maxium alignment of .data: 0x3 +# CHECK-NEXT: Module type: 0x0 +# CHECK-NEXT: Cpu type of objects: 0x1 +# CHECK-NEXT: (Reserved): 0x0 +# CHECK-NEXT: Maximum stack size: 0x0 +# CHECK-NEXT: Maximum data size: 0x0 +# CHECK-NEXT: Reserved for debugger: 0x0 +# CHECK-NEXT: Text page size: 0x1 +# CHECK-NEXT: Data page size: 0x1 +# CHECK-NEXT: Stack page size: 0x1 +# CHECK-NEXT: Flag: 0x0 +# CHECK-NEXT: Alignment of thread-local storage: 0x1 +# CHECK-NEXT: Section number for .tdata: 1 +# CHECK-NEXT: Section number for .tbss: 1 +# CHECK-NEXT: } + +--- !XCOFF +FileHeader: + MagicNumber: 0x1DF +AuxiliaryHeader: + Magic: 0x10B + Version: 0x1 + TextSectionSize: 0x6 + DataSectionSize: 0x15 + BssSectionSize: 0x4 + EntryPointAddr: 0x2824 + TextStartAddr: 0x1128 + DataStartAddr: 0x2740 + TOCAnchorAddr: 0x2844 + SecNumOfEntryPoint: 2 + SecNumOfText: 1 + SecNumOfData: 2 + SecNumOfTOC: 2 + SecNumOfLoader: 4 + SecNumOfBSS: 3 + MaxAlignOfText: 0x7 + MaxAlignOfData: 0x3 + ModuleType: 0x1 + TextPageSize: 0x1 + DataPageSize: 0x1 + StackPageSize: 0x1 + SecNumOfTData: 0x1 + SecNumOfTBSS: 0x1 + FlagAndTDataAlignment: 0x1 diff --git a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-64.yaml b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-64.yaml --- a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-64.yaml +++ b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-64.yaml @@ -0,0 +1,67 @@ +## Test that we can explicitly specify all fields of the auxiliary file header. +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj --auxiliary-header %t | FileCheck %s + +# CHECK: AuxiliaryHeader { +# CHECK-NEXT: Magic: 0x10B +# CHECK-NEXT: Version: 0x1 +# CHECK-NEXT: Reserved for debugger: 0x0 +# CHECK-NEXT: .text section start address: 0x11F8 +# CHECK-NEXT: .data section start address: 0x1740 +# CHECK-NEXT: TOC anchor address: 0x18A0 +# CHECK-NEXT: Section number of entryPoint: 2 +# CHECK-NEXT: Section number of .text: 1 +# CHECK-NEXT: Section number of .data: 2 +# CHECK-NEXT: Section number of TOC: 2 +# CHECK-NEXT: Section number of loader data: 4 +# CHECK-NEXT: Section number of .bss: 3 +# CHECK-NEXT: Maxium alignment of .text: 0x7 +# CHECK-NEXT: Maxium alignment of .data: 0x3 +# CHECK-NEXT: Module type: 0x0 +# CHECK-NEXT: Cpu type of objects: 0x1 +# CHECK-NEXT: (Reserved): 0x0 +# CHECK-NEXT: Text page size: 0x1 +# CHECK-NEXT: Data page size: 0x1 +# CHECK-NEXT: Stack page size: 0x1 +# CHECK-NEXT: Flag: 0x0 +# CHECK-NEXT: Alignment of thread-local storage: 0x0 +# CHECK-NEXT: Size of .text section: 0x6 +# CHECK-NEXT: Size of .data section: 0x15 +# CHECK-NEXT: Size of .bss section: 0x4 +# CHECK-NEXT: Entry point address: 0x1860 +# CHECK-NEXT: Maximum stack size: 0x0 +# CHECK-NEXT: Maximum data size: 0x0 +# CHECK-NEXT: Section number for .tdata: 1 +# CHECK-NEXT: Section number for .tbss: 1 +# CHECK-NEXT: Additional flags 64-bit XCOFF: 0x2 +# CHECK-NEXT: } + +--- !XCOFF +FileHeader: + MagicNumber: 0x1F7 +AuxiliaryHeader: + Magic: 0x10B + Version: 0x1 + TextSectionSize: 0x6 + DataSectionSize: 0x15 + BssSectionSize: 0x4 + EntryPointAddr: 0x1860 + TextStartAddr: 0x11F8 + DataStartAddr: 0x1740 + TOCAnchorAddr: 0x18A0 + SecNumOfEntryPoint: 2 + SecNumOfText: 1 + SecNumOfData: 2 + SecNumOfTOC: 2 + SecNumOfLoader: 4 + SecNumOfBSS: 3 + MaxAlignOfText: 0x7 + MaxAlignOfData: 0x3 + ModuleType: 0x1 + TextPageSize: 0x1 + DataPageSize: 0x1 + StackPageSize: 0x1 + SecNumOfTData: 0x1 + SecNumOfTBSS: 0x1 + FlagAndTDataAlignment: 0x1 + Flag: 0x2 diff --git a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml --- a/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml +++ b/llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml @@ -0,0 +1,55 @@ +## Test that yaml2obj automatically sets omited fields of the auxiliary file header if not set explicitly. +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj --auxiliary-header %t | FileCheck %s + +# CHECK: AuxiliaryHeader { +# CHECK-NEXT: Magic: 0x10B +# CHECK-NEXT: Version: 0x1 +# CHECK-NEXT: Size of .text section: 0x4 +# CHECK-NEXT: Size of .data section: 0x4 +# CHECK-NEXT: Size of .bss section: 0x4 +# CHECK-NEXT: Entry point address: 0x0 +# CHECK-NEXT: .text section start address: 0x0 +# CHECK-NEXT: .data section start address: 0x8 +# CHECK-NEXT: TOC anchor address: 0x0 +# CHECK-NEXT: Section number of entryPoint: 0 +# CHECK-NEXT: Section number of .text: 1 +# CHECK-NEXT: Section number of .data: 3 +# CHECK-NEXT: Section number of TOC: 0 +# CHECK-NEXT: Section number of loader data: 6 +# CHECK-NEXT: Section number of .bss: 4 +# CHECK-NEXT: Maxium alignment of .text: 0x0 +# CHECK-NEXT: Maxium alignment of .data: 0x0 +# CHECK-NEXT: Module type: 0x0 +# CHECK-NEXT: Cpu type of objects: 0x0 +# CHECK-NEXT: (Reserved): 0x0 +# CHECK-NEXT: Maximum stack size: 0x0 +# CHECK-NEXT: Maximum data size: 0x0 +# CHECK-NEXT: Reserved for debugger: 0x0 +# CHECK-NEXT: Text page size: 0x0 +# CHECK-NEXT: Data page size: 0x0 +# CHECK-NEXT: Stack page size: 0x0 +# CHECK-NEXT: Flag: 0x0 +# CHECK-NEXT: Alignment of thread-local storage: 0x0 +# CHECK-NEXT: Section number for .tdata: 5 +# CHECK-NEXT: Section number for .tbss: 0 +# CHECK-NEXT: } + +--- !XCOFF +FileHeader: + MagicNumber: 0x1DF +AuxiliaryHeader: + Magic: 0x10B +Sections: + - Flags: [ STYP_TEXT ] + SectionData: "12" + - Flags: [ STYP_TEXT ] + SectionData: "34" + - Flags: [ STYP_DATA ] + SectionData: "56" + - Flags: [ STYP_BSS ] + SectionData: "78" + - Flags: [ STYP_TDATA ] + SectionData: "0910" + - Flags: [ STYP_LOADER ] + SectionData: "1011"