use (llvm 3.4) built in StringRefMemoryObject instead of BytesMemoryObject
This commit is contained in:
parent
aa0ee9b6a6
commit
bc02b3d90a
5 changed files with 23 additions and 43 deletions
|
|
@ -93,7 +93,7 @@ class Disassembler:
|
||||||
#decode some bytes into instructions. yields each instruction
|
#decode some bytes into instructions. yields each instruction
|
||||||
#as it is decoded.
|
#as it is decoded.
|
||||||
def decode(self, bs):
|
def decode(self, bs):
|
||||||
code = api.llvm.BytesMemoryObject.new(bs)
|
code = api.llvm.StringRefMemoryObject.new(bs, 0)
|
||||||
idx = code.getBase()
|
idx = code.getBase()
|
||||||
|
|
||||||
while(idx < code.getExtent()):
|
while(idx < code.getExtent()):
|
||||||
|
|
|
||||||
|
|
@ -35,30 +35,6 @@
|
||||||
|
|
||||||
#include "auto_pyobject.h"
|
#include "auto_pyobject.h"
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
class BytesMemoryObject : public MemoryObject {
|
|
||||||
private:
|
|
||||||
StringRef m_bytes;
|
|
||||||
|
|
||||||
public:
|
|
||||||
BytesMemoryObject(StringRef bytes) {
|
|
||||||
m_bytes = bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t getBase() const { return 0; }
|
|
||||||
uint64_t getExtent() const { return (uint64_t) m_bytes.size(); }
|
|
||||||
|
|
||||||
int readByte(uint64_t addr, uint8_t *byte) const {
|
|
||||||
if (addr >= getExtent())
|
|
||||||
return -1;
|
|
||||||
*byte = (uint8_t) m_bytes[(size_t) addr];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace extra{
|
namespace extra{
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
from binding import *
|
|
||||||
from .namespace import llvm
|
|
||||||
from .ADT.StringRef import StringRef
|
|
||||||
|
|
||||||
MemoryObject = llvm.Class()
|
|
||||||
BytesMemoryObject = llvm.Class(MemoryObject)
|
|
||||||
|
|
||||||
@MemoryObject
|
|
||||||
class MemoryObject:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@BytesMemoryObject
|
|
||||||
class BytesMemoryObject:
|
|
||||||
new = Constructor(cast(bytes, StringRef))
|
|
||||||
|
|
||||||
getBase = Method(cast(Uint64, int))
|
|
||||||
getExtent = Method(cast(Uint64, int))
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from ..namespace import llvm
|
from ..namespace import llvm
|
||||||
from ..BytesMemoryObject import MemoryObject
|
from ..Support.StringRefMemoryObject import MemoryObject
|
||||||
from ..Support.raw_ostream import raw_ostream
|
from ..Support.raw_ostream import raw_ostream
|
||||||
|
|
||||||
MCSubtargetInfo = llvm.Class()
|
MCSubtargetInfo = llvm.Class()
|
||||||
|
|
|
||||||
21
llvmpy/src/Support/StringRefMemoryObject.py
Normal file
21
llvmpy/src/Support/StringRefMemoryObject.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
from binding import *
|
||||||
|
from ..namespace import llvm
|
||||||
|
from ..ADT.StringRef import StringRef
|
||||||
|
|
||||||
|
MemoryObject = llvm.Class()
|
||||||
|
if LLVM_VERSION >= (3, 4):
|
||||||
|
StringRefMemoryObject = llvm.Class(MemoryObject)
|
||||||
|
|
||||||
|
@MemoryObject
|
||||||
|
class MemoryObject:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if LLVM_VERSION >= (3, 4):
|
||||||
|
@StringRefMemoryObject
|
||||||
|
class StringRefMemoryObject:
|
||||||
|
_include_ = "llvm/Support/StringRefMemoryObject.h"
|
||||||
|
|
||||||
|
new = Constructor(cast(bytes, StringRef), cast(int, Uint64))
|
||||||
|
|
||||||
|
getBase = Method(cast(Uint64, int))
|
||||||
|
getExtent = Method(cast(Uint64, int))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue