Make elf proghdr fields match what objdump prints

This commit is contained in:
Frans Kaashoek 2011-08-17 20:23:36 -04:00
parent 5f069dcf2f
commit fa81545f1c
3 changed files with 7 additions and 7 deletions

View file

@ -35,8 +35,8 @@ bootmain(void)
ph = (struct proghdr*)((uchar*)elf + elf->phoff); ph = (struct proghdr*)((uchar*)elf + elf->phoff);
eph = ph + elf->phnum; eph = ph + elf->phnum;
for(; ph < eph; ph++){ for(; ph < eph; ph++){
pa = (uchar*)ph->pa; pa = (uchar*)ph->paddr;
readseg(pa, ph->filesz, ph->offset); readseg(pa, ph->filesz, ph->off);
if(ph->memsz > ph->filesz) if(ph->memsz > ph->filesz)
stosb(pa + ph->filesz, 0, ph->memsz - ph->filesz); stosb(pa + ph->filesz, 0, ph->memsz - ph->filesz);
} }

6
elf.h
View file

@ -24,9 +24,9 @@ struct elfhdr {
// Program section header // Program section header
struct proghdr { struct proghdr {
uint type; uint type;
uint offset; uint off;
uint va; uint vaddr;
uint pa; uint paddr;
uint filesz; uint filesz;
uint memsz; uint memsz;
uint flags; uint flags;

4
exec.c
View file

@ -41,9 +41,9 @@ exec(char *path, char **argv)
continue; continue;
if(ph.memsz < ph.filesz) if(ph.memsz < ph.filesz)
goto bad; goto bad;
if((sz = allocuvm(pgdir, sz, ph.va + ph.memsz)) == 0) if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0)
goto bad; goto bad;
if(loaduvm(pgdir, (char*)ph.va, ip, ph.offset, ph.filesz) < 0) if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0)
goto bad; goto bad;
} }
iunlockput(ip); iunlockput(ip);