From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by sourceware.org (Postfix) with ESMTPS id E4B603858414 for ; Wed, 8 Sep 2021 19:19:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E4B603858414 Received: by mail-qv1-xf2a.google.com with SMTP id 62so1999065qvb.11 for ; Wed, 08 Sep 2021 12:19:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FchRKcxD5QpLYCP6Ps+BXFhbDUQ53hdsFbtTGNeaPsE=; b=WCjYpQutB3W6Tcm2kAyAlGEUFXYtiVYh/scAqgYZClBvZl3bZwB4nZ0zTAZzMdn53G RKxBSmknlapBH6rKAR1pg0VfbPW/14IZvW2FIe9BvFcKhZLXQB0I6ffosIGV2LCjrjnD 12v2eWaCSsgpoB+ZEDw7Hx8uccfwT938HmUn3/u0Y/x6Jg7W3tPs29nob1l4+zf0xQUa nVNFpMCflJ2gV66YoqiQmUeX3ArT0CC2V+0OW+9ePHRboaOmOF8M9w80qOC+CGSKEgVa pXAXynmw0G3N7sKtvvUzwjvwzarvh/h2I9FZnNzOYWOZaoDGkGN3NzETTpClpHS8EC27 gFjQ== X-Gm-Message-State: AOAM5305u+Y/sgs83Ar2rcFo6ZMDR4WmEbMRmIIZK6qvTzcEEm3hYR25 WXBK+c6Pc/RpavrCBATXBPpvVMBkpvyjfQ== X-Google-Smtp-Source: ABdhPJz7AK4LTRYjQxYL7QNemOD9IV1CGiv7VvNX5vx1pYQjB1iTEQ2slmHgr5gw4ZVWeYOY361Gkg== X-Received: by 2002:ad4:5990:: with SMTP id ek16mr5511298qvb.30.1631128789140; Wed, 08 Sep 2021 12:19:49 -0700 (PDT) Received: from ?IPv6:2804:431:c7cb:733d:a4ea:9de2:51ec:4b77? ([2804:431:c7cb:733d:a4ea:9de2:51ec:4b77]) by smtp.gmail.com with ESMTPSA id x3sm6474qkx.62.2021.09.08.12.19.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Sep 2021 12:19:48 -0700 (PDT) Subject: Re: [PATCH] dl: Use "adr" assembler command to get proper load address To: Lukasz Majewski , Fangrui Song Cc: Florian Weimer , Joseph Myers , Carlos O'Donell , libc-alpha References: <20210907131616.23472-1-lukma@denx.de> <20210907164906.yt6nonvfyhvbrx6p@google.com> <20210907193227.6047f9cc@ktm> <20210907174417.sctsswphsyae4mpc@google.com> <20210908170524.4be44bf0@ktm> From: Adhemerval Zanella Message-ID: <16812ef5-e21b-ba69-7ee7-a0c5a094ad01@linaro.org> Date: Wed, 8 Sep 2021 16:19:46 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210908170524.4be44bf0@ktm> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2021 19:19:52 -0000 On 08/09/2021 12:05, Lukasz Majewski wrote: > > The r1 gets the 0xffffee80 (negative offset) value. It is then added to pc > and used to calculate r2. > > For working code (with this patch applied) - there are NO such large > values (like aforementioned 0xffffee80). The arithmetic is done on > > 1690: 00000020 .word 0x00000020 > 1694: 0002be7e .word 0x0002be7e > > which seems to work. > > This shouldn't be a problem as with U2 the arithmetic shall work. > However, I've noticed (with passing LD_DEBUG=all) that the > ld-linux-armhf.so.3 (and init) are relocated twice before execution. > > Why do we need to relocate it? > > Another question is why on this particular case the large (i.e. > negative) offset matters? I think it is highly unlikely the negative offset plays any role here. Do you have a working example to trigger this issue? I am currently testing arm for different compilers (gcc 6.2, gcc 10, gcc 11) and with different configurations (armv5, armv6, armv7, with and without thumb) and I haven't see any issue so far. It might binutils related, which version are you using?