Home | History | Annotate | Download | only in yaml2obj

Lines Matching refs:CP

142 // Take a CP and assign addresses and sizes to everything. Returns false if the
144 static bool layoutOptionalHeader(COFFParser &CP) {
145 if (!CP.isPE())
147 unsigned PEHeaderSize = CP.is64Bit() ? sizeof(object::pe32plus_header)
149 CP.Obj.Header.SizeOfOptionalHeader =
159 // Take a CP and assign addresses and sizes to everything. Returns false if the
161 static bool layoutCOFF(COFFParser &CP) {
164 CP.SectionTableStart =
165 CP.getHeaderSize() + CP.Obj.Header.SizeOfOptionalHeader;
166 if (CP.isPE())
167 CP.SectionTableStart += DOSStubSize + sizeof(COFF::PEMagic);
168 CP.SectionTableSize = COFF::SectionSize * CP.Obj.Sections.size();
171 CP.SectionTableStart + CP.SectionTableSize;
174 for (COFFYAML::Section &S : CP.Obj.Sections) {
177 CurrentSectionDataOffset, CP.isPE() ? CP.getFileAlignment() : 4);
179 if (CP.isPE())
181 RoundUpToAlignment(S.Header.SizeOfRawData, CP.getFileAlignment());
200 for (std::vector<COFFYAML::Symbol>::iterator i = CP.Obj.Symbols.begin(),
201 e = CP.Obj.Symbols.end();
212 (i->File.size() + CP.getSymbolSize() - 1) / CP.getSymbolSize();
222 CP.Obj.Header.NumberOfSections = CP.Obj.Sections.size();
223 CP.Obj.Header.NumberOfSymbols = NumberOfSymbols;
224 if (NumberOfSymbols > 0 || CP.StringTable.size() > 4)
225 CP.Obj.Header.PointerToSymbolTable = SymbolTableStart;
227 CP.Obj.Header.PointerToSymbolTable = 0;
229 *reinterpret_cast<support::ulittle32_t *>(&CP.StringTable[0])
230 = CP.StringTable.size();
288 static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic, T Header) {
291 Header->SectionAlignment = CP.Obj.OptionalHeader->Header.SectionAlignment;
292 Header->FileAlignment = CP.Obj.OptionalHeader->Header.FileAlignment;
296 CP.SectionTableStart + CP.SectionTableSize, Header->FileAlignment);
300 for (const COFFYAML::Section &S : CP.Obj.Sections) {
319 CP.Obj.OptionalHeader->Header.AddressOfEntryPoint; // RVA
320 Header->ImageBase = CP.Obj.OptionalHeader->Header.ImageBase;
322 CP.Obj.OptionalHeader->Header.MajorOperatingSystemVersion;
324 CP.Obj.OptionalHeader->Header.MinorOperatingSystemVersion;
326 CP.Obj.OptionalHeader->Header.MajorImageVersion;
328 CP.Obj.OptionalHeader->Header.MinorImageVersion;
330 CP.Obj.OptionalHeader->Header.MajorSubsystemVersion;
332 CP.Obj.OptionalHeader->Header.MinorSubsystemVersion;
335 Header->Subsystem = CP.Obj.OptionalHeader->Header.Subsystem;
336 Header->DLLCharacteristics = CP.Obj.OptionalHeader->Header.DLLCharacteristics;
337 Header->SizeOfStackReserve = CP.Obj.OptionalHeader->Header.SizeOfStackReserve;
338 Header->SizeOfStackCommit = CP.Obj.OptionalHeader->Header.SizeOfStackCommit;
339 Header->SizeOfHeapReserve = CP.Obj.OptionalHeader->Header.SizeOfHeapReserve;
340 Header->SizeOfHeapCommit = CP.Obj.OptionalHeader->Header.SizeOfHeapCommit;
345 static bool writeCOFF(COFFParser &CP, raw_ostream &OS) {
346 if (CP.isPE()) {
369 if (CP.useBigObj()) {
373 << binary_le(CP.Obj.Header.Machine)
374 << binary_le(CP.Obj.Header.TimeDateStamp);
380 << binary_le(CP.Obj.Header.NumberOfSections)
381 << binary_le(CP.Obj.Header.PointerToSymbolTable)
382 << binary_le(CP.Obj.Header.NumberOfSymbols);
384 OS << binary_le(CP.Obj.Header.Machine)
385 << binary_le(static_cast<int16_t>(CP.Obj.Header.NumberOfSections))
386 << binary_le(CP.Obj.Header.TimeDateStamp)
387 << binary_le(CP.Obj.Header.PointerToSymbolTable)
388 << binary_le(CP.Obj.Header.NumberOfSymbols)
389 << binary_le(CP.Obj.Header.SizeOfOptionalHeader)
390 << binary_le(CP.Obj.Header.Characteristics);
392 if (CP.isPE()) {
393 if (CP.is64Bit()) {
395 initializeOptionalHeader(CP, COFF::PE32Header::PE32_PLUS, &PEH);
399 uint32_t BaseOfData = initializeOptionalHeader(CP, COFF::PE32Header::PE32, &PEH);
404 CP.Obj.OptionalHeader->DataDirectories) {
417 assert(OS.tell() == CP.SectionTableStart);
419 for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(),
420 e = CP.Obj.Sections.end();
433 assert(OS.tell() == CP.SectionTableStart + CP.SectionTableSize);
437 for (std::vector<COFFYAML::Symbol>::iterator I = CP.Obj.Symbols.begin(),
438 E = CP.Obj.Symbols.end();
445 for (const COFFYAML::Section &S : CP.Obj.Sections) {
463 for (std::vector<COFFYAML::Symbol>::const_iterator i = CP.Obj.Symbols.begin(),
464 e = CP.Obj.Symbols.end();
468 if (CP.useBigObj())
482 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size);
489 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size);
494 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size);
496 unsigned SymbolSize = CP.getSymbolSize();
513 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size);
519 << num_zeros(CP.getSymbolSize() - COFF::Symbol16Size);
523 if (CP.Obj.Header.PointerToSymbolTable)
524 OS.write(&CP.StringTable[0], CP.StringTable.size());
536 COFFParser CP(Doc);
537 if (!CP.parse()) {
542 if (!layoutOptionalHeader(CP)) {
546 if (!layoutCOFF(CP)) {
550 if (!writeCOFF(CP, Out)) {