diff options
author | norly <ny-git@enpas.org> | 2013-06-27 03:20:54 +0100 |
---|---|---|
committer | norly <ny-git@enpas.org> | 2013-06-27 03:20:54 +0100 |
commit | 13b621d944766f19db762c0fd79e359e824a5f83 (patch) | |
tree | b83319b362580e31c929bd6d649769421c1a6ecf /src/libelfu/model/section.c | |
parent | c76af00e00b540ce7ddbc44d145bc2e70927a799 (diff) |
Allocate .symtab during Reladd if none presentcleanup
Diffstat (limited to 'src/libelfu/model/section.c')
-rw-r--r-- | src/libelfu/model/section.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libelfu/model/section.c b/src/libelfu/model/section.c index 9ef6fd8..74fbc3a 100644 --- a/src/libelfu/model/section.c +++ b/src/libelfu/model/section.c @@ -198,6 +198,30 @@ ElfuScn** elfu_mScnSortedByOffset(ElfuElf *me, size_t *count) +int elfu_mScnAppendData(ElfuScn *ms, void *buf, size_t len) +{ + char *newbuf; + + assert(ms); + assert(ms->shdr.sh_type != SHT_NOBITS); + assert(ms->databuf); + + newbuf = realloc(ms->databuf, ms->shdr.sh_size + len); + if (!newbuf) { + ELFU_WARN("elfu_mScnAppendData: malloc() failed for newbuf.\n"); + return -1; + } + + ms->databuf = newbuf; + memcpy(newbuf + ms->shdr.sh_size, buf, len); + ms->shdr.sh_size += len; + assert(ms->shdr.sh_size == ms->shdr.sh_size); + + return 0; +} + + + /* * Allocation, destruction */ |