[Bug libelf/23916] [bisected] elifutils-0.175 broke kernel's objtool (elifutils-0.173 works)

mark at klomp dot org sourceware-bugzilla@sourceware.org
Sat Nov 24 01:04:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23916

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
Thanks. I am fairly sure this is a bug in binutils/bfd.

First gas creates a compressed section with the wrong alignment.
Because a compressed section has a Chdr it needs to be aligned
to either 4 or 8 depending on ELF class (32 or 64 bit). The actual
alignment of the uncompressed section data is contained in the Chdr
as ch_addralign. gas/bfd seems to always just use the same (1) alignment
for both the uncompressed section data and compressed data.

Second libelf accepts this, but corrects the alignment when it
writes out the section.

Third bfd_check_compression_header sanity checks the section alignment,
but it checks that the compressed and decompressed alignment is equal?!?
I think it wanted to check that the alignment is a power of 2 instead.

The following (obviously somewhat incorrect, because it just ignores the
alignment completely) patch seems to fix/workaround things:

diff --git a/bfd/bfd.c b/bfd/bfd.c
index 15becd7ae8..9cc05a0174 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2404,7 +2404,7 @@ bfd_check_compression_header (bfd *abfd, bfd_byte
*contents,
       chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
     }
       if (chdr.ch_type == ELFCOMPRESS_ZLIB
-      && chdr.ch_addralign == 1U << sec->alignment_power)
+      /* && chdr.ch_addralign == 1U << sec->alignment_power */)
     {
       *uncompressed_size = chdr.ch_size;
       return TRUE;

I'll file a proper bug and patch tomorrow against binutils.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list