From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by sourceware.org (Postfix) with ESMTPS id CB7D5385840C for ; Thu, 7 Oct 2021 17:24:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB7D5385840C Received: by mail-yb1-xb29.google.com with SMTP id q189so15092785ybq.1 for ; Thu, 07 Oct 2021 10:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NRgxE38HRwObvo+sE6vFXIfh+fEEhL7pLtB0Sd7xEx4=; b=W9ToItRu1IMoKWjsBeqTqLnY20hdGDbOc/1jdx0yDn6YzvsQS9okReLSDF4ai960pb 8qlKqBBrfPHJ8FIug5gCgrCvDszqdmcaV7a28/CKewWGkl444s9IHzGdm3wtbdAg/ctm Q5PrAs9t0NaptpT/8s33Y/qmNXdNGEcnENvI0EJQdixZ7WVCJU2k9EMyoBIBZjTZ4ArW z2nuMxFxwzmCu10s8NLofIuWI1nB10/WUlkVDRnJcAvh+dLz8wXO9kbUaJcpf0TvIxLi Jsy4lZwExfwGFdT33H7egARRxsGWULyuGp4ilZtYm5idmskF0wKD+7rCwj0F9HTETY8q J5eA== X-Gm-Message-State: AOAM533M4fVEZRwVUyFdO95UgVXiuyZCEHyhzCUklOCNjsBR+5ZybIXz kfqQJ23PxD4F6ZSGM/9/+YhB9Bt9xWSwAG76uqBNvQ== X-Google-Smtp-Source: ABdhPJybK+lFgP2VzxLQDXH4vY12+fFHIvl9LY+mWtOLdIIIHmaPt71O3hjlROGLozs2qYfM6e/2D6dPGT50iBc24y8= X-Received: by 2002:a25:d06:: with SMTP id 6mr5948212ybn.519.1633627474182; Thu, 07 Oct 2021 10:24:34 -0700 (PDT) MIME-Version: 1.0 References: <20210907174417.sctsswphsyae4mpc@google.com> <20211005094554.2f28d6bd@ktm> <20211006075721.qnv6qabroytcsido@google.com> <20211006110321.5f1a9610@ktm> <20211006134344.63395242@ktm> <20211006125517.GE2700@arm.com> <20211007111926.30db4c4f@ktm> <20211007120038.1445bbd3@ktm> <44bac775-3127-7bc7-c4ea-fa282ed277d3@linaro.org> <20211007155730.GG2700@arm.com> In-Reply-To: From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Thu, 7 Oct 2021 10:24:22 -0700 Message-ID: Subject: Re: [PATCH] dl: Use "adr" assembler command to get proper load address To: Adhemerval Zanella Cc: "H.J. Lu" , Szabolcs Nagy , Florian Weimer , Andreas Schwab , libc-alpha , Joseph Myers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.8 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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: Thu, 07 Oct 2021 17:24:36 -0000 On Thu, Oct 7, 2021 at 9:54 AM Adhemerval Zanella via Libc-alpha wrote: > > > > On 07/10/2021 13:22, H.J. Lu wrote: > > On Thu, Oct 7, 2021 at 8:57 AM Szabolcs Nagy wrote: > >> > >> The 10/07/2021 07:29, H.J. Lu via Libc-alpha wrote: > >>> On Thu, Oct 7, 2021 at 7:18 AM Adhemerval Zanella via Libc-alpha > >>> wrote: > >>>> On 07/10/2021 07:00, Lukasz Majewski wrote: > >>>>> On Thu, 7 Oct 2021 11:19:26 +0200 > >>>>> Lukasz Majewski wrote: > >>>>> And indeed it is the case. Yocto/OE by default perform prelinking (use > >>>>> prelink program) to speedup start time of dynamic program. > >>>>> > >>>>> The prelink [1] itself assigns some virtual addresses to all required > >>>>> shared objects (in our case for /sbin/init), so no clashes are > >>>>> encountered. > >>>>> > >>>>> And using prelink is a _default_ behaviour in Yocto/OE poky distro. > >>>> > >>>> Does it work without prelink? Also, does it fail with prelink in real > >>>> hardware? > >>>> > >>>> It indeed might be a prelink issue in fact. > >>> > >>> This will fail everywhere if prelink is used. > >> > >> i thought the point of prelinking is that the vaddr in > >> the elf image is the runtime address so you don't have > >> to process relative relocs or adjust pointers in the > >> dynamic array with += l_addr at all (and then l_addr > >> does not have to be correct, ld.so would still work). > >> > >> but here ld.so is loaded to some random offset on top > >> of the static prelink offset. is this expected? > >> does it make sense to prelink ld.so this way? > > > > ld.so is loaded by the kernel. It makes no sense to > > prelink ld.so. > > > > The question is whether we consider this a regression or if > we don't support it and instruct consumers to not do it. &__ehdr_start was used long before "elf: Unconditionally use __ehdr_start" https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=elf/rtld.c;h=878e6480f4980b2fef468d8e271cd68acd4fc2d0;hp=d733359eaf808b8a5579908a6cd1153062c02919;hb=302247c89121e8d4c7629e589edbb4974fff6edb;hpb=13710e7e6af6c8965cc9a63a0660cb4ce1966557 It is surprising if that code could do something useful with prelinking.