elfcopy: Handle objects without a ".shstrtab" section string table

As of LLVM revision 238073, LLVM stores symbols and section names in
the same string table.  From the upstream commit mesage:

  With the scheme of naming sections like ".text.foo" where foo is a
  symbol, there is a big potential saving in using a single one.

This is a cherry-pick of ELF Tool Chain revision 3225.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2015-06-13 14:24:31 +00:00
parent 5b889f3ddb
commit 619ba3b416

View File

@ -1349,6 +1349,14 @@ set_shstrtab(struct elfcopy *ecp)
s = ecp->shstrtab;
if (s->os == NULL) {
/* Input object does not contain .shstrtab section */
if ((s->os = elf_newscn(ecp->eout)) == NULL)
errx(EXIT_FAILURE, "elf_newscn failed: %s",
elf_errmsg(-1));
insert_to_sec_list(ecp, s, 1);
}
if (gelf_getshdr(s->os, &sh) == NULL)
errx(EXIT_FAILURE, "692 gelf_getshdr() failed: %s",
elf_errmsg(-1));