diff options
author | Kai Wang <kaiw@FreeBSD.org> | 2010-07-21 09:27:16 +0000 |
---|---|---|
committer | Kai Wang <kaiw@FreeBSD.org> | 2010-07-21 09:27:16 +0000 |
commit | c0308c2c849131d8e95780cdce5397e41f4f4f1a (patch) | |
tree | 4033f1d598426806df7f697baa45dcd4437f77af /lib/libelf | |
parent | 49ca10d40c30236988dd5153c1456b474ae2e4b9 (diff) | |
download | src-c0308c2c849131d8e95780cdce5397e41f4f4f1a.tar.gz src-c0308c2c849131d8e95780cdce5397e41f4f4f1a.zip |
Bug fix: permit the creation of zero-sized sections.
Obtained from: elftoolchain
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=210328
Diffstat (limited to 'lib/libelf')
-rw-r--r-- | lib/libelf/elf_update.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c index fc5f9a38e6cd..a4290365d2e9 100644 --- a/lib/libelf/elf_update.c +++ b/lib/libelf/elf_update.c @@ -534,22 +534,24 @@ _libelf_write_scn(Elf *e, char *nf, Elf_Scn *s, off_t rc) int ec; size_t fsz, msz, nobjects; uint32_t sh_type; - uint64_t sh_off; + uint64_t sh_off, sh_size; int elftype; Elf_Data *d, dst; - if ((ec = e->e_class) == ELFCLASS32) + if ((ec = e->e_class) == ELFCLASS32) { sh_type = s->s_shdr.s_shdr32.sh_type; - else + sh_size = (uint64_t) s->s_shdr.s_shdr32.sh_size; + } else { sh_type = s->s_shdr.s_shdr64.sh_type; + sh_size = s->s_shdr.s_shdr64.sh_size; + } /* * Ignore sections that do not allocate space in the file. */ - if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) + if (sh_type == SHT_NOBITS || sh_type == SHT_NULL || sh_size == 0) return (rc); - elftype = _libelf_xlate_shtype(sh_type); assert(elftype >= ELF_T_FIRST && elftype <= ELF_T_LAST); |