Hi Mark, On Mon, May 18, 2026 at 12:54 PM Mark Wielaard <[email protected]> wrote: > > Depending on whether the ELF was 32 or 64 bit elf_compress would get > the original sh_addralign, as embedded in the Chdr, differenly. For > 32bit ELF we would simply get the sh_addralign from the Shdr. For > 64bit ELF we would take the (max) alignment of the underlying > Elf_Data, provided by __libelf_compress. Use the second method for
I think this description of the 32bit and 64bit approaches is reversed. It looks like the 64bit ELF got sh_addralign from the Shdr. Otherwise LGTM. Aaron > both since the Shdr might not have been setup yet, so what counts is > the Elf_Data alignment. > > * libelf/elf_compress.c (elf_compress): Remove sh_addralign. > Set chdr.ch_addralign to orig_addralign in 32bit case. > > Signed-off-by: Mark Wielaard <[email protected]> > --- > libelf/elf_compress.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c > index a2fa1f087658..28c9b25f4811 100644 > --- a/libelf/elf_compress.c > +++ b/libelf/elf_compress.c > @@ -583,7 +583,6 @@ elf_compress (Elf_Scn *scn, int type, unsigned int flags) > > Elf64_Xword sh_flags; > Elf64_Word sh_type; > - Elf64_Xword sh_addralign; > union shdr > { > Elf32_Shdr *s32; > @@ -597,7 +596,6 @@ elf_compress (Elf_Scn *scn, int type, unsigned int flags) > > sh_flags = shdr.s32->sh_flags; > sh_type = shdr.s32->sh_type; > - sh_addralign = shdr.s32->sh_addralign; > } > else > { > @@ -607,7 +605,6 @@ elf_compress (Elf_Scn *scn, int type, unsigned int flags) > > sh_flags = shdr.s64->sh_flags; > sh_type = shdr.s64->sh_type; > - sh_addralign = shdr.s64->sh_addralign; > } > > if ((sh_flags & SHF_ALLOC) != 0) > @@ -669,7 +666,7 @@ elf_compress (Elf_Scn *scn, int type, unsigned int flags) > chdr.ch_type = type; > chdr.ch_reserved = 0; > chdr.ch_size = orig_size; > - chdr.ch_addralign = sh_addralign; > + chdr.ch_addralign = orig_addralign; > if (elfdata != MY_ELFDATA) > { > CONVERT (chdr.ch_type); > -- > 2.53.0 >
