else if (inflate == 0)
{
/* In theory the user could have constucted a compressed section
- by hand. But we always just take the rawdata directly and
- decompress that. */
- Elf_Data *data = elf_rawdata (scn, NULL);
+ by hand. And in practice they do. For example when copying
+ a section from one file to another using elf_newdata. So we
+ have to use elf_getdata (not elf_rawdata). */
+ Elf_Data *data = elf_getdata (scn, NULL);
if (data == NULL)
return -1;
+2018-11-09 Mark Wielaard <mark@klomp.org>
+
+ * strip.c (remove_debug_relocations): Check if section is gnu
+ compressed and decompress and recompress it.
+
2018-11-12 Mark Wielaard <mark@klomp.org>
* elflint.c (check_note_data): Recognize NT_GNU_BUILD_ATTRIBUTE_OPEN
(and recompress if necessary at the end). */
GElf_Chdr tchdr;
int tcompress_type = 0;
- if (gelf_getchdr (tscn, &tchdr) != NULL)
+ bool is_gnu_compressed = false;
+ if (strncmp (tname, ".zdebug", strlen ("zdebug")) == 0)
{
- tcompress_type = tchdr.ch_type;
- if (elf_compress (tscn, 0, 0) != 1)
+ is_gnu_compressed = true;
+ if (elf_compress_gnu (tscn, 0, 0) != 1)
INTERNAL_ERROR (fname);
}
+ else
+ {
+ if (gelf_getchdr (tscn, &tchdr) != NULL)
+ {
+ tcompress_type = tchdr.ch_type;
+ if (elf_compress (tscn, 0, 0) != 1)
+ INTERNAL_ERROR (fname);
+ }
+ }
Elf_Data *tdata = elf_getdata (tscn, NULL);
if (tdata == NULL || tdata->d_buf == NULL
shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize;
gelf_update_shdr (scn, shdr);
- if (tcompress_type != 0)
- if (elf_compress (tscn, tcompress_type, ELF_CHF_FORCE) != 1)
- INTERNAL_ERROR (fname);
+ if (is_gnu_compressed)
+ {
+ if (elf_compress_gnu (tscn, 1, ELF_CHF_FORCE) != 1)
+ INTERNAL_ERROR (fname);
+ }
+ else if (tcompress_type != 0)
+ {
+ if (elf_compress (tscn, tcompress_type, ELF_CHF_FORCE) != 1)
+ INTERNAL_ERROR (fname);
+ }
}
}
}
testfiles testfile-debug-rel-ppc64.o
runtest testfile-debug-rel-ppc64.o 1
+testfiles testfile-debug-rel-ppc64-z.o
+runtest testfile-debug-rel-ppc64-z.o 1
+
+testfiles testfile-debug-rel-ppc64-g.o
+runtest testfile-debug-rel-ppc64-g.o 1
+
exit $status