elf,stabs: stabs32/64_generate -- append ending token

This represent "end of compilation unit" token.
Since gcc does (almost) the same lets be on the
same side.

Though to be precise gcc puts offset which points
to the first byte right after the last instruction
issued but in fact string index is analyzed only
so we may safely write zero here (without relocation
as well).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2009-09-14 22:10:08 +04:00
parent 28032a027c
commit 69c4f63c25
2 changed files with 19 additions and 16 deletions

View File

@ -1689,19 +1689,16 @@ static void stabs32_generate(void)
/* /*
* worst case size of the stab buffer would be: * worst case size of the stab buffer would be:
* the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line * the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line
* plus one "ending" entry
*/ */
sbuf = sbuf = (uint8_t *)nasm_malloc((numlinestabs * 2 + 4) *
(uint8_t *)nasm_malloc((numlinestabs * 2 + 3) * sizeof(struct stabentry));
sizeof(struct stabentry));
ssbuf = (uint8_t *)nasm_malloc(strsize); ssbuf = (uint8_t *)nasm_malloc(strsize);
rbuf = (uint8_t *)nasm_malloc(numlinestabs * 8 * (2 + 3)); rbuf = (uint8_t *)nasm_malloc(numlinestabs * 8 * (2 + 3));
rptr = rbuf; rptr = rbuf;
for (i = 0; i < numfiles; i++) { for (i = 0; i < numfiles; i++)
strcpy((char *)ssbuf + fileidx[i], allfiles[i]); strcpy((char *)ssbuf + fileidx[i], allfiles[i]);
}
ssbuf[0] = 0; ssbuf[0] = 0;
stabstrlen = strsize; /* set global variable for length of stab strings */ stabstrlen = strsize; /* set global variable for length of stab strings */
@ -1764,6 +1761,10 @@ static void stabs32_generate(void)
} }
/* this is an "ending" token */
WRITE_STAB(sptr, 0, N_SO, 0, 0, 0);
numstabs++;
((struct stabentry *)sbuf)->n_desc = numstabs; ((struct stabentry *)sbuf)->n_desc = numstabs;
nasm_free(allfiles); nasm_free(allfiles);

View File

@ -1763,21 +1763,19 @@ static void stabs64_generate(void)
} }
} }
/* worst case size of the stab buffer would be: /*
the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line * worst case size of the stab buffer would be:
* the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line
* plus one "ending" entry
*/ */
sbuf = sbuf = (uint8_t *)nasm_malloc((numlinestabs * 2 + 4) *
(uint8_t *)nasm_malloc((numlinestabs * 2 + 3) * sizeof(struct stabentry));
sizeof(struct stabentry));
ssbuf = (uint8_t *)nasm_malloc(strsize); ssbuf = (uint8_t *)nasm_malloc(strsize);
rbuf = (uint8_t *)nasm_malloc(numlinestabs * 16 * (2 + 3)); rbuf = (uint8_t *)nasm_malloc(numlinestabs * 16 * (2 + 3));
rptr = rbuf; rptr = rbuf;
for (i = 0; i < numfiles; i++) { for (i = 0; i < numfiles; i++)
strcpy((char *)ssbuf + fileidx[i], allfiles[i]); strcpy((char *)ssbuf + fileidx[i], allfiles[i]);
}
ssbuf[0] = 0; ssbuf[0] = 0;
stabstrlen = strsize; /* set global variable for length of stab strings */ stabstrlen = strsize; /* set global variable for length of stab strings */
@ -1841,6 +1839,10 @@ static void stabs64_generate(void)
} }
/* this is an "ending" token */
WRITE_STAB(sptr, 0, N_SO, 0, 0, 0);
numstabs++;
((struct stabentry *)sbuf)->n_desc = numstabs; ((struct stabentry *)sbuf)->n_desc = numstabs;
nasm_free(allfiles); nasm_free(allfiles);