On Wed, Aug 19, 2020 at 11:51:15PM +0200, Mark Wielaard wrote:
> In elf_getdata.c we have the following to compensate for possibly
> bad sh_addralign values of compressed sections:
> 
>       /* Compressed data has a header, but then compressed data.
>          Make sure to set the alignment of the header explicitly,
>          don't trust the file alignment for the section, it is
>          often wrong.  */
>       if ((flags & SHF_COMPRESSED) != 0)
>         {
>           entsize = 1;
>           align = __libelf_type_align (elf->class, ELF_T_CHDR);
>         }
> 
> Which makes sure the d_data alignment is correct for the Chdr struct
> at the start of the compressed section.
> 
> But this means that if a user just reads such a compressed section
> without changing it, and then tries to write it out again using
> elf_update they get an error message about d_align and sh_addralign
> being out of sync.
> 
> We already correct obviously incorrect sh_entsize fields.
> Do the same for the sh_addralign field of a SHF_COMPRESSED section.

Pushed to master and added to the Fedora rawhide package.

Cheers,

Mark

Reply via email to