fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame^] | 1 | #ifndef _COREGRIND_UME_H |
| 2 | #define _COREGRIND_UME_H |
| 3 | |
| 4 | #include <elf.h> |
| 5 | #include <sys/types.h> |
| 6 | |
| 7 | #if ELFSZ == 64 |
| 8 | #define ESZ(x) Elf64_##x |
| 9 | #elif ELFSZ == 32 |
| 10 | #define ESZ(x) Elf32_##x |
| 11 | #else |
| 12 | #error ELFSZ needs to ==32 or ==64 |
| 13 | #endif |
| 14 | |
| 15 | /* Integer type the same size as a pointer */ |
| 16 | typedef ESZ(Addr) addr_t; |
| 17 | |
| 18 | struct exeinfo |
| 19 | { |
| 20 | int setbrk; /* INPUT: if true, set the brk segment base */ |
| 21 | addr_t map_base; /* INPUT: if non-zero, base address of mappings */ |
| 22 | |
| 23 | addr_t exe_base; /* INOUT: lowest (allowed) address of exe */ |
| 24 | addr_t exe_end; /* INOUT: highest (allowed) address */ |
| 25 | |
| 26 | addr_t phdr; /* address phdr was mapped at */ |
| 27 | int phnum; /* number of phdrs */ |
| 28 | addr_t interp_base; /* where interpreter (ld.so) was mapped */ |
| 29 | addr_t entry; /* entrypoint in main executable */ |
| 30 | addr_t init_eip; /* initial eip */ |
| 31 | addr_t brkbase; /* base address of brk segment */ |
| 32 | |
| 33 | /* these are the extra args added by #! scripts */ |
| 34 | char *argv0; /* the interpreter name */ |
| 35 | char *argv1; /* the args for the interpreter */ |
| 36 | |
| 37 | char **argv; /* the original argv */ |
| 38 | }; |
| 39 | |
| 40 | int do_exec(const char *exe, struct exeinfo *info); |
| 41 | |
| 42 | void foreach_map(int (*fn)(void *start, void *end, |
| 43 | const char *perm, off_t offset, |
| 44 | int maj, int min, int ino)); |
| 45 | void as_pad(void *start, void *end); |
| 46 | void as_unpad(void *start, void *end); |
| 47 | void as_closepadfile(void); |
| 48 | int as_getpadfd(void); |
| 49 | void as_setpadfd(int); |
| 50 | |
| 51 | struct elfinfo |
| 52 | { |
| 53 | ESZ(Ehdr) e; |
| 54 | ESZ(Phdr) *p; |
| 55 | int fd; |
| 56 | }; |
| 57 | |
| 58 | struct elfinfo *readelf(int fd, const char *filename); |
| 59 | ESZ(Addr) mapelf(struct elfinfo *e, ESZ(Addr) base, int setbrk); |
| 60 | |
| 61 | struct ume_auxv |
| 62 | { |
| 63 | int a_type; |
| 64 | union { |
| 65 | void *a_ptr; |
| 66 | int a_val; |
| 67 | void (*a_fcn)(void); |
| 68 | }; |
| 69 | }; |
| 70 | |
| 71 | struct ume_auxv *find_auxv(int *orig_esp); |
| 72 | |
| 73 | /* Our private auxv entries */ |
| 74 | #define AT_UME_PADFD 0xff01 /* padding file fd */ |
| 75 | #define AT_UME_EXECFD 0xff02 /* stage1 executable fd */ |
| 76 | |
| 77 | #endif /* _COREGRIND_UME_H */ |