diff options
author | emaste <emaste@FreeBSD.org> | 2014-12-22 16:31:09 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-12-22 16:31:09 +0000 |
commit | 7740946485db08b2a4367192fe0ade8891fda5d8 (patch) | |
tree | f94b759ee7a808a29b6a22c74cbb69e8e32a07aa /contrib/elftoolchain/elfcopy | |
parent | 6e107d58e3237f5dcc1e263809d7ee7b9bde58fb (diff) | |
download | FreeBSD-src-7740946485db08b2a4367192fe0ade8891fda5d8.zip FreeBSD-src-7740946485db08b2a4367192fe0ade8891fda5d8.tar.gz |
Set up default shstrtab entries at shstrtab initialization
Instead of waiting until the addition of the first non-default entry.
This fixes a segfault when strip(1) is asked to remove every section from
an object file.
Upstream elftoolchain ticket 463
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1341
Diffstat (limited to 'contrib/elftoolchain/elfcopy')
-rw-r--r-- | contrib/elftoolchain/elfcopy/sections.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c index 1704a6b..1ad7252 100644 --- a/contrib/elftoolchain/elfcopy/sections.c +++ b/contrib/elftoolchain/elfcopy/sections.c @@ -1139,12 +1139,6 @@ add_to_shstrtab(struct elfcopy *ecp, const char *name) struct section *s; s = ecp->shstrtab; - if (s->buf == NULL) { - insert_to_strtab(s, ""); - insert_to_strtab(s, ".symtab"); - insert_to_strtab(s, ".strtab"); - insert_to_strtab(s, ".shstrtab"); - } insert_to_strtab(s, name); } @@ -1206,6 +1200,11 @@ init_shstrtab(struct elfcopy *ecp) s->loadable = 0; s->type = SHT_STRTAB; s->vma = 0; + + insert_to_strtab(s, ""); + insert_to_strtab(s, ".symtab"); + insert_to_strtab(s, ".strtab"); + insert_to_strtab(s, ".shstrtab"); } void |