Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
numba
GitHub Repository: numba/llvmlite
Path: blob/main/ffi/object_file.cpp
1154 views
1
#include "core.h"
2
3
#include "llvm-c/ExecutionEngine.h"
4
#include "llvm-c/Object.h"
5
6
#include "llvm/Object/ObjectFile.h"
7
8
#include <stdio.h>
9
10
// From lib/Object/Object.cpp
11
namespace llvm {
12
inline object::section_iterator *unwrap(LLVMSectionIteratorRef SI) {
13
return reinterpret_cast<object::section_iterator *>(SI);
14
}
15
16
inline LLVMSectionIteratorRef wrap(const object::section_iterator *SI) {
17
return reinterpret_cast<LLVMSectionIteratorRef>(
18
const_cast<object::section_iterator *>(SI));
19
}
20
} // namespace llvm
21
22
extern "C" {
23
24
API_EXPORT(LLVMObjectFileRef)
25
LLVMPY_CreateObjectFile(const char *buf, const size_t n) {
26
return LLVMCreateObjectFile(
27
LLVMCreateMemoryBufferWithMemoryRangeCopy(buf, n, ""));
28
}
29
30
API_EXPORT(void)
31
LLVMPY_DisposeObjectFile(LLVMObjectFileRef O) {
32
return LLVMDisposeObjectFile(O);
33
}
34
35
API_EXPORT(LLVMSectionIteratorRef)
36
LLVMPY_GetSections(LLVMObjectFileRef O) { return LLVMGetSections(O); }
37
38
API_EXPORT(void)
39
LLVMPY_DisposeSectionIterator(LLVMSectionIteratorRef SI) {
40
LLVMDisposeSectionIterator(SI);
41
}
42
43
API_EXPORT(void)
44
LLVMPY_MoveToNextSection(LLVMSectionIteratorRef SI) {
45
LLVMMoveToNextSection(SI);
46
}
47
48
API_EXPORT(bool)
49
LLVMPY_IsSectionIteratorAtEnd(LLVMObjectFileRef O, LLVMSectionIteratorRef SI) {
50
return LLVMIsSectionIteratorAtEnd(O, SI);
51
}
52
53
API_EXPORT(const char *)
54
LLVMPY_GetSectionName(LLVMSectionIteratorRef SI) {
55
return LLVMGetSectionName(SI);
56
}
57
58
API_EXPORT(uint64_t)
59
LLVMPY_GetSectionAddress(LLVMSectionIteratorRef SI) {
60
return LLVMGetSectionAddress(SI);
61
}
62
63
API_EXPORT(const char *)
64
LLVMPY_GetSectionContents(LLVMSectionIteratorRef SI) {
65
return LLVMGetSectionContents(SI);
66
}
67
68
API_EXPORT(uint64_t)
69
LLVMPY_GetSectionSize(LLVMSectionIteratorRef SI) {
70
return LLVMGetSectionSize(SI);
71
}
72
73
API_EXPORT(bool)
74
LLVMPY_IsSectionText(LLVMSectionIteratorRef SI) {
75
return (*llvm::unwrap(SI))->isText();
76
}
77
78
} // end extern C
79
80