Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.4 KiB

  1. //===-- llvm/Target/TargetELFWriterInfo.h - ELF Writer Info -----*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines the TargetELFWriterInfo class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
  14. #define LLVM_TARGET_TARGETELFWRITERINFO_H
  15. namespace llvm {
  16. //===--------------------------------------------------------------------===//
  17. // TargetELFWriterInfo
  18. //===--------------------------------------------------------------------===//
  19. class TargetELFWriterInfo {
  20. protected:
  21. // EMachine - This field is the target specific value to emit as the
  22. // e_machine member of the ELF header.
  23. unsigned short EMachine;
  24. bool is64Bit, isLittleEndian;
  25. public:
  26. // Machine architectures
  27. enum MachineType {
  28. EM_NONE = 0, // No machine
  29. EM_M32 = 1, // AT&T WE 32100
  30. EM_SPARC = 2, // SPARC
  31. EM_386 = 3, // Intel 386
  32. EM_68K = 4, // Motorola 68000
  33. EM_88K = 5, // Motorola 88000
  34. EM_486 = 6, // Intel 486 (deprecated)
  35. EM_860 = 7, // Intel 80860
  36. EM_MIPS = 8, // MIPS R3000
  37. EM_PPC = 20, // PowerPC
  38. EM_ARM = 40, // ARM
  39. EM_ALPHA = 41, // DEC Alpha
  40. EM_SPARCV9 = 43, // SPARC V9
  41. EM_X86_64 = 62, // AMD64
  42. EM_HEXAGON = 164 // Qualcomm Hexagon
  43. };
  44. // ELF File classes
  45. enum {
  46. ELFCLASS32 = 1, // 32-bit object file
  47. ELFCLASS64 = 2 // 64-bit object file
  48. };
  49. // ELF Endianess
  50. enum {
  51. ELFDATA2LSB = 1, // Little-endian object file
  52. ELFDATA2MSB = 2 // Big-endian object file
  53. };
  54. explicit TargetELFWriterInfo(bool is64Bit_, bool isLittleEndian_);
  55. virtual ~TargetELFWriterInfo();
  56. unsigned short getEMachine() const { return EMachine; }
  57. unsigned getEFlags() const { return 0; }
  58. unsigned getEIClass() const { return is64Bit ? ELFCLASS64 : ELFCLASS32; }
  59. unsigned getEIData() const {
  60. return isLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
  61. }
  62. /// ELF Header and ELF Section Header Info
  63. unsigned getHdrSize() const { return is64Bit ? 64 : 52; }
  64. unsigned getSHdrSize() const { return is64Bit ? 64 : 40; }
  65. /// Symbol Table Info
  66. unsigned getSymTabEntrySize() const { return is64Bit ? 24 : 16; }
  67. /// getPrefELFAlignment - Returns the preferred alignment for ELF. This
  68. /// is used to align some sections.
  69. unsigned getPrefELFAlignment() const { return is64Bit ? 8 : 4; }
  70. /// getRelocationEntrySize - Entry size used in the relocation section
  71. unsigned getRelocationEntrySize() const {
  72. return is64Bit ? (hasRelocationAddend() ? 24 : 16)
  73. : (hasRelocationAddend() ? 12 : 8);
  74. }
  75. /// getRelocationType - Returns the target specific ELF Relocation type.
  76. /// 'MachineRelTy' contains the object code independent relocation type
  77. virtual unsigned getRelocationType(unsigned MachineRelTy) const = 0;
  78. /// hasRelocationAddend - True if the target uses an addend in the
  79. /// ELF relocation entry.
  80. virtual bool hasRelocationAddend() const = 0;
  81. /// getDefaultAddendForRelTy - Gets the default addend value for a
  82. /// relocation entry based on the target ELF relocation type.
  83. virtual long int getDefaultAddendForRelTy(unsigned RelTy,
  84. long int Modifier = 0) const = 0;
  85. /// getRelTySize - Returns the size of relocatable field in bits
  86. virtual unsigned getRelocationTySize(unsigned RelTy) const = 0;
  87. /// isPCRelativeRel - True if the relocation type is pc relative
  88. virtual bool isPCRelativeRel(unsigned RelTy) const = 0;
  89. /// getJumpTableRelocationTy - Returns the machine relocation type used
  90. /// to reference a jumptable.
  91. virtual unsigned getAbsoluteLabelMachineRelTy() const = 0;
  92. /// computeRelocation - Some relocatable fields could be relocated
  93. /// directly, avoiding the relocation symbol emission, compute the
  94. /// final relocation value for this symbol.
  95. virtual long int computeRelocation(unsigned SymOffset, unsigned RelOffset,
  96. unsigned RelTy) const = 0;
  97. };
  98. } // end llvm namespace
  99. #endif // LLVM_TARGET_TARGETELFWRITERINFO_H