Commit 335b3855 authored by Russ Cox's avatar Russ Cox

a little more 6l cleanup

R=r
DELTA=51  (14 added, 24 deleted, 13 changed)
OCL=31968
CL=31971
parent 5a74c0b6
...@@ -132,7 +132,7 @@ asmb(void) ...@@ -132,7 +132,7 @@ asmb(void)
vlong symdatva = 0x99LL<<32; vlong symdatva = 0x99LL<<32;
Elf64Hdr *eh; Elf64Hdr *eh;
Elf64PHdr *ph, *pph; Elf64PHdr *ph, *pph;
Elf64SHdr *sh, *dynsh; Elf64SHdr *sh;
if(debug['v']) if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime()); Bprint(&bso, "%5.2f asmb\n", cputime());
...@@ -456,36 +456,21 @@ asmb(void) ...@@ -456,36 +456,21 @@ asmb(void)
ph->filesz = endelf() - ph->off; ph->filesz = endelf() - ph->off;
ph->align = 1; ph->align = 1;
/* S header for interpreter */
sh = newElf64SHdr(".interp"); sh = newElf64SHdr(".interp");
sh->type = SHT_PROGBITS; sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC; sh->flags = SHF_ALLOC;
sh->addr = va;
sh->off = ph->off; sh->off = ph->off;
sh->addr = startva + sh->off; sh->addr = startva + sh->off;
sh->size = ph->filesz; sh->size = ph->filesz;
sh->addralign = 1; sh->addralign = 1;
/* dynamic load section */
ph = newElf64PHdr();
ph->type = PT_LOAD;
ph->flags = PF_R + PF_W;
ph->off = 0;
ph->vaddr = startva + ph->off;
ph->paddr = startva + ph->off;
ph->align = 8;
/* S headers inside dynamic load section */ /* S headers inside dynamic load section */
dynsh = newElf64SHdr(".dynamic"); // must be first
dynsh->off = startelf();
seek(cout, ELFDYNAMICSIZE, 1); // leave room for dynamic table
sh = newElf64SHdr(".hash"); sh = newElf64SHdr(".hash");
sh->type = SHT_HASH; sh->type = SHT_HASH;
sh->flags = SHF_ALLOC; sh->flags = SHF_ALLOC;
sh->entsize = 4; sh->entsize = 4;
sh->addr = va; sh->off = startelf();
sh->off = seek(cout, 0, 1);
hashoff = sh->off; hashoff = sh->off;
sh->addr = startva + sh->off; sh->addr = startva + sh->off;
/* temporary hack: 8 zeroes means 0 buckets, 0 chains */ /* temporary hack: 8 zeroes means 0 buckets, 0 chains */
...@@ -497,7 +482,6 @@ asmb(void) ...@@ -497,7 +482,6 @@ asmb(void)
sh->type = SHT_PROGBITS; sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC+SHF_WRITE; sh->flags = SHF_ALLOC+SHF_WRITE;
sh->entsize = 8; sh->entsize = 8;
sh->addr = va;
sh->off = startelf(); sh->off = startelf();
sh->addr = startva + sh->off; sh->addr = startva + sh->off;
sh->size = endelf() - sh->off; sh->size = endelf() - sh->off;
...@@ -507,21 +491,17 @@ asmb(void) ...@@ -507,21 +491,17 @@ asmb(void)
sh->type = SHT_PROGBITS; sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC+SHF_WRITE; sh->flags = SHF_ALLOC+SHF_WRITE;
sh->entsize = 8; sh->entsize = 8;
sh->addr = va;
sh->off = startelf(); sh->off = startelf();
sh->addr = startva + sh->off; sh->addr = startva + sh->off;
sh->size = endelf() - sh->off; sh->size = endelf() - sh->off;
sh->addralign = 8; sh->addralign = 8;
/* +8 necessary for now to silence readelf addressing at end of hash section */ sh = newElf64SHdr(".dynamic");
ph->filesz = endelf() - ph->off +8; /* dynamic section maps these shdrs' data */ sh->type = SHT_DYNAMIC;
ph->memsz = ph->filesz; sh->flags = SHF_ALLOC+SHF_WRITE;
sh->entsize = 16;
dynsh->type = SHT_DYNAMIC; sh->addr = startva + sh->off;
dynsh->flags = SHF_ALLOC+SHF_WRITE; sh->off = startelf();
dynsh->entsize = 16;
dynsh->addr = startva + dynsh->off;
seek(cout, dynsh->off, 0);
elf64writedynent(DT_HASH, startva+hashoff); elf64writedynent(DT_HASH, startva+hashoff);
elf64writedynent(DT_STRTAB, startva+ELF64FULLHDRSIZE-STRTABSIZE); elf64writedynent(DT_STRTAB, startva+ELF64FULLHDRSIZE-STRTABSIZE);
elf64writedynent(DT_SYMTAB, startva); elf64writedynent(DT_SYMTAB, startva);
...@@ -531,19 +511,29 @@ asmb(void) ...@@ -531,19 +511,29 @@ asmb(void)
elf64writedynent(DT_STRSZ, STRTABSIZE); elf64writedynent(DT_STRSZ, STRTABSIZE);
elf64writedynent(DT_SYMENT, 0); elf64writedynent(DT_SYMENT, 0);
elf64writedynent(DT_NULL, 0); elf64writedynent(DT_NULL, 0);
cflush(); sh->size = endelf() - sh->off;
dynsh->size = seek(cout, 0, 1) - dynsh->off; sh->addralign = 8;
dynsh->addralign = 8;
/* dynamic section */ /* PT_DYNAMIC for .dynamic section */
ph = newElf64PHdr(); ph = newElf64PHdr();
ph->type = PT_DYNAMIC; ph->type = PT_DYNAMIC;
ph->flags = PF_R + PF_W; ph->flags = PF_R + PF_W;
ph->off = dynsh->off; ph->off = sh->off;
ph->filesz = dynsh->size; ph->vaddr = startva + ph->off;
ph->memsz = dynsh->size; ph->paddr = startva + ph->off;
ph->filesz = sh->size;
ph->memsz = sh->size;
ph->align = 8;
/* PT_LOAD for all dynamic sections */
ph = newElf64PHdr();
ph->type = PT_LOAD;
ph->flags = PF_R + PF_W;
ph->off = 0;
ph->vaddr = startva + ph->off; ph->vaddr = startva + ph->off;
ph->paddr = startva + ph->off; ph->paddr = startva + ph->off;
ph->filesz = sh->off + sh->size - ph->off;
ph->memsz = ph->filesz;
ph->align = 8; ph->align = 8;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment