diff options
author | Mark Wielaard <mark@klomp.org> | 2018-11-13 21:18:09 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-11-13 21:30:17 +0100 |
commit | cf10453f8252df81225796d98548ba6eac113df3 (patch) | |
tree | 13cea388f62135b702fe1db133dd842e1bf2873a /libelf/elf_compress.c | |
parent | d3e6266754b95244063aa1e40c531fdd57259332 (diff) | |
download | elfutils-cf10453f8252df81225796d98548ba6eac113df3.tar.gz |
libelf: Correctly setup alignment of SHF_COMPRESSED section data.
We didn't set the alignment of SHF_COMPRESSED sections correctly.
Those sections start with an Elf(32|64)_Chdr. Make sure sh_addralign
is setup to be able to read such a struct directly. Likewise don't
trust the alignment set on any SHF_COMPRESSED section, but always
make the (raw) compressed data aligned correctly for the reading the
Elf(32|64)_Chdr directly.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf/elf_compress.c')
-rw-r--r-- | libelf/elf_compress.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c index d96245df..be9eeaba 100644 --- a/libelf/elf_compress.c +++ b/libelf/elf_compress.c @@ -455,14 +455,14 @@ elf_compress (Elf_Scn *scn, int type, unsigned int flags) { Elf32_Shdr *shdr = elf32_getshdr (scn); shdr->sh_size = new_size; - shdr->sh_addralign = 1; + shdr->sh_addralign = __libelf_type_align (ELFCLASS32, ELF_T_CHDR); shdr->sh_flags |= SHF_COMPRESSED; } else { Elf64_Shdr *shdr = elf64_getshdr (scn); shdr->sh_size = new_size; - shdr->sh_addralign = 1; + shdr->sh_addralign = __libelf_type_align (ELFCLASS64, ELF_T_CHDR); shdr->sh_flags |= SHF_COMPRESSED; } |