/* stage2 needs this so it can clean up the padding we leave in
place when we start it */
auxv[0].a_type = AT_UME_PADFD;
- auxv[0].a_val = as_getpadfd();
+ auxv[0].u.a_val = as_getpadfd();
/* This will be needed by valgrind itself so that it can
subsequently execve() children. This needs to be done here
because /proc/self/exe will go away once we unmap stage1. */
auxv[1].a_type = AT_UME_EXECFD;
- auxv[1].a_val = open("/proc/self/exe", O_RDONLY);
+ auxv[1].u.a_val = open("/proc/self/exe", O_RDONLY);
/* make sure the rest are sane */
for(i = new_entries; i < delta/sizeof(*auxv); i++) {
auxv[i].a_type = AT_IGNORE;
- auxv[i].a_val = 0;
+ auxv[i].u.a_val = 0;
}
/* OK, go through and patch up the auxv entries to match the new
seen = 0;
for(; auxv->a_type != AT_NULL; auxv++) {
if (0)
- printf("doing auxv %p %4x: %d %p\n", auxv, auxv->a_type, auxv->a_val, auxv->a_ptr);
+ printf("doing auxv %p %4x: %d %p\n", auxv, auxv->a_type, auxv->u.a_val, auxv->u.a_ptr);
switch(auxv->a_type) {
case AT_PHDR:
seen |= 1;
- auxv->a_val = info->phdr;
+ auxv->u.a_val = info->phdr;
break;
case AT_PHNUM:
seen |= 2;
- auxv->a_val = info->phnum;
+ auxv->u.a_val = info->phnum;
break;
case AT_BASE:
seen |= 4;
- auxv->a_val = info->interp_base;
+ auxv->u.a_val = info->interp_base;
break;
case AT_ENTRY:
seen |= 8;
- auxv->a_val = info->entry;
+ auxv->u.a_val = info->entry;
break;
}
}
for(; auxv->a_type != AT_NULL; auxv++)
switch(auxv->a_type) {
case AT_UME_PADFD:
- as_setpadfd(auxv->a_val);
+ as_setpadfd(auxv->u.a_val);
found |= 1;
break;
case AT_UME_EXECFD:
- kp.vgexecfd = auxv->a_val;
+ kp.vgexecfd = auxv->u.a_val;
found |= 2;
break;
}
auxsize = sizeof(*auxv); /* there's always at least one entry: AT_NULL */
for(cauxv = orig_auxv; cauxv->a_type != AT_NULL; cauxv++) {
if (cauxv->a_type == AT_PLATFORM)
- stringsize += strlen(cauxv->a_ptr) + 1;
+ stringsize += strlen(cauxv->u.a_ptr) + 1;
auxsize += sizeof(*cauxv);
}
mmap((void *)PGROUNDDN(cl_esp),
client_end - PGROUNDDN(cl_esp),
PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
/* ==================== copy client stack ==================== */
if (info->phdr == 0)
auxv->a_type = AT_IGNORE;
else
- auxv->a_val = info->phdr;
+ auxv->u.a_val = info->phdr;
break;
case AT_PHNUM:
if (info->phdr == 0)
auxv->a_type = AT_IGNORE;
else
- auxv->a_val = info->phnum;
+ auxv->u.a_val = info->phnum;
break;
case AT_BASE:
if (info->interp_base == 0)
auxv->a_type = AT_IGNORE;
else
- auxv->a_val = info->interp_base;
+ auxv->u.a_val = info->interp_base;
break;
case AT_PLATFORM: /* points to a platform description string */
- auxv->a_ptr = copy_str(&strtab, orig_auxv->a_ptr);
+ auxv->u.a_ptr = copy_str(&strtab, orig_auxv->u.a_ptr);
break;
case AT_ENTRY:
- auxv->a_val = info->entry;
+ auxv->u.a_val = info->entry;
break;
case AT_IGNORE:
the kernel actually execve's) should never be SUID, and we
need LD_PRELOAD/LD_LIBRARY_PATH to work for the client, we
set AT_SECURE to 0. */
- auxv->a_val = 0;
+ auxv->u.a_val = 0;
break;
case AT_SYSINFO:
/* make the redzone inaccessible */
mmap((void *)client_end, REDZONE_SIZE, PROT_NONE,
- MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
munmap(CLIENT_BASE, client_size); /* make client hole */
incrementally initialized as it is used */
if (shadow_size != 0)
mmap((char *)shadow_base, shadow_size, PROT_NONE,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
+ MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
/* unpad us */
as_unpad((void *)shadow_end, (void *)~0);
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include <asm/unistd.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
#include <dlfcn.h>
#include <assert.h>
void *a_ptr;
int a_val;
void (*a_fcn)(void);
- };
+ } u;
};
struct ume_auxv *find_auxv(int *orig_esp);
case N_STSYM:
case N_LCSYM:
sym->kind = SyStatic;
- sym->addr = si->offset + (Addr)val;
+ sym->u.addr = si->offset + (Addr)val;
break;
case N_PSYM:
sym->kind = SyEBPrel; /* +ve offset off EBP (erk, or ESP if no frame pointer) */
- sym->offset = val;
+ sym->u.offset = val;
break;
case N_LSYM:
sym->kind = SyEBPrel; /* -ve off EBP when there's a frame pointer */
else
sym->kind = SyESPrel; /* +ve off ESP when there's no frame pointer */
- sym->offset = val;
+ sym->u.offset = val;
break;
case N_RSYM:
sym->kind = SyReg;
- sym->regno = val;
+ sym->u.regno = val;
break;
case N_GSYM:
sym->kind = SyGlobal;
- sym->addr = 0; /* XXX should really look up global address */
+ sym->u.addr = 0; /* XXX should really look up global address */
break;
default:
v->size = VG_(st_sizeof)(sym->type);
if (debug && 0)
- VG_(printf)("sym->name=%s sym->kind=%d offset=%d\n", sym->name, sym->kind, sym->offset);
+ VG_(printf)("sym->name=%s sym->kind=%d offset=%d\n", sym->name, sym->kind, sym->u.offset);
switch(sym->kind) {
UInt reg;
case SyGlobal:
case SyStatic:
- if (sym->addr == 0) {
+ if (sym->u.addr == 0) {
/* XXX lookup value */
}
- v->valuep = sym->addr;
+ v->valuep = sym->u.addr;
break;
case SyReg:
- v->valuep = (Addr)regaddr(tid, sym->regno);
+ v->valuep = (Addr)regaddr(tid, sym->u.regno);
break;
case SyEBPrel:
case SyESPrel:
reg = *regaddr(tid, sym->kind == SyESPrel ? R_ESP : R_EBP);
if (debug)
- VG_(printf)("reg=%p+%d=%p\n", reg, sym->offset, reg+sym->offset);
- v->valuep = (Addr)(reg + sym->offset);
+ VG_(printf)("reg=%p+%d=%p\n", reg, sym->u.offset, reg+sym->u.offset);
+ v->valuep = (Addr)(reg + sym->u.offset);
break;
case SyType:
Int offset; /* offset on stack (-ve -> ebp; +ve -> esp) */
Int regno; /* register number */
Addr addr; /* static or global address */
- };
+ } u;
};
struct _Scope {
SymResolver *resolver; /* symtab reader's resolver */
void *data; /* data for resolver */
} t_unresolved;
- };
+ } u;
};
if (st->kind != TyUnresolved)
return;
- (*st->t_unresolved.resolver)(st, st->t_unresolved.data);
+ (*st->u.t_unresolved.resolver)(st, st->u.t_unresolved.data);
if (st->kind == TyUnresolved)
st->kind = TyError;
st->kind = TyUnresolved;
st->size = 0;
- st->t_unresolved.resolver = resolver;
- st->t_unresolved.data = data;
+ st->u.t_unresolved.resolver = resolver;
+ st->u.t_unresolved.data = data;
return st;
}
if (st->kind != TyUnresolved)
return;
- st->t_unresolved.resolver = resolver;
- st->t_unresolved.data = data;
+ st->u.t_unresolved.resolver = resolver;
+ st->u.t_unresolved.data = data;
}
Bool VG_(st_isresolved)(SymType *st)
st->kind = TyInt;
st->size = size;
- st->t_scalar.issigned = isSigned;
+ st->u.t_scalar.issigned = isSigned;
return st;
}
st->kind = TyFloat;
st->size = size;
- st->t_scalar.issigned = True;
+ st->u.t_scalar.issigned = True;
return st;
}
st->kind = TyPointer;
st->size = sizeof(void *);
- st->t_pointer.type = ptr;
+ st->u.t_pointer.type = ptr;
return st;
}
st->kind = TyRange;
st->size = 0; /* ? */
- st->t_range.type = ty;
- st->t_range.min = min;
- st->t_range.max = max;
+ st->u.t_range.type = ty;
+ st->u.t_range.min = min;
+ st->u.t_range.max = max;
return st;
}
vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyStruct);
- vg_assert(st->kind != TyStruct || st->t_struct.nfield == 0);
+ vg_assert(st->kind != TyStruct || st->u.t_struct.nfield == 0);
st->kind = TyStruct;
st->size = size;
- st->t_struct.nfield = 0;
- st->t_struct.nfieldalloc = nfields;
+ st->u.t_struct.nfield = 0;
+ st->u.t_struct.nfieldalloc = nfields;
if (nfields != 0)
- st->t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
+ st->u.t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
else
- st->t_struct.fields = NULL;
+ st->u.t_struct.fields = NULL;
return st;
}
vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyUnion);
- vg_assert(st->kind != TyUnion || st->t_struct.nfield == 0);
+ vg_assert(st->kind != TyUnion || st->u.t_struct.nfield == 0);
st->kind = TyUnion;
st->size = size;
- st->t_struct.nfield = 0;
- st->t_struct.nfieldalloc = nfields;
+ st->u.t_struct.nfield = 0;
+ st->u.t_struct.nfieldalloc = nfields;
if (nfields != 0)
- st->t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
+ st->u.t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
else
- st->t_struct.fields = NULL;
+ st->u.t_struct.fields = NULL;
return st;
}
vg_assert(st->kind == TyStruct || st->kind == TyUnion);
- if (st->t_struct.nfieldalloc == st->t_struct.nfield) {
+ if (st->u.t_struct.nfieldalloc == st->u.t_struct.nfield) {
StField *n = VG_(arena_malloc)(VG_AR_SYMTAB,
- sizeof(StField) * (st->t_struct.nfieldalloc + 2));
- VG_(memcpy)(n, st->t_struct.fields, sizeof(*n) * st->t_struct.nfield);
- if (st->t_struct.fields != NULL)
- VG_(arena_free)(VG_AR_SYMTAB, st->t_struct.fields);
- st->t_struct.nfieldalloc++;
- st->t_struct.fields = n;
+ sizeof(StField) * (st->u.t_struct.nfieldalloc + 2));
+ VG_(memcpy)(n, st->u.t_struct.fields, sizeof(*n) * st->u.t_struct.nfield);
+ if (st->u.t_struct.fields != NULL)
+ VG_(arena_free)(VG_AR_SYMTAB, st->u.t_struct.fields);
+ st->u.t_struct.nfieldalloc++;
+ st->u.t_struct.fields = n;
}
- f = &st->t_struct.fields[st->t_struct.nfield++];
+ f = &st->u.t_struct.fields[st->u.t_struct.nfield++];
f->name = name;
f->type = type;
f->offset = off;
vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyEnum);
st->kind = TyEnum;
- st->t_enum.ntag = 0;
- st->t_enum.tags = NULL;
+ st->u.t_enum.ntag = 0;
+ st->u.t_enum.tags = NULL;
return st;
}
vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown);
st->kind = TyArray;
- st->t_array.type = type;
- st->t_array.idxtype = idxtype;
+ st->u.t_array.type = type;
+ st->u.t_array.idxtype = idxtype;
return st;
}
st->kind = TyTypedef;
st->name = name;
- st->t_typedef.type = type;
+ st->u.t_typedef.type = type;
return st;
}
resolve(type);
if (type->kind == TyTypedef)
- type = type->t_typedef.type;
+ type = type->u.t_typedef.type;
}
return type;
Int i;
if (debug)
- VG_(printf)(" %d fields\n", type->t_struct.nfield);
- for(i = 0; i < type->t_struct.nfield; i++) {
- StField *f = &type->t_struct.fields[i];
+ VG_(printf)(" %d fields\n", type->u.t_struct.nfield);
+ for(i = 0; i < type->u.t_struct.nfield; i++) {
+ StField *f = &type->u.t_struct.fields[i];
newvar(f->name, f->type, var->valuep + (f->offset / 8), (f->size + 7) / 8);
}
break;
Int i;
Int offset; /* offset of index for non-0-based arrays */
Int min, max; /* range of indicies we care about (0 based) */
- SymType *ty = type->t_array.type;
- vg_assert(type->t_array.idxtype->kind == TyRange);
+ SymType *ty = type->u.t_array.type;
+ vg_assert(type->u.t_array.idxtype->kind == TyRange);
- offset = type->t_array.idxtype->t_range.min;
+ offset = type->u.t_array.idxtype->u.t_range.min;
min = 0;
- max = type->t_array.idxtype->t_range.max - offset;
+ max = type->u.t_array.idxtype->u.t_range.max - offset;
if ((max-min+1) == 0) {
#if SHADOWCHUNK
/* XXX work out a way of telling whether a pointer is
actually a decayed array, and treat it accordingly */
if (is_valid_addr(var->valuep))
- newvar(NULL, type->t_pointer.type, *(Addr *)var->valuep, -1);
+ newvar(NULL, type->u.t_pointer.type, *(Addr *)var->valuep, -1);
break;
case TyUnresolved: