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.

149 lines
5.6 KiB

  1. /*===-- llvm-c/Object.h - Object Lib C Iface --------------------*- 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 header declares the C interface to libLLVMObject.a, which */
  11. /* implements object file reading and writing. */
  12. /* */
  13. /* Many exotic languages can interoperate with C code but have a harder time */
  14. /* with C++ due to name mangling. So in addition to C, this interface enables */
  15. /* tools written in such languages. */
  16. /* */
  17. /*===----------------------------------------------------------------------===*/
  18. #ifndef LLVM_C_OBJECT_H
  19. #define LLVM_C_OBJECT_H
  20. #include "llvm-c/Core.h"
  21. #include "llvm/Config/llvm-config.h"
  22. #ifdef __cplusplus
  23. #include "llvm/Object/ObjectFile.h"
  24. extern "C" {
  25. #endif
  26. /**
  27. * @defgroup LLVMCObject Object file reading and writing
  28. * @ingroup LLVMC
  29. *
  30. * @{
  31. */
  32. // Opaque type wrappers
  33. typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
  34. typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
  35. typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
  36. typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
  37. // ObjectFile creation
  38. LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
  39. void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
  40. // ObjectFile Section iterators
  41. LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
  42. void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
  43. LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
  44. LLVMSectionIteratorRef SI);
  45. void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
  46. void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
  47. LLVMSymbolIteratorRef Sym);
  48. // ObjectFile Symbol iterators
  49. LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
  50. void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
  51. LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
  52. LLVMSymbolIteratorRef SI);
  53. void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
  54. // SectionRef accessors
  55. const char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
  56. uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
  57. const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
  58. uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
  59. LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
  60. LLVMSymbolIteratorRef Sym);
  61. // Section Relocation iterators
  62. LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
  63. void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
  64. LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
  65. LLVMRelocationIteratorRef RI);
  66. void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
  67. // SymbolRef accessors
  68. const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
  69. uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
  70. uint64_t LLVMGetSymbolFileOffset(LLVMSymbolIteratorRef SI);
  71. uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
  72. // RelocationRef accessors
  73. uint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI);
  74. uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
  75. LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
  76. uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
  77. // NOTE: Caller takes ownership of returned string of the two
  78. // following functions.
  79. const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
  80. const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
  81. /**
  82. * @}
  83. */
  84. #ifdef __cplusplus
  85. }
  86. namespace llvm {
  87. namespace object {
  88. inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
  89. return reinterpret_cast<ObjectFile*>(OF);
  90. }
  91. inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
  92. return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
  93. }
  94. inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
  95. return reinterpret_cast<section_iterator*>(SI);
  96. }
  97. inline LLVMSectionIteratorRef
  98. wrap(const section_iterator *SI) {
  99. return reinterpret_cast<LLVMSectionIteratorRef>
  100. (const_cast<section_iterator*>(SI));
  101. }
  102. inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) {
  103. return reinterpret_cast<symbol_iterator*>(SI);
  104. }
  105. inline LLVMSymbolIteratorRef
  106. wrap(const symbol_iterator *SI) {
  107. return reinterpret_cast<LLVMSymbolIteratorRef>
  108. (const_cast<symbol_iterator*>(SI));
  109. }
  110. inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) {
  111. return reinterpret_cast<relocation_iterator*>(SI);
  112. }
  113. inline LLVMRelocationIteratorRef
  114. wrap(const relocation_iterator *SI) {
  115. return reinterpret_cast<LLVMRelocationIteratorRef>
  116. (const_cast<relocation_iterator*>(SI));
  117. }
  118. }
  119. }
  120. #endif /* defined(__cplusplus) */
  121. #endif