From 619ba3b41634db404b3699bf677285350ddf00a0 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sat, 13 Jun 2015 14:24:31 +0000 Subject: [PATCH] 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 --- contrib/elftoolchain/elfcopy/sections.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c index a407a4274718..a6fd25d5f332 100644 --- a/contrib/elftoolchain/elfcopy/sections.c +++ b/contrib/elftoolchain/elfcopy/sections.c @@ -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));