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 B823CC43334 for ; Mon, 11 Jul 2022 16:16:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6FE1E8401B; Mon, 11 Jul 2022 18:16:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QKfDzoSk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73CC784044; Mon, 11 Jul 2022 18:16:19 +0200 (CEST) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (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 A052D83FEA for ; Mon, 11 Jul 2022 18:16:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.bossman075@gmail.com Received: by mail-qk1-x72f.google.com with SMTP id l26so4183080qkl.10 for ; Mon, 11 Jul 2022 09:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:in-reply-to :content-transfer-encoding; bh=wXlEbWrI49g2eS/leBk4Xbj9qyC/2CbftQcZ7ArhSJI=; b=QKfDzoSkxoHed3Vv8JAGnBZEcbP+QGxLgq9TDh8CmAnSFWx8KNYMIJEc3VmlEPHIWD CUpphuMvD0zxo5CqImn+m9zIcdPROs08rKYldLHclN0zsaSorfMQeqHfC1/OngnbQBQm AM+3qrqTaKFRREBB4rlv/HcHKZhlUJBn1QTfa6ZYB0A0/DzsbvKXZxO2tENrG+FIqjy5 mnt9ETxihxOhxBEJNrqHziM5zscquPIKxRBbV0uOjROPrfscud1q9ldjdUg650TZ/G9w Ef1t17nmrFTTpRAebP4nyYodoUKpJc9XHpBbmAB/gc8ytdtCJILq0UhzJQKAnRSUvsvF czAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:in-reply-to :content-transfer-encoding; bh=wXlEbWrI49g2eS/leBk4Xbj9qyC/2CbftQcZ7ArhSJI=; b=vF0/iOoFi/Z9isWlN6kbpa52h7jqanSYYtWVvvRoOXlLoQM0/4Rh4ilXU6sgRvzHcL KfHvxvJaHYRy+n4+alQxxO4/7FGrZw8Jlv+ArLCFuXQePs5BCoS0spZ3EC5AsJkMDVBS daMC+BqElMKLU15Pcsj0vgKaQFe3VIVPMEZQQ1VzZnz/C2hBukJVHU6wiJENwu1grxjr 9T8e3mJ163/FU18A/S3r8EiM3EjqFEX4U+YDxJf+hriFYyaCisL9D2Hj34sX+Nk26u/y yLUWD8aqKkAQuQ9vZAaOrzUIKQAQWLVK3512+uS1kNe0BKMyvngtcBBFB0y/5PjmG4IK jWTg== X-Gm-Message-State: AJIora/bDYDjCmD1XYiI2czl37IZW/v4KUc3vna+phoUwTXshn8N8Hu7 kOAkSoqoGtkGXJwo9xG525M= X-Google-Smtp-Source: AGRyM1uFQsor46u27mqsXZvJPnJBeff5UskwQtP8CnohX627xm2actBnjzdOUCnUeLpX5JwHFve/jg== X-Received: by 2002:a05:620a:1e3:b0:6af:504d:c1f2 with SMTP id x3-20020a05620a01e300b006af504dc1f2mr12159013qkn.34.1657556175056; Mon, 11 Jul 2022 09:16:15 -0700 (PDT) Received: from [10.4.50.83] (146-115-144-188.s4282.c3-0.nwt-cbr1.sbo-nwt.ma.cable.rcncustomer.com. [146.115.144.188]) by smtp.gmail.com with ESMTPSA id a15-20020ac8108f000000b0031e9ff0c44fsm5483778qtj.20.2022.07.11.09.16.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jul 2022 09:16:13 -0700 (PDT) From: Jesse Taube X-Google-Original-From: Jesse Taube Message-ID: <86016465-2277-c296-32ae-d6a694ea7eb8@gmail.com> Date: Mon, 11 Jul 2022 12:16:11 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v1] arm: relocate: Replace ADR instruction with non-pseudo-instruction Content-Language: en-US To: Andre Przywara Cc: u-boot@lists.denx.de, trini@konsulko.com, sbabic@denx.de, festevam@gmail.com, festevam@denx.de, giulio.benetti@benettiengineering.com, sjg@chromium.org References: <20220710070953.933688-1-Mr.Bossman075@gmail.com> <20220711135740.0eb67b22@donnerap.cambridge.arm.com> In-Reply-To: <20220711135740.0eb67b22@donnerap.cambridge.arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 7/11/22 08:57, Andre Przywara wrote: > On Sun, 10 Jul 2022 03:09:53 -0400 > Jesse Taube wrote: > > Hi Jesse, > >> In Binutils 2.37 the ADR instruction has changed >> use alternate instructions. > > Can you elaborate on this? What has changed exactly, and why? Looking at > the commit you mention below I don't see an immediate problem that would > require code changes? Also it speaks of forward references, but this one > is not one? > And I didn't spot any difference between 2.38 and 2.35, at least not in my > isolated test (but I didn't bother to compile a whole stage 1 GCC with > newer binutils yet). > >> The change causes armv7-m to not boot. > > What does "causes armv7-m to not boot" mean? It compiles fine, but hangs > or crashes? well when we reallocate it doesn't copy the whole instruction so its an invalid instruction and boot loops. > Can you show the relevant disassembly from both binutils versions? > > And from trying to reproduce this minimally, do we need a ".syntax unified" > in the .S file? Yes its required. sorry i didn't post the test code here... The test code is as follows ``` .syntax unified .global bug; .align 4 bug: adr r3, bug .size bug, .-bug .type bug 2; // This changes offset from 4 to 3 in include/linux/linkage.h:ENDPROC //arm-linux-gnueabi-as -march=armv7-m -c -o bug.o bug.S && arm-linux-gnueabi-objdump --disassemble=bug bug.o ``` > >> Signed-off-by: Jesse Taube >> --- >> arch/arm/lib/relocate.S | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/lib/relocate.S b/arch/arm/lib/relocate.S >> index 14b7f61c1a..22c419534f 100644 >> --- a/arch/arm/lib/relocate.S >> +++ b/arch/arm/lib/relocate.S >> @@ -78,7 +78,13 @@ ENDPROC(relocate_vectors) >> */ >> >> ENTRY(relocate_code) >> - adr r3, relocate_code >> +/* >> + * Binutils doesn't comply with the arm docs for adr in thumb2 >> + * from commit d3e52e120b68bf19552743fbc078e0a759f48cb7 onward >> + * to remove ambiguity explicitly define the pseudo-instruction >> + */ >> + mov r3, pc >> + subs r3, #4 > > But this will break ARM, won't it? Because it would require to subtract #8? > I mean there is a reason for this adr instruction, because this offset > calculation is best left to the assembler. Not to speak of the fragility > of assuming that the relocate_code label is pointing to the very first > instruction. The ENTRY macro could also insert instructions. > > Cheers, > Andre > >> ldr r1, _image_copy_start_ofs >> add r1, r3 /* r1 <- Run &__image_copy_start */ >> subs r4, r0, r1 /* r4 <- Run to copy offset */ >