comparison include/llvm/BinaryFormat/COFF.h @ 148:63bd29f05246

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 19:46:37 +0900
parents c2174574ed3a
children
comparison
equal deleted inserted replaced
146:3fc4d5c3e21e 148:63bd29f05246
1 //===-- llvm/BinaryFormat/COFF.h --------------------------------*- C++ -*-===// 1 //===-- llvm/BinaryFormat/COFF.h --------------------------------*- C++ -*-===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // 4 // See https://llvm.org/LICENSE.txt for license information.
5 // This file is distributed under the University of Illinois Open Source 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 // 8 //
10 // This file contains an definitions used in Windows COFF Files. 9 // This file contains an definitions used in Windows COFF Files.
11 // 10 //
108 IMAGE_FILE_MACHINE_MIPSFPU = 0x366, 107 IMAGE_FILE_MACHINE_MIPSFPU = 0x366,
109 IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466, 108 IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,
110 IMAGE_FILE_MACHINE_POWERPC = 0x1F0, 109 IMAGE_FILE_MACHINE_POWERPC = 0x1F0,
111 IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1, 110 IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1,
112 IMAGE_FILE_MACHINE_R4000 = 0x166, 111 IMAGE_FILE_MACHINE_R4000 = 0x166,
112 IMAGE_FILE_MACHINE_RISCV32 = 0x5032,
113 IMAGE_FILE_MACHINE_RISCV64 = 0x5064,
114 IMAGE_FILE_MACHINE_RISCV128 = 0x5128,
113 IMAGE_FILE_MACHINE_SH3 = 0x1A2, 115 IMAGE_FILE_MACHINE_SH3 = 0x1A2,
114 IMAGE_FILE_MACHINE_SH3DSP = 0x1A3, 116 IMAGE_FILE_MACHINE_SH3DSP = 0x1A3,
115 IMAGE_FILE_MACHINE_SH4 = 0x1A6, 117 IMAGE_FILE_MACHINE_SH4 = 0x1A6,
116 IMAGE_FILE_MACHINE_SH5 = 0x1A8, 118 IMAGE_FILE_MACHINE_SH5 = 0x1A8,
117 IMAGE_FILE_MACHINE_THUMB = 0x1C2, 119 IMAGE_FILE_MACHINE_THUMB = 0x1C2,
366 IMAGE_REL_ARM_BRANCH24 = 0x0003, 368 IMAGE_REL_ARM_BRANCH24 = 0x0003,
367 IMAGE_REL_ARM_BRANCH11 = 0x0004, 369 IMAGE_REL_ARM_BRANCH11 = 0x0004,
368 IMAGE_REL_ARM_TOKEN = 0x0005, 370 IMAGE_REL_ARM_TOKEN = 0x0005,
369 IMAGE_REL_ARM_BLX24 = 0x0008, 371 IMAGE_REL_ARM_BLX24 = 0x0008,
370 IMAGE_REL_ARM_BLX11 = 0x0009, 372 IMAGE_REL_ARM_BLX11 = 0x0009,
373 IMAGE_REL_ARM_REL32 = 0x000A,
371 IMAGE_REL_ARM_SECTION = 0x000E, 374 IMAGE_REL_ARM_SECTION = 0x000E,
372 IMAGE_REL_ARM_SECREL = 0x000F, 375 IMAGE_REL_ARM_SECREL = 0x000F,
373 IMAGE_REL_ARM_MOV32A = 0x0010, 376 IMAGE_REL_ARM_MOV32A = 0x0010,
374 IMAGE_REL_ARM_MOV32T = 0x0011, 377 IMAGE_REL_ARM_MOV32T = 0x0011,
375 IMAGE_REL_ARM_BRANCH20T = 0x0012, 378 IMAGE_REL_ARM_BRANCH20T = 0x0012,
376 IMAGE_REL_ARM_BRANCH24T = 0x0014, 379 IMAGE_REL_ARM_BRANCH24T = 0x0014,
377 IMAGE_REL_ARM_BLX23T = 0x0015 380 IMAGE_REL_ARM_BLX23T = 0x0015,
381 IMAGE_REL_ARM_PAIR = 0x0016,
378 }; 382 };
379 383
380 enum RelocationTypesARM64 : unsigned { 384 enum RelocationTypesARM64 : unsigned {
381 IMAGE_REL_ARM64_ABSOLUTE = 0x0000, 385 IMAGE_REL_ARM64_ABSOLUTE = 0x0000,
382 IMAGE_REL_ARM64_ADDR32 = 0x0001, 386 IMAGE_REL_ARM64_ADDR32 = 0x0001,
393 IMAGE_REL_ARM64_TOKEN = 0x000C, 397 IMAGE_REL_ARM64_TOKEN = 0x000C,
394 IMAGE_REL_ARM64_SECTION = 0x000D, 398 IMAGE_REL_ARM64_SECTION = 0x000D,
395 IMAGE_REL_ARM64_ADDR64 = 0x000E, 399 IMAGE_REL_ARM64_ADDR64 = 0x000E,
396 IMAGE_REL_ARM64_BRANCH19 = 0x000F, 400 IMAGE_REL_ARM64_BRANCH19 = 0x000F,
397 IMAGE_REL_ARM64_BRANCH14 = 0x0010, 401 IMAGE_REL_ARM64_BRANCH14 = 0x0010,
398 }; 402 IMAGE_REL_ARM64_REL32 = 0x0011,
399 403 };
400 enum COMDATType : unsigned { 404
405 enum COMDATType : uint8_t {
401 IMAGE_COMDAT_SELECT_NODUPLICATES = 1, 406 IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
402 IMAGE_COMDAT_SELECT_ANY, 407 IMAGE_COMDAT_SELECT_ANY,
403 IMAGE_COMDAT_SELECT_SAME_SIZE, 408 IMAGE_COMDAT_SELECT_SAME_SIZE,
404 IMAGE_COMDAT_SELECT_EXACT_MATCH, 409 IMAGE_COMDAT_SELECT_EXACT_MATCH,
405 IMAGE_COMDAT_SELECT_ASSOCIATIVE, 410 IMAGE_COMDAT_SELECT_ASSOCIATIVE,
458 AuxiliarybfAndefSymbol bfAndefSymbol; 463 AuxiliarybfAndefSymbol bfAndefSymbol;
459 AuxiliaryWeakExternal WeakExternal; 464 AuxiliaryWeakExternal WeakExternal;
460 AuxiliarySectionDefinition SectionDefinition; 465 AuxiliarySectionDefinition SectionDefinition;
461 }; 466 };
462 467
463 /// @brief The Import Directory Table. 468 /// The Import Directory Table.
464 /// 469 ///
465 /// There is a single array of these and one entry per imported DLL. 470 /// There is a single array of these and one entry per imported DLL.
466 struct ImportDirectoryTableEntry { 471 struct ImportDirectoryTableEntry {
467 uint32_t ImportLookupTableRVA; 472 uint32_t ImportLookupTableRVA;
468 uint32_t TimeDateStamp; 473 uint32_t TimeDateStamp;
469 uint32_t ForwarderChain; 474 uint32_t ForwarderChain;
470 uint32_t NameRVA; 475 uint32_t NameRVA;
471 uint32_t ImportAddressTableRVA; 476 uint32_t ImportAddressTableRVA;
472 }; 477 };
473 478
474 /// @brief The PE32 Import Lookup Table. 479 /// The PE32 Import Lookup Table.
475 /// 480 ///
476 /// There is an array of these for each imported DLL. It represents either 481 /// There is an array of these for each imported DLL. It represents either
477 /// the ordinal to import from the target DLL, or a name to lookup and import 482 /// the ordinal to import from the target DLL, or a name to lookup and import
478 /// from the target DLL. 483 /// from the target DLL.
479 /// 484 ///
480 /// This also happens to be the same format used by the Import Address Table 485 /// This also happens to be the same format used by the Import Address Table
481 /// when it is initially written out to the image. 486 /// when it is initially written out to the image.
482 struct ImportLookupTableEntry32 { 487 struct ImportLookupTableEntry32 {
483 uint32_t data; 488 uint32_t data;
484 489
485 /// @brief Is this entry specified by ordinal, or name? 490 /// Is this entry specified by ordinal, or name?
486 bool isOrdinal() const { return data & 0x80000000; } 491 bool isOrdinal() const { return data & 0x80000000; }
487 492
488 /// @brief Get the ordinal value of this entry. isOrdinal must be true. 493 /// Get the ordinal value of this entry. isOrdinal must be true.
489 uint16_t getOrdinal() const { 494 uint16_t getOrdinal() const {
490 assert(isOrdinal() && "ILT entry is not an ordinal!"); 495 assert(isOrdinal() && "ILT entry is not an ordinal!");
491 return data & 0xFFFF; 496 return data & 0xFFFF;
492 } 497 }
493 498
494 /// @brief Set the ordinal value and set isOrdinal to true. 499 /// Set the ordinal value and set isOrdinal to true.
495 void setOrdinal(uint16_t o) { 500 void setOrdinal(uint16_t o) {
496 data = o; 501 data = o;
497 data |= 0x80000000; 502 data |= 0x80000000;
498 } 503 }
499 504
500 /// @brief Get the Hint/Name entry RVA. isOrdinal must be false. 505 /// Get the Hint/Name entry RVA. isOrdinal must be false.
501 uint32_t getHintNameRVA() const { 506 uint32_t getHintNameRVA() const {
502 assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!"); 507 assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
503 return data; 508 return data;
504 } 509 }
505 510
506 /// @brief Set the Hint/Name entry RVA and set isOrdinal to false. 511 /// Set the Hint/Name entry RVA and set isOrdinal to false.
507 void setHintNameRVA(uint32_t rva) { data = rva; } 512 void setHintNameRVA(uint32_t rva) { data = rva; }
508 }; 513 };
509 514
510 /// @brief The DOS compatible header at the front of all PEs. 515 /// The DOS compatible header at the front of all PEs.
511 struct DOSHeader { 516 struct DOSHeader {
512 uint16_t Magic; 517 uint16_t Magic;
513 uint16_t UsedBytesInTheLastPage; 518 uint16_t UsedBytesInTheLastPage;
514 uint16_t FileSizeInPages; 519 uint16_t FileSizeInPages;
515 uint16_t NumberOfRelocationItems; 520 uint16_t NumberOfRelocationItems;