Add support for NetBSD as a host OS
With these changes, I am able to run Manticore on Linux (static) binaries from a NetBSD host. Tested with NetBSD/amd64 (7.1_STABLE XEN3_DOM0).
This commit is contained in:
parent
44ef97ec6c
commit
42ef3431ea
@ -43,5 +43,38 @@ if osname == "darwin" or osname.startswith("linux"):
|
||||
mmap = _mmap
|
||||
munmap = _munmap
|
||||
|
||||
elif osname.startswith("netbsd"):
|
||||
|
||||
libc = ctypes.cdll.LoadLibrary("libc.so.12")
|
||||
|
||||
# void* mmap(void* addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
mmap_function = libc.mmap
|
||||
mmap_function.restype = ctypes.c_void_p
|
||||
mmap_function.argtype = [ctypes.c_void_p, ctypes.c_size_t,
|
||||
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_size_t]
|
||||
# int munmap(void* addr, size_t len)
|
||||
munmap_function = libc.munmap
|
||||
munmap_function.restype = ctypes.c_int
|
||||
munmap_function.argtype = [ctypes.c_void_p, ctypes.c_size_t]
|
||||
|
||||
def _munmap(address, size):
|
||||
result = munmap_function(address, size)
|
||||
assert result == 0
|
||||
|
||||
def _mmap(fd, offset, size):
|
||||
prot = MMAP.PROT_READ | MMAP.PROT_WRITE
|
||||
flags = MMAP.MAP_PRIVATE
|
||||
|
||||
if size & 0xfff != 0:
|
||||
size = (size & ~0xfff) + 0x1000
|
||||
|
||||
assert size > 0
|
||||
|
||||
result = mmap_function(0, size, prot, flags, fd, offset)
|
||||
return ctypes.cast(result, ctypes.POINTER(ctypes.c_char))
|
||||
|
||||
mmap = _mmap
|
||||
munmap = _munmap
|
||||
|
||||
else:
|
||||
raise ValueError("Unsupported host OS: " + osname)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user