?l: remove direct hunk manipulation from linkers, just call malloc()
as with recent changes, cc's malloc() could make the hunk pointer misaligned. in the the compilers, the hunk pointer is used directly by the lexer with no effort to to keep the hunk pointer aligned. alloc/malloc still return aligned pointers, but hunk itself can be on a odd address after allocation of a odd sized amount of bytes. however, in the linkers, this assumption appears to be differnet. as most allocations mostly allocate padded structures. however, symbol lookup allocates strings on byte-size ganularity and the cc's malloc would misalign the hunk pointer after the malloc() call. while the rest of the code assumed hunk pointer was always aligned. this change removes all the hunk pointer fiddling from the linker, and we just call malloc() (which will use the fast implmenentation of cc, and should not really make much of a performance difference).
This commit is contained in:
parent
73f38fc546
commit
ecdf3f921e
10 changed files with 40 additions and 259 deletions
|
@ -498,12 +498,7 @@ dosym:
|
|||
}
|
||||
}
|
||||
|
||||
while(nhunk < sizeof(Auto))
|
||||
gethunk();
|
||||
u = (Auto*)hunk;
|
||||
nhunk -= sizeof(Auto);
|
||||
hunk += sizeof(Auto);
|
||||
|
||||
u = malloc(sizeof(Auto));
|
||||
u->link = curauto;
|
||||
curauto = u;
|
||||
u->asym = s;
|
||||
|
@ -760,12 +755,7 @@ loop:
|
|||
goto loop;
|
||||
}
|
||||
|
||||
while(nhunk < sizeof(Prog))
|
||||
gethunk();
|
||||
p = (Prog*)hunk;
|
||||
nhunk -= sizeof(Prog);
|
||||
hunk += sizeof(Prog);
|
||||
|
||||
p = malloc(sizeof(Prog));
|
||||
p->as = o;
|
||||
p->line = bloc[2] | (bloc[3] << 8) | (bloc[4] << 16) | (bloc[5] << 24);
|
||||
p->back = 2;
|
||||
|
@ -1025,12 +1015,7 @@ lookup(char *symb, int v)
|
|||
if(memcmp(s->name, symb, l) == 0)
|
||||
return s;
|
||||
|
||||
while(nhunk < sizeof(Sym))
|
||||
gethunk();
|
||||
s = (Sym*)hunk;
|
||||
nhunk -= sizeof(Sym);
|
||||
hunk += sizeof(Sym);
|
||||
|
||||
s = malloc(sizeof(Sym));
|
||||
s->name = malloc(l + 1);
|
||||
memmove(s->name, symb, l);
|
||||
|
||||
|
@ -1046,14 +1031,7 @@ lookup(char *symb, int v)
|
|||
Prog*
|
||||
prg(void)
|
||||
{
|
||||
Prog *p;
|
||||
|
||||
while(nhunk < sizeof(Prog))
|
||||
gethunk();
|
||||
p = (Prog*)hunk;
|
||||
nhunk -= sizeof(Prog);
|
||||
hunk += sizeof(Prog);
|
||||
|
||||
Prog *p = (Prog*)malloc(sizeof(Prog));
|
||||
*p = zprg;
|
||||
return p;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue