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
This commit is contained in:
Ed Maste 2014-12-22 16:31:09 +00:00
parent a59806b252
commit 9ef62fdb87

View File

@ -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