Object.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. extern "C" {
  24. #endif
  25. /**
  26. * @defgroup LLVMCObject Object file reading and writing
  27. * @ingroup LLVMC
  28. *
  29. * @{
  30. */
  31. // Opaque type wrappers
  32. typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
  33. typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
  34. typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
  35. typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
  36. // ObjectFile creation
  37. LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
  38. void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
  39. // ObjectFile Section iterators
  40. LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
  41. void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
  42. LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
  43. LLVMSectionIteratorRef SI);
  44. void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
  45. void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
  46. LLVMSymbolIteratorRef Sym);
  47. // ObjectFile Symbol iterators
  48. LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
  49. void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
  50. LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
  51. LLVMSymbolIteratorRef SI);
  52. void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
  53. // SectionRef accessors
  54. const char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
  55. uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
  56. const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
  57. uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
  58. LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
  59. LLVMSymbolIteratorRef Sym);
  60. // Section Relocation iterators
  61. LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
  62. void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
  63. LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
  64. LLVMRelocationIteratorRef RI);
  65. void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
  66. // SymbolRef accessors
  67. const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
  68. uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
  69. uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
  70. // RelocationRef accessors
  71. uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
  72. LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
  73. uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
  74. // NOTE: Caller takes ownership of returned string of the two
  75. // following functions.
  76. const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
  77. const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
  78. /**
  79. * @}
  80. */
  81. #ifdef __cplusplus
  82. }
  83. #endif /* defined(__cplusplus) */
  84. #endif