From 443d6288386f5521efa7d49bc8ea5be04f5fd696 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Feb 2012 18:11:39 -0500 Subject: libmach, acid, db: 64-bit support --- src/libmach/map.c | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'src/libmach/map.c') diff --git a/src/libmach/map.c b/src/libmach/map.c index b20bd873..392efbed 100644 --- a/src/libmach/map.c +++ b/src/libmach/map.c @@ -6,10 +6,10 @@ #include #include -static int fdrw(Map*, Seg*, ulong, void*, uint, int); -static int zerorw(Map*, Seg*, ulong, void*, uint, int); -static int mrw(Map*, ulong, void*, uint, int); -static int datarw(Map*, Seg*, ulong, void*, uint, int); +static int fdrw(Map*, Seg*, u64int, void*, uint, int); +static int zerorw(Map*, Seg*, u64int, void*, uint, int); +static int mrw(Map*, u64int, void*, uint, int); +static int datarw(Map*, Seg*, u64int, void*, uint, int); Map* allocmap(void) @@ -71,7 +71,7 @@ findseg(Map *map, char *name, char *file) } int -addrtoseg(Map *map, ulong addr, Seg *sp) +addrtoseg(Map *map, u64int addr, Seg *sp) { int i; Seg *s; @@ -93,7 +93,7 @@ addrtoseg(Map *map, ulong addr, Seg *sp) } int -addrtosegafter(Map *map, ulong addr, Seg *sp) +addrtosegafter(Map *map, u64int addr, Seg *sp) { int i; Seg *s, *best; @@ -142,13 +142,13 @@ removeseg(Map *map, int i) } int -get1(Map *map, ulong addr, uchar *a, uint n) +get1(Map *map, u64int addr, uchar *a, uint n) { return mrw(map, addr, a, n, 1); } int -get2(Map *map, ulong addr, u16int *u) +get2(Map *map, u64int addr, u16int *u) { u16int v; @@ -159,7 +159,7 @@ get2(Map *map, ulong addr, u16int *u) } int -get4(Map *map, ulong addr, u32int *u) +get4(Map *map, u64int addr, u32int *u) { u32int v; @@ -170,7 +170,7 @@ get4(Map *map, ulong addr, u32int *u) } int -get8(Map *map, ulong addr, u64int *u) +get8(Map *map, u64int addr, u64int *u) { u64int v; @@ -181,34 +181,47 @@ get8(Map *map, ulong addr, u64int *u) } int -put1(Map *map, ulong addr, uchar *a, uint n) +geta(Map *map, u64int addr, u64int *u) +{ + u32int v; + + if(machcpu == &machamd64) + return get8(map, addr, u); + if(get4(map, addr, &v) < 0) + return -1; + *u = v; + return 4; +} + +int +put1(Map *map, u64int addr, uchar *a, uint n) { return mrw(map, addr, a, n, 0); } int -put2(Map *map, ulong addr, u16int u) +put2(Map *map, u64int addr, u16int u) { u = mach->swap2(u); return mrw(map, addr, &u, 2, 0); } int -put4(Map *map, ulong addr, u32int u) +put4(Map *map, u64int addr, u32int u) { u = mach->swap4(u); return mrw(map, addr, &u, 4, 0); } int -put8(Map *map, ulong addr, u64int u) +put8(Map *map, u64int addr, u64int u) { u = mach->swap8(u); return mrw(map, addr, &u, 8, 0); } static Seg* -reloc(Map *map, ulong addr, uint n, ulong *off, uint *nn) +reloc(Map *map, u64int addr, uint n, u64int *off, uint *nn) { int i; ulong o; @@ -236,12 +249,12 @@ reloc(Map *map, ulong addr, uint n, ulong *off, uint *nn) } static int -mrw(Map *map, ulong addr, void *a, uint n, int r) +mrw(Map *map, u64int addr, void *a, uint n, int r) { uint nn; uint tot; Seg *s; - ulong off; + u64int off; for(tot=0; tot