From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752860AbdKWM7B (ORCPT ); Thu, 23 Nov 2017 07:59:01 -0500 Received: from mx3.parnet.fi ([77.234.108.7]:55738 "EHLO mx3.parnet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751911AbdKWM67 (ORCPT ); Thu, 23 Nov 2017 07:58:59 -0500 X-Greylist: delayed 3428 seconds by postgrey-1.27 at vger.kernel.org; Thu, 23 Nov 2017 07:58:59 EST Date: Thu, 23 Nov 2017 14:01:44 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: "Jason A. Donenfeld" cc: nickc@redhat.com, binutils@sourceware.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] arm: detect buggy binutils when in thumb2 mode In-Reply-To: <20171123115021.25213-1-Jason@zx2c4.com> Message-ID: References: <20171123114802.24942-1-Jason@zx2c4.com> <20171123115021.25213-1-Jason@zx2c4.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Nov 2017, Jason A. Donenfeld wrote: > On older versions of binutils, \sym points to an aligned address. On > newer versions of binutils, \sym sometimes points to the unaligned thumb > address in certain circumstances. In order to homogenize this behavior, > rather than adding 1, we could simply OR in 1, so that already unaligned > instructions don't change. While that works, the downside is that we have > to add an `orr` instruction to a fast path. The assembler can't do this at > assemble time via "|1" because "invalid operands (.text and *ABS* sections) > for `|'". A better solution would be to have consistent binutils behavior, > but that ship has sailed. > > So, this commit adds a detection mechanism, which began as a small thing > from Russell King that I then rewrote to use pure bash instead of > shelling out, so that it doesn't slow down the build process. The detection > mechanism _could_ be used to modify the assembly we generate, but for now > it's just being used to catch buggy binutils and abort the build process in > that case. > > The rest of this commit message contains all of the relevant information > about the boot bug when compiled in thumb2 mode. > > My tests concerned these versions: > broken: GNU ld (Gentoo 2.29.1 p3) 2.29.1 > working: GNU ld (GNU Binutils for Ubuntu) 2.26.1 FWIW, this issue stems from this change: https://sourceware.org/bugzilla/show_bug.cgi?id=21458 The same issue caused problems in libavcodec as well, where we chose to work around the issue in this fashion: https://git.libav.org/?p=libav.git;a=commitdiff;h=9dde6ab06c48f9447cd16f39bee33569cddb7be4;hp=547db1eaecd597031165a2bf637acaaacde52788 Related debian bug report, with a different workaround: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870622 (In libav, we chose the workaround since the .eqv one suggested in the debian bug report didn't really work well with assemblers for other platforms.) // Martin