summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2009-09-14 22:10:08 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2009-09-14 22:43:30 +0400
commit69c4f63c25fb5ead8e8439fcfa112f0e8d68ec03 (patch)
treeab279017ee7589a6bfd9b244ab3072b6b99e9b7b
parent28032a027c1739bcee8fcaa26257f842a4945408 (diff)
downloadnasm-69c4f63c25fb5ead8e8439fcfa112f0e8d68ec03.tar.gz
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>
-rw-r--r--output/outelf32.c15
-rw-r--r--output/outelf64.c20
2 files changed, 19 insertions, 16 deletions
diff --git a/output/outelf32.c b/output/outelf32.c
index 23d576ed..47c9d103 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -1689,19 +1689,16 @@ static void stabs32_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
+ * plus one "ending" entry
*/
- sbuf =
- (uint8_t *)nasm_malloc((numlinestabs * 2 + 3) *
- sizeof(struct stabentry));
-
+ sbuf = (uint8_t *)nasm_malloc((numlinestabs * 2 + 4) *
+ sizeof(struct stabentry));
ssbuf = (uint8_t *)nasm_malloc(strsize);
-
rbuf = (uint8_t *)nasm_malloc(numlinestabs * 8 * (2 + 3));
rptr = rbuf;
- for (i = 0; i < numfiles; i++) {
+ for (i = 0; i < numfiles; i++)
strcpy((char *)ssbuf + fileidx[i], allfiles[i]);
- }
ssbuf[0] = 0;
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;
nasm_free(allfiles);
diff --git a/output/outelf64.c b/output/outelf64.c
index 53bc4c5a..b005693c 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -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 =
- (uint8_t *)nasm_malloc((numlinestabs * 2 + 3) *
- sizeof(struct stabentry));
-
+ sbuf = (uint8_t *)nasm_malloc((numlinestabs * 2 + 4) *
+ sizeof(struct stabentry));
ssbuf = (uint8_t *)nasm_malloc(strsize);
-
rbuf = (uint8_t *)nasm_malloc(numlinestabs * 16 * (2 + 3));
rptr = rbuf;
- for (i = 0; i < numfiles; i++) {
+ for (i = 0; i < numfiles; i++)
strcpy((char *)ssbuf + fileidx[i], allfiles[i]);
- }
ssbuf[0] = 0;
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;
nasm_free(allfiles);