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.

360 lines
13 KiB

  1. //===-- llvm/MC/MCObjectFileInfo.h - Object File 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 describes common object file formats.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCBJECTFILEINFO_H
  14. #define LLVM_MC_MCBJECTFILEINFO_H
  15. #include "llvm/Support/CodeGen.h"
  16. namespace llvm {
  17. class MCContext;
  18. class MCSection;
  19. class StringRef;
  20. class Triple;
  21. class MCObjectFileInfo {
  22. protected:
  23. /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
  24. /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
  25. /// support alignment on comm.
  26. bool CommDirectiveSupportsAlignment;
  27. /// SupportsWeakEmptyEHFrame - True if target object file supports a
  28. /// weak_definition of constant 0 for an omitted EH frame.
  29. bool SupportsWeakOmittedEHFrame;
  30. /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
  31. /// "EH_frame" symbol for EH information should be an assembler temporary (aka
  32. /// private linkage, aka an L or .L label) or false if it should be a normal
  33. /// non-.globl label. This defaults to true.
  34. bool IsFunctionEHFrameSymbolPrivate;
  35. /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
  36. /// encoding values for EH.
  37. unsigned PersonalityEncoding;
  38. unsigned LSDAEncoding;
  39. unsigned FDEEncoding;
  40. unsigned FDECFIEncoding;
  41. unsigned TTypeEncoding;
  42. /// Section flags for eh_frame
  43. unsigned EHSectionType;
  44. unsigned EHSectionFlags;
  45. /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
  46. /// should emit only an EH frame.
  47. unsigned CompactUnwindDwarfEHFrameOnly;
  48. /// TextSection - Section directive for standard text.
  49. ///
  50. const MCSection *TextSection;
  51. /// DataSection - Section directive for standard data.
  52. ///
  53. const MCSection *DataSection;
  54. /// BSSSection - Section that is default initialized to zero.
  55. const MCSection *BSSSection;
  56. /// ReadOnlySection - Section that is readonly and can contain arbitrary
  57. /// initialized data. Targets are not required to have a readonly section.
  58. /// If they don't, various bits of code will fall back to using the data
  59. /// section for constants.
  60. const MCSection *ReadOnlySection;
  61. /// StaticCtorSection - This section contains the static constructor pointer
  62. /// list.
  63. const MCSection *StaticCtorSection;
  64. /// StaticDtorSection - This section contains the static destructor pointer
  65. /// list.
  66. const MCSection *StaticDtorSection;
  67. /// LSDASection - If exception handling is supported by the target, this is
  68. /// the section the Language Specific Data Area information is emitted to.
  69. const MCSection *LSDASection;
  70. /// CompactUnwindSection - If exception handling is supported by the target
  71. /// and the target can support a compact representation of the CIE and FDE,
  72. /// this is the section to emit them into.
  73. const MCSection *CompactUnwindSection;
  74. // Dwarf sections for debug info. If a target supports debug info, these must
  75. // be set.
  76. const MCSection *DwarfAbbrevSection;
  77. const MCSection *DwarfInfoSection;
  78. const MCSection *DwarfLineSection;
  79. const MCSection *DwarfFrameSection;
  80. const MCSection *DwarfPubTypesSection;
  81. const MCSection *DwarfDebugInlineSection;
  82. const MCSection *DwarfStrSection;
  83. const MCSection *DwarfLocSection;
  84. const MCSection *DwarfARangesSection;
  85. const MCSection *DwarfRangesSection;
  86. const MCSection *DwarfMacroInfoSection;
  87. // The pubnames section is no longer generated by default. The generation
  88. // can be enabled by a compiler flag.
  89. const MCSection *DwarfPubNamesSection;
  90. // DWARF5 Experimental Debug Info Sections
  91. /// DwarfAccelNamesSection, DwarfAccelObjCSection,
  92. /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
  93. /// If we use the DWARF accelerated hash tables then we want to emit these
  94. /// sections.
  95. const MCSection *DwarfAccelNamesSection;
  96. const MCSection *DwarfAccelObjCSection;
  97. const MCSection *DwarfAccelNamespaceSection;
  98. const MCSection *DwarfAccelTypesSection;
  99. /// These are used for the Fission separate debug information files.
  100. const MCSection *DwarfInfoDWOSection;
  101. const MCSection *DwarfAbbrevDWOSection;
  102. const MCSection *DwarfStrDWOSection;
  103. const MCSection *DwarfLineDWOSection;
  104. const MCSection *DwarfLocDWOSection;
  105. const MCSection *DwarfStrOffDWOSection;
  106. const MCSection *DwarfAddrSection;
  107. // Extra TLS Variable Data section. If the target needs to put additional
  108. // information for a TLS variable, it'll go here.
  109. const MCSection *TLSExtraDataSection;
  110. /// TLSDataSection - Section directive for Thread Local data.
  111. /// ELF, MachO and COFF.
  112. const MCSection *TLSDataSection; // Defaults to ".tdata".
  113. /// TLSBSSSection - Section directive for Thread Local uninitialized data.
  114. /// Null if this target doesn't support a BSS section.
  115. /// ELF and MachO only.
  116. const MCSection *TLSBSSSection; // Defaults to ".tbss".
  117. /// EHFrameSection - EH frame section. It is initialized on demand so it
  118. /// can be overwritten (with uniquing).
  119. const MCSection *EHFrameSection;
  120. /// ELF specific sections.
  121. ///
  122. const MCSection *DataRelSection;
  123. const MCSection *DataRelLocalSection;
  124. const MCSection *DataRelROSection;
  125. const MCSection *DataRelROLocalSection;
  126. const MCSection *MergeableConst4Section;
  127. const MCSection *MergeableConst8Section;
  128. const MCSection *MergeableConst16Section;
  129. /// MachO specific sections.
  130. ///
  131. /// TLSTLVSection - Section for thread local structure information.
  132. /// Contains the source code name of the variable, visibility and a pointer
  133. /// to the initial value (.tdata or .tbss).
  134. const MCSection *TLSTLVSection; // Defaults to ".tlv".
  135. /// TLSThreadInitSection - Section for thread local data initialization
  136. /// functions.
  137. const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
  138. const MCSection *CStringSection;
  139. const MCSection *UStringSection;
  140. const MCSection *TextCoalSection;
  141. const MCSection *ConstTextCoalSection;
  142. const MCSection *ConstDataSection;
  143. const MCSection *DataCoalSection;
  144. const MCSection *DataCommonSection;
  145. const MCSection *DataBSSSection;
  146. const MCSection *FourByteConstantSection;
  147. const MCSection *EightByteConstantSection;
  148. const MCSection *SixteenByteConstantSection;
  149. const MCSection *LazySymbolPointerSection;
  150. const MCSection *NonLazySymbolPointerSection;
  151. /// COFF specific sections.
  152. ///
  153. const MCSection *DrectveSection;
  154. const MCSection *PDataSection;
  155. const MCSection *XDataSection;
  156. public:
  157. void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
  158. MCContext &ctx);
  159. bool isFunctionEHFrameSymbolPrivate() const {
  160. return IsFunctionEHFrameSymbolPrivate;
  161. }
  162. bool getSupportsWeakOmittedEHFrame() const {
  163. return SupportsWeakOmittedEHFrame;
  164. }
  165. bool getCommDirectiveSupportsAlignment() const {
  166. return CommDirectiveSupportsAlignment;
  167. }
  168. unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
  169. unsigned getLSDAEncoding() const { return LSDAEncoding; }
  170. unsigned getFDEEncoding(bool CFI) const {
  171. return CFI ? FDECFIEncoding : FDEEncoding;
  172. }
  173. unsigned getTTypeEncoding() const { return TTypeEncoding; }
  174. unsigned getCompactUnwindDwarfEHFrameOnly() const {
  175. return CompactUnwindDwarfEHFrameOnly;
  176. }
  177. const MCSection *getTextSection() const { return TextSection; }
  178. const MCSection *getDataSection() const { return DataSection; }
  179. const MCSection *getBSSSection() const { return BSSSection; }
  180. const MCSection *getLSDASection() const { return LSDASection; }
  181. const MCSection *getCompactUnwindSection() const{
  182. return CompactUnwindSection;
  183. }
  184. const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
  185. const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
  186. const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
  187. const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
  188. const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
  189. const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
  190. const MCSection *getDwarfDebugInlineSection() const {
  191. return DwarfDebugInlineSection;
  192. }
  193. const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
  194. const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
  195. const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
  196. const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
  197. const MCSection *getDwarfMacroInfoSection() const {
  198. return DwarfMacroInfoSection;
  199. }
  200. // DWARF5 Experimental Debug Info Sections
  201. const MCSection *getDwarfAccelNamesSection() const {
  202. return DwarfAccelNamesSection;
  203. }
  204. const MCSection *getDwarfAccelObjCSection() const {
  205. return DwarfAccelObjCSection;
  206. }
  207. const MCSection *getDwarfAccelNamespaceSection() const {
  208. return DwarfAccelNamespaceSection;
  209. }
  210. const MCSection *getDwarfAccelTypesSection() const {
  211. return DwarfAccelTypesSection;
  212. }
  213. const MCSection *getDwarfInfoDWOSection() const {
  214. return DwarfInfoDWOSection;
  215. }
  216. const MCSection *getDwarfAbbrevDWOSection() const {
  217. return DwarfAbbrevDWOSection;
  218. }
  219. const MCSection *getDwarfStrDWOSection() const {
  220. return DwarfStrDWOSection;
  221. }
  222. const MCSection *getDwarfLineDWOSection() const {
  223. return DwarfLineDWOSection;
  224. }
  225. const MCSection *getDwarfLocDWOSection() const {
  226. return DwarfLocDWOSection;
  227. }
  228. const MCSection *getDwarfStrOffDWOSection() const {
  229. return DwarfStrOffDWOSection;
  230. }
  231. const MCSection *getDwarfAddrSection() const {
  232. return DwarfAddrSection;
  233. }
  234. const MCSection *getTLSExtraDataSection() const {
  235. return TLSExtraDataSection;
  236. }
  237. const MCSection *getTLSDataSection() const { return TLSDataSection; }
  238. const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
  239. /// ELF specific sections.
  240. ///
  241. const MCSection *getDataRelSection() const { return DataRelSection; }
  242. const MCSection *getDataRelLocalSection() const {
  243. return DataRelLocalSection;
  244. }
  245. const MCSection *getDataRelROSection() const { return DataRelROSection; }
  246. const MCSection *getDataRelROLocalSection() const {
  247. return DataRelROLocalSection;
  248. }
  249. const MCSection *getMergeableConst4Section() const {
  250. return MergeableConst4Section;
  251. }
  252. const MCSection *getMergeableConst8Section() const {
  253. return MergeableConst8Section;
  254. }
  255. const MCSection *getMergeableConst16Section() const {
  256. return MergeableConst16Section;
  257. }
  258. /// MachO specific sections.
  259. ///
  260. const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
  261. const MCSection *getTLSThreadInitSection() const {
  262. return TLSThreadInitSection;
  263. }
  264. const MCSection *getCStringSection() const { return CStringSection; }
  265. const MCSection *getUStringSection() const { return UStringSection; }
  266. const MCSection *getTextCoalSection() const { return TextCoalSection; }
  267. const MCSection *getConstTextCoalSection() const {
  268. return ConstTextCoalSection;
  269. }
  270. const MCSection *getConstDataSection() const { return ConstDataSection; }
  271. const MCSection *getDataCoalSection() const { return DataCoalSection; }
  272. const MCSection *getDataCommonSection() const { return DataCommonSection; }
  273. const MCSection *getDataBSSSection() const { return DataBSSSection; }
  274. const MCSection *getFourByteConstantSection() const {
  275. return FourByteConstantSection;
  276. }
  277. const MCSection *getEightByteConstantSection() const {
  278. return EightByteConstantSection;
  279. }
  280. const MCSection *getSixteenByteConstantSection() const {
  281. return SixteenByteConstantSection;
  282. }
  283. const MCSection *getLazySymbolPointerSection() const {
  284. return LazySymbolPointerSection;
  285. }
  286. const MCSection *getNonLazySymbolPointerSection() const {
  287. return NonLazySymbolPointerSection;
  288. }
  289. /// COFF specific sections.
  290. ///
  291. const MCSection *getDrectveSection() const { return DrectveSection; }
  292. const MCSection *getPDataSection() const { return PDataSection; }
  293. const MCSection *getXDataSection() const { return XDataSection; }
  294. const MCSection *getEHFrameSection() {
  295. if (!EHFrameSection)
  296. InitEHFrameSection();
  297. return EHFrameSection;
  298. }
  299. private:
  300. enum Environment { IsMachO, IsELF, IsCOFF };
  301. Environment Env;
  302. Reloc::Model RelocM;
  303. CodeModel::Model CMModel;
  304. MCContext *Ctx;
  305. void InitMachOMCObjectFileInfo(Triple T);
  306. void InitELFMCObjectFileInfo(Triple T);
  307. void InitCOFFMCObjectFileInfo(Triple T);
  308. /// InitEHFrameSection - Initialize EHFrameSection on demand.
  309. ///
  310. void InitEHFrameSection();
  311. };
  312. } // end namespace llvm
  313. #endif