X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=bindings%2Fpython%2Fllvm%2Fobject.py;h=b427113e9cea945ac4b550ec585a93d55e779edb;hp=473aa3a1089ef8c6e521f93724a6c253cfd22c8d;hb=7609bf251117db67abfe0d5b6622860afc769278;hpb=61e22cd85cd4c84fff391da67018c92bf21a8e19 diff --git a/bindings/python/llvm/object.py b/bindings/python/llvm/object.py index 473aa3a1089..b427113e9ce 100644 --- 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 +from ctypes import POINTER from ctypes import c_uint64 +from ctypes import string_at from .common import CachedProperty from .common import LLVMObject @@ -211,7 +214,12 @@ class Section(LLVMObject): 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): @@ -310,14 +318,6 @@ class Symbol(LLVMObject): 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.""" @@ -345,7 +345,6 @@ class Symbol(LLVMObject): """Cache all cacheable properties.""" getattr(self, 'name') getattr(self, 'address') - getattr(self, 'file_offset') getattr(self, 'size') def expire(self): @@ -372,14 +371,6 @@ class Relocation(LLVMObject): 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.""" @@ -471,7 +462,8 @@ def register_library(library): 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 @@ -495,15 +487,9 @@ def register_library(library): 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.LLVMGetRelocationAddress.argtypes = [c_object_p] - library.LLVMGetRelocationAddress.restype = c_uint64 - library.LLVMGetRelocationOffset.argtypes = [c_object_p] library.LLVMGetRelocationOffset.restype = c_uint64