projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ReleaseNotes: -femultated-tls; by Chih-hung Hsieh
[oota-llvm.git]
/
bindings
/
python
/
llvm
/
object.py
diff --git
a/bindings/python/llvm/object.py
b/bindings/python/llvm/object.py
index 473aa3a1089ef8c6e521f93724a6c253cfd22c8d..b427113e9cea945ac4b550ec585a93d55e779edb 100644
(file)
--- a/
bindings/python/llvm/object.py
+++ b/
bindings/python/llvm/object.py
@@
-78,7
+78,10
@@
Here are some examples on how to perform iteration:
"""
from ctypes import c_char_p
"""
from ctypes import c_char_p
+from ctypes import c_char
+from ctypes import POINTER
from ctypes import c_uint64
from ctypes import c_uint64
+from ctypes import string_at
from .common import CachedProperty
from .common import LLVMObject
from .common import CachedProperty
from .common import LLVMObject
@@
-211,7
+214,12
@@
class Section(LLVMObject):
if self.expired:
raise Exception('Section instance has expired.')
if self.expired:
raise Exception('Section instance has expired.')
- return lib.LLVMGetSectionContents(self)
+ siz = self.size
+
+ r = lib.LLVMGetSectionContents(self)
+ if r:
+ return string_at(r, siz)
+ return None
@CachedProperty
def address(self):
@CachedProperty
def address(self):
@@
-310,14
+318,6
@@
class Symbol(LLVMObject):
return lib.LLVMGetSymbolAddress(self)
return lib.LLVMGetSymbolAddress(self)
- @CachedProperty
- def file_offset(self):
- """The offset of this symbol in the file, in long bytes."""
- if self.expired:
- raise Exception('Symbol instance has expired.')
-
- return lib.LLVMGetSymbolFileOffset(self)
-
@CachedProperty
def size(self):
"""The size of the symbol, in long bytes."""
@CachedProperty
def size(self):
"""The size of the symbol, in long bytes."""
@@
-345,7
+345,6
@@
class Symbol(LLVMObject):
"""Cache all cacheable properties."""
getattr(self, 'name')
getattr(self, 'address')
"""Cache all cacheable properties."""
getattr(self, 'name')
getattr(self, 'address')
- getattr(self, 'file_offset')
getattr(self, 'size')
def expire(self):
getattr(self, 'size')
def expire(self):
@@
-372,14
+371,6
@@
class Relocation(LLVMObject):
self.expired = False
self.expired = False
- @CachedProperty
- def address(self):
- """The address of this relocation, in long bytes."""
- if self.expired:
- raise Exception('Relocation instance has expired.')
-
- return lib.LLVMGetRelocationAddress(self)
-
@CachedProperty
def offset(self):
"""The offset of this relocation, in long bytes."""
@CachedProperty
def offset(self):
"""The offset of this relocation, in long bytes."""
@@
-471,7
+462,8
@@
def register_library(library):
library.LLVMGetSectionSize.restype = c_uint64
library.LLVMGetSectionContents.argtypes = [c_object_p]
library.LLVMGetSectionSize.restype = c_uint64
library.LLVMGetSectionContents.argtypes = [c_object_p]
- library.LLVMGetSectionContents.restype = c_char_p
+ # Can't use c_char_p here as it isn't a NUL-terminated string.
+ library.LLVMGetSectionContents.restype = POINTER(c_char)
library.LLVMGetSectionAddress.argtypes = [c_object_p]
library.LLVMGetSectionAddress.restype = c_uint64
library.LLVMGetSectionAddress.argtypes = [c_object_p]
library.LLVMGetSectionAddress.restype = c_uint64
@@
-495,15
+487,9
@@
def register_library(library):
library.LLVMGetSymbolAddress.argtypes = [Symbol]
library.LLVMGetSymbolAddress.restype = c_uint64
library.LLVMGetSymbolAddress.argtypes = [Symbol]
library.LLVMGetSymbolAddress.restype = c_uint64
- library.LLVMGetSymbolFileOffset.argtypes = [Symbol]
- library.LLVMGetSymbolFileOffset.restype = c_uint64
-
library.LLVMGetSymbolSize.argtypes = [Symbol]
library.LLVMGetSymbolSize.restype = c_uint64
library.LLVMGetSymbolSize.argtypes = [Symbol]
library.LLVMGetSymbolSize.restype = c_uint64
- library.LLVMGetRelocationAddress.argtypes = [c_object_p]
- library.LLVMGetRelocationAddress.restype = c_uint64
-
library.LLVMGetRelocationOffset.argtypes = [c_object_p]
library.LLVMGetRelocationOffset.restype = c_uint64
library.LLVMGetRelocationOffset.argtypes = [c_object_p]
library.LLVMGetRelocationOffset.restype = c_uint64