unsigned char *p;
if (strp_htab == NULL)
- return NULL;
+ {
+ debug_sections[DEBUG_STR].new_data = NULL;
+ debug_sections[DEBUG_STR].new_size = 0;
+ return NULL;
+ }
count = htab_elements (strp_htab);
arr = (struct strp_entry **)
obstack_alloc (&ob, count * sizeof (struct strp_entry *));
GElf_Word shstrtabadd = 0;
char *shstrtab = NULL;
bool remove_gdb_index = false;
+ bool remove_debug_str = false;
ehdr = dso->ehdr;
if (multi_ehdr.e_ident[0] == '\0')
> (unsigned int) addsec)
dso->shdr[j].sh_info++;
}
- if (ehdr.e_shstrndx > addsec)
+ if (dso->ehdr.e_shstrndx > addsec)
ehdr.e_shstrndx++;
len = strlen (debug_sections[i].name) + 1;
dso->shdr[dso->ehdr.e_shstrndx].sh_size += len;
ehdr.e_shoff += diff;
dso->shdr[debug_sections[i].sec].sh_size
= debug_sections[i].new_size;
- if (i == GDB_INDEX
+ if ((i == GDB_INDEX || i == DEBUG_STR)
&& debug_sections[i].new_size == 0)
{
- remove_gdb_index = true;
+ if (i == GDB_INDEX)
+ remove_gdb_index = true;
+ else
+ remove_debug_str = true;
ehdr.e_shnum--;
for (j = 1; j < dso->ehdr.e_shnum; ++j)
{
> (unsigned int) debug_sections[i].sec)
dso->shdr[j].sh_info--;
}
- if (ehdr.e_shstrndx > debug_sections[i].sec)
+ if (dso->ehdr.e_shstrndx > debug_sections[i].sec)
ehdr.e_shstrndx--;
}
}
if (remove_gdb_index
&& i == debug_sections[GDB_INDEX].sec)
continue;
+ if (remove_debug_str
+ && i == debug_sections[DEBUG_STR].sec)
+ continue;
scn = elf_newscn (elf);
elf_flagscn (scn, ELF_C_SET, ELF_F_DIRTY);
gelf_update_shdr (scn, &dso->shdr[i]);