From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11598 invoked by alias); 24 Nov 2018 01:04:26 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 11536 invoked by uid 48); 24 Nov 2018 01:04:22 -0000 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libelf/23916] [bisected] elifutils-0.175 broke kernel's objtool (elifutils-0.173 works) Date: Sat, 24 Nov 2018 01:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libelf X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2018-q4/txt/msg00184.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D23916 --- Comment #2 from Mark Wielaard --- 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 =3D bfd_get_64 (abfd, &echdr->ch_addralign); } if (chdr.ch_type =3D=3D ELFCOMPRESS_ZLIB - && chdr.ch_addralign =3D=3D 1U << sec->alignment_power) + /* && chdr.ch_addralign =3D=3D 1U << sec->alignment_power */) { *uncompressed_size =3D chdr.ch_size; return TRUE; I'll file a proper bug and patch tomorrow against binutils. --=20 You are receiving this mail because: You are on the CC list for the bug.