896e01d
commit 73e83285fbeac648edb60a0c4767fad9d470cf0a
896e01d
Author: Mark Wielaard <mark@klomp.org>
896e01d
Date:   Sat Jul 21 23:40:11 2018 +0200
896e01d
896e01d
    unstrip: Handle SHT_GROUP sections in ET_REL files.
896e01d
    
896e01d
    SHT_GROUP sections are put in both the stripped and debug file.
896e01d
    Handle correcting the symbol table/name entry of the group only once.
896e01d
    
896e01d
    The testfile was generated with the gcc annobin plugin.
896e01d
    
896e01d
    Signed-off-by: Mark Wielaard <mark@klomp.org>
896e01d
896e01d
diff --git a/src/unstrip.c b/src/unstrip.c
896e01d
index 057efef..cb1f7dc 100644
896e01d
--- a/src/unstrip.c
896e01d
+++ b/src/unstrip.c
896e01d
@@ -563,7 +563,11 @@ adjust_all_relocs (Elf *elf, Elf_Scn *symtab, const GElf_Shdr *symshdr,
896e01d
 	GElf_Shdr shdr_mem;
896e01d
 	GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
896e01d
 	ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
896e01d
-	if (shdr->sh_type != SHT_NOBITS && shdr->sh_link == new_sh_link)
896e01d
+	/* Don't redo SHT_GROUP, groups are in both the stripped and debug,
896e01d
+	   it will already have been done by adjust_relocs for the
896e01d
+	   stripped_symtab.  */
896e01d
+	if (shdr->sh_type != SHT_NOBITS && shdr->sh_type != SHT_GROUP
896e01d
+	    && shdr->sh_link == new_sh_link)
896e01d
 	  adjust_relocs (scn, scn, shdr, map, symshdr);
896e01d
       }
896e01d
 }