diff options
| author | Mark Wielaard <[email protected]> | 2016-08-06 15:13:19 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-08-15 09:58:09 +0200 |
| commit | 6ff6c215bfa4153874751cdc0bae26acfbba4a81 (patch) | |
| tree | d66b9e7fd602ed1733cca45dcfab8edd05425b00 /src/strip.c | |
| parent | a8b2529facfbabfe4c8a0ca1a4387fe482d1c955 (diff) | |
strip: Handle compressed relocation target sections.
binutils 2.27 assembler will create compressed sections for x86 ELF
targets. The linker will decompress them again and it doesn't do this
for any other target. This broke one of the run-strip-reloc.sh self tests.
Fix by checking if the target of a relocation section is compressed and
first decompressing it before applying relocations and then compressing
again if necessary.
Add explicit testcases for compressed and uncompressed ET_REL files
to run-strip-reloc.sh.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/strip.c')
| -rw-r--r-- | src/strip.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/strip.c b/src/strip.c index 23d3d51b..f56554f7 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1,5 +1,5 @@ /* Discard section not used at runtime from object files. - Copyright (C) 2000-2012, 2014, 2015 Red Hat, Inc. + Copyright (C) 2000-2012, 2014, 2015, 2016 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2000. @@ -1791,10 +1791,18 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, Elf_Data *reldata = elf_getdata (scn, NULL); if (reldata == NULL || reldata->d_buf == NULL) INTERNAL_ERROR (fname); - /* We actually wanted the rawdata, but since we already - accessed it earlier as elf_getdata () that won't - work. But debug sections are all ELF_T_BYTE, so it - doesn't really matter. */ + + /* Make sure we adjust the uncompressed debug data + (and recompress if necessary at the end). */ + GElf_Chdr tchdr; + int tcompress_type = 0; + 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 || tdata->d_type != ELF_T_BYTE) @@ -1976,6 +1984,10 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, nrels = next; 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, 0) != 1) + INTERNAL_ERROR (fname); } } } |
