Lines Matching refs:Header
47 return Obj.Header.Machine == COFF::IMAGE_FILE_MACHINE_AMD64; in is64Bit()
51 return Obj.OptionalHeader->Header.FileAlignment; in getFileAlignment()
72 std::copy(Name.begin(), Name.end(), Sec.Header.Name); in parseSections()
81 Sec.Header.Name[0] = '/'; in parseSections()
82 std::copy(str.begin(), str.end(), Sec.Header.Name + 1); in parseSections()
94 Sec.Header.Characteristics |= (Log2_32(Sec.Alignment) + 1) << 20; in parseSections()
109 std::copy(Name.begin(), Name.end(), Sym.Header.Name); in parseSymbols()
114 Sym.Header.Name + 4) = Index; in parseSymbols()
117 Sym.Header.Type = Sym.SimpleType; in parseSymbols()
118 Sym.Header.Type |= Sym.ComplexType << COFF::SCT_COMPLEX_TYPE_SHIFT; in parseSymbols()
158 CP.Obj.Header.SizeOfOptionalHeader = in layoutOptionalHeader()
174 CP.getHeaderSize() + CP.Obj.Header.SizeOfOptionalHeader; in layoutCOFF()
187 S.Header.SizeOfRawData = S.SectionData.binary_size(); in layoutCOFF()
189 S.Header.SizeOfRawData = in layoutCOFF()
190 alignTo(S.Header.SizeOfRawData, CP.getFileAlignment()); in layoutCOFF()
191 S.Header.PointerToRawData = CurrentSectionDataOffset; in layoutCOFF()
192 CurrentSectionDataOffset += S.Header.SizeOfRawData; in layoutCOFF()
194 S.Header.PointerToRelocations = CurrentSectionDataOffset; in layoutCOFF()
195 S.Header.NumberOfRelocations = S.Relocations.size(); in layoutCOFF()
197 S.Header.NumberOfRelocations * COFF::RelocationSize; in layoutCOFF()
200 S.Header.SizeOfRawData = 0; in layoutCOFF()
201 S.Header.PointerToRawData = 0; in layoutCOFF()
226 i->Header.NumberOfAuxSymbols = NumberOfAuxSymbols; in layoutCOFF()
231 CP.Obj.Header.NumberOfSections = CP.Obj.Sections.size(); in layoutCOFF()
232 CP.Obj.Header.NumberOfSymbols = NumberOfSymbols; in layoutCOFF()
234 CP.Obj.Header.PointerToSymbolTable = SymbolTableStart; in layoutCOFF()
236 CP.Obj.Header.PointerToSymbolTable = 0; in layoutCOFF()
297 static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic, T Header) { in initializeOptionalHeader() argument
298 memset(Header, 0, sizeof(*Header)); in initializeOptionalHeader()
299 Header->Magic = Magic; in initializeOptionalHeader()
300 Header->SectionAlignment = CP.Obj.OptionalHeader->Header.SectionAlignment; in initializeOptionalHeader()
301 Header->FileAlignment = CP.Obj.OptionalHeader->Header.FileAlignment; in initializeOptionalHeader()
305 Header->FileAlignment); in initializeOptionalHeader()
306 uint32_t SizeOfImage = alignTo(SizeOfHeaders, Header->SectionAlignment); in initializeOptionalHeader()
309 if (S.Header.Characteristics & COFF::IMAGE_SCN_CNT_CODE) in initializeOptionalHeader()
310 SizeOfCode += S.Header.SizeOfRawData; in initializeOptionalHeader()
311 if (S.Header.Characteristics & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) in initializeOptionalHeader()
312 SizeOfInitializedData += S.Header.SizeOfRawData; in initializeOptionalHeader()
313 if (S.Header.Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) in initializeOptionalHeader()
314 SizeOfUninitializedData += S.Header.SizeOfRawData; in initializeOptionalHeader()
316 Header->BaseOfCode = S.Header.VirtualAddress; // RVA in initializeOptionalHeader()
318 BaseOfData = S.Header.VirtualAddress; // RVA in initializeOptionalHeader()
319 if (S.Header.VirtualAddress) in initializeOptionalHeader()
320 SizeOfImage += alignTo(S.Header.VirtualSize, Header->SectionAlignment); in initializeOptionalHeader()
322 Header->SizeOfCode = SizeOfCode; in initializeOptionalHeader()
323 Header->SizeOfInitializedData = SizeOfInitializedData; in initializeOptionalHeader()
324 Header->SizeOfUninitializedData = SizeOfUninitializedData; in initializeOptionalHeader()
325 Header->AddressOfEntryPoint = in initializeOptionalHeader()
326 CP.Obj.OptionalHeader->Header.AddressOfEntryPoint; // RVA in initializeOptionalHeader()
327 Header->ImageBase = CP.Obj.OptionalHeader->Header.ImageBase; in initializeOptionalHeader()
328 Header->MajorOperatingSystemVersion = in initializeOptionalHeader()
329 CP.Obj.OptionalHeader->Header.MajorOperatingSystemVersion; in initializeOptionalHeader()
330 Header->MinorOperatingSystemVersion = in initializeOptionalHeader()
331 CP.Obj.OptionalHeader->Header.MinorOperatingSystemVersion; in initializeOptionalHeader()
332 Header->MajorImageVersion = in initializeOptionalHeader()
333 CP.Obj.OptionalHeader->Header.MajorImageVersion; in initializeOptionalHeader()
334 Header->MinorImageVersion = in initializeOptionalHeader()
335 CP.Obj.OptionalHeader->Header.MinorImageVersion; in initializeOptionalHeader()
336 Header->MajorSubsystemVersion = in initializeOptionalHeader()
337 CP.Obj.OptionalHeader->Header.MajorSubsystemVersion; in initializeOptionalHeader()
338 Header->MinorSubsystemVersion = in initializeOptionalHeader()
339 CP.Obj.OptionalHeader->Header.MinorSubsystemVersion; in initializeOptionalHeader()
340 Header->SizeOfImage = SizeOfImage; in initializeOptionalHeader()
341 Header->SizeOfHeaders = SizeOfHeaders; in initializeOptionalHeader()
342 Header->Subsystem = CP.Obj.OptionalHeader->Header.Subsystem; in initializeOptionalHeader()
343 Header->DLLCharacteristics = CP.Obj.OptionalHeader->Header.DLLCharacteristics; in initializeOptionalHeader()
344 Header->SizeOfStackReserve = CP.Obj.OptionalHeader->Header.SizeOfStackReserve; in initializeOptionalHeader()
345 Header->SizeOfStackCommit = CP.Obj.OptionalHeader->Header.SizeOfStackCommit; in initializeOptionalHeader()
346 Header->SizeOfHeapReserve = CP.Obj.OptionalHeader->Header.SizeOfHeapReserve; in initializeOptionalHeader()
347 Header->SizeOfHeapCommit = CP.Obj.OptionalHeader->Header.SizeOfHeapCommit; in initializeOptionalHeader()
348 Header->NumberOfRvaAndSize = COFF::NUM_DATA_DIRECTORIES + 1; in initializeOptionalHeader()
380 << binary_le(CP.Obj.Header.Machine) in writeCOFF()
381 << binary_le(CP.Obj.Header.TimeDateStamp); in writeCOFF()
387 << binary_le(CP.Obj.Header.NumberOfSections) in writeCOFF()
388 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
389 << binary_le(CP.Obj.Header.NumberOfSymbols); in writeCOFF()
391 OS << binary_le(CP.Obj.Header.Machine) in writeCOFF()
392 << binary_le(static_cast<int16_t>(CP.Obj.Header.NumberOfSections)) in writeCOFF()
393 << binary_le(CP.Obj.Header.TimeDateStamp) in writeCOFF()
394 << binary_le(CP.Obj.Header.PointerToSymbolTable) in writeCOFF()
395 << binary_le(CP.Obj.Header.NumberOfSymbols) in writeCOFF()
396 << binary_le(CP.Obj.Header.SizeOfOptionalHeader) in writeCOFF()
397 << binary_le(CP.Obj.Header.Characteristics); in writeCOFF()
429 OS.write(i->Header.Name, COFF::NameSize); in writeCOFF()
430 OS << binary_le(i->Header.VirtualSize) in writeCOFF()
431 << binary_le(i->Header.VirtualAddress) in writeCOFF()
432 << binary_le(i->Header.SizeOfRawData) in writeCOFF()
433 << binary_le(i->Header.PointerToRawData) in writeCOFF()
434 << binary_le(i->Header.PointerToRelocations) in writeCOFF()
435 << binary_le(i->Header.PointerToLineNumbers) in writeCOFF()
436 << binary_le(i->Header.NumberOfRelocations) in writeCOFF()
437 << binary_le(i->Header.NumberOfLineNumbers) in writeCOFF()
438 << binary_le(i->Header.Characteristics); in writeCOFF()
448 CurSymbol += 1 + I->Header.NumberOfAuxSymbols; in writeCOFF()
453 if (!S.Header.SizeOfRawData) in writeCOFF()
455 assert(S.Header.PointerToRawData >= OS.tell()); in writeCOFF()
456 OS << num_zeros(S.Header.PointerToRawData - OS.tell()); in writeCOFF()
458 assert(S.Header.SizeOfRawData >= S.SectionData.binary_size()); in writeCOFF()
459 OS << num_zeros(S.Header.SizeOfRawData - S.SectionData.binary_size()); in writeCOFF()
473 OS.write(i->Header.Name, COFF::NameSize); in writeCOFF()
474 OS << binary_le(i->Header.Value); in writeCOFF()
476 OS << binary_le(i->Header.SectionNumber); in writeCOFF()
478 OS << binary_le(static_cast<int16_t>(i->Header.SectionNumber)); in writeCOFF()
479 OS << binary_le(i->Header.Type) in writeCOFF()
480 << binary_le(i->Header.StorageClass) in writeCOFF()
481 << binary_le(i->Header.NumberOfAuxSymbols); in writeCOFF()
530 if (CP.Obj.Header.PointerToSymbolTable) in writeCOFF()