Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D556C3F6B0 for ; Wed, 27 Jul 2022 10:59:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7521383445; Wed, 27 Jul 2022 12:59:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="p0SNg7DK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E641C83010; Wed, 27 Jul 2022 12:59:32 +0200 (CEST) Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D6C2F83F8E for ; Wed, 27 Jul 2022 12:59:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf32.google.com with SMTP id q3so11789193qvp.5 for ; Wed, 27 Jul 2022 03:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UEIjDVBZ23ycez7kZUXYr6dbJUdm9fQvQ+DoQsDXSkg=; b=p0SNg7DKTNFFLCEepgpBdaMg+hUMoyfjjh8wvAdz3YiowWLdpii0aFSasrcabS53QS Up4a8FW21xwV9rsw4Brna83hwqZ/o7CJP8yXT2fW4/uGgEjyZAHW2MVWbQItftbwLv0z 7aVnnVaafiilOjRlohsvfCFurMFWjFg2P5hCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UEIjDVBZ23ycez7kZUXYr6dbJUdm9fQvQ+DoQsDXSkg=; b=1AVcK7HPplE0WpwbPubzwTrw/BkWbFA1NfjlLVHNJSCCYVhc7ZFPci8bBANgmA6rEF bYTdwJLMfVT0qlTRGfhDRuSMJ/j79W2Juf659KFp5bfL1U0EF1zyFwFM0WYl36wUtU04 Wcga1wPRnrWjOxbmzVHMJHb63UE4xMjEt/0kSYbMDVkglnlE0bSy1Nh0QoJcTNhiwCYs HZQ6ARc62bnP5M4ltoTYkVs5LTtLXR1WovP5TA6J+X1Ijg4eUx8Z6B0P5SpGVkRFO+zp SyFwrzfgUZFhU7yjEnXPADaFBT8noQC3j/sT0SHHzXrRbJV1BO+xDNZyDi13/UUKjlhZ 9v3g== X-Gm-Message-State: AJIora+s6RDyPe5FmM+3wDkjjTz4dqVWn5rwzNwg6ab9HZEbRonYlEYX pOvuYYvh/QgsiTHsMmkenDYG4w== X-Google-Smtp-Source: AGRyM1sPXKySHoH0be9TRq5H9yEWCDlSlUo2Ra8GiXj2glqhcM3PivRlXH7WsM/2COt7RTVt7OT3FA== X-Received: by 2002:ad4:5fc7:0:b0:474:1b46:907f with SMTP id jq7-20020ad45fc7000000b004741b46907fmr19097969qvb.55.1658919567630; Wed, 27 Jul 2022 03:59:27 -0700 (PDT) Received: from bill-the-cat (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id u6-20020a05620a0c4600b006b65410b2ddsm7627194qki.34.2022.07.27.03.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 03:59:26 -0700 (PDT) Date: Wed, 27 Jul 2022 06:59:24 -0400 From: Tom Rini To: Andre Przywara Cc: Simon Glass , Stefano Babic , Fabio Estevam , Jesse Taube , Giulio Benetti , u-boot@lists.denx.de Subject: Re: [PATCH] ARM: relocate: Fix Thumb code by using proper label type Message-ID: <20220727105924.GQ1146598@bill-the-cat> References: <20220712110023.3163770-1-andre.przywara@arm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="k6xMYE33oZlJwKGP" Content-Disposition: inline In-Reply-To: <20220712110023.3163770-1-andre.przywara@arm.com> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --k6xMYE33oZlJwKGP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 12, 2022 at 12:00:23PM +0100, Andre Przywara wrote: > The generic ARM relocate_code function was using its own function entry > point as a relocation base, and it was obtaining that address by using > the "adr" instruction on that entry point label. > However that label is not just an ordinary label, instead we explicitly > mark it as a function start address. Normally that doesn't change much > (other than for debugging), but when assembled in Thumb mode, newer > versions of the GNU assembler prepare everything for this address being > used as the argument to a "bx" call, so make sure bit 0 is set in there > to mark this function as Thumb code. Of course this doesn't end up very > well when we use this address for the ensuing memcpy operation. >=20 > To avoid this problem, and to solve it in a robust way, add an extra > label, which is not marked as a function entry, and use that for the adr > instruction. This lets all assemblers generate the right immediate offset > in the "adr" instruction. >=20 > This fixes in particular ARMv7-M ports when using GNU binutils v2.37 or > newer (commit d3e52e120b68 seems to trigger the change in behaviour). >=20 > Signed-off-by: Andre Przywara > Reported-by: Jesse Taube Applied to u-boot/master, thanks! --=20 Tom --k6xMYE33oZlJwKGP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmLhGokACgkQFHw5/5Y0 tyzKVgwAsK4NvdR+MYUhVDJ9VVgevxlOP7LeTPUoAXpVSfCpqy2VUdCf7h7CL/fS CoLuMS8zkQFu1IbZNClVLnzGPLgxLtYBF+wKi8ZTGlRr1Fv42MnG1IAwRMrcEuQ1 EaIMHCL/YDzgDG7L+3uFKZNvbbxmMtnq+PhNcDxh7JPxeL1w34ajZQ/rpCOx/I0X adzF4idWhYfw8dO9KgCcpJRAWveGC51o8C6f0l2w5TCQp/tvqNrZBzjXHoWcIYS6 J6gWqjXykvxPcLYEcCBEKLVWMAMWan2pCW1U/unlNX1tZVk3ISDrbcHUTSryr42o 0x5foOUyfiPKpgm2oBih4R1hQkfXWgS3MDUz/+hwnzxXu4agNN1GoEOSIP6yYAr6 jibv9xizD9miaEm3scuOOFBPPzpW4AyHDGXiTuptQJKtiysyXtjgD5PNC4eXVydl P3E1DeZcqIFNBnD8pKHyNxoIGtOycodfaErjeAZEcNeWRq+DleNa8UD+vJ6j6oYG LWlpGvOI =xbkK -----END PGP SIGNATURE----- --k6xMYE33oZlJwKGP--