aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-14 17:03:33 +1300
committerAndrew Chambers <[email protected]>2021-10-14 17:03:33 +1300
commit4967589e726a760153bb17ae2136c4fc28554d77 (patch)
treec1ea0bebf54d2d703fa0709063a08eb741033c9d /main.c
parent303d73960d49a67f45d7b653bbeff5b6c0b4efa7 (diff)
Never add data to bss.
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 943f04e..3cf9a88 100644
--- a/main.c
+++ b/main.c
@@ -58,11 +58,18 @@ static const char *secname(Section *s) {
}
static void secaddbytes(Section *s, const void *bytes, size_t n) {
+
+ if (s->hdr.sh_type == SHT_NOBITS) {
+ s->hdr.sh_size += n;
+ return;
+ }
+
while (s->capacity < s->hdr.sh_size + n) {
- s->capacity = s->capacity ? (s->capacity * 2) : 64;
+ s->capacity = s->capacity ? (s->capacity * 2) : 512;
s->data = xrealloc(s->data, s->capacity);
}
memcpy(s->data + s->hdr.sh_size, bytes, n);
+
s->hdr.sh_size += n;
}