From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id BDF3C385800C for ; Mon, 11 Oct 2021 12:02:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BDF3C385800C Received: by mail-pf1-x433.google.com with SMTP id x130so5689085pfd.6 for ; Mon, 11 Oct 2021 05:02:00 -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=nO2jaJ1SNn68VnwcVNih/lesAuE64LtfcNQvpcRnxAY=; b=JgRjPbzo5aezU/Vy6Q/V4M/LuY8fZ6UE33wyJBdjQHuGd1S4Sk65hQCzdJWpEhQ7qE won3AlN33tAHtEW86I+/Z5PioUiJyOfoz9G1hmcZtp1VZzxtyrpl+vRwNUHiMoSOKi6L udxK3rKyjiWHEJpFLuenDnehWZrDJPzmDj+mDEHEUvYaJnJT5XQnqGfW9m8/pAoAdT87 H1wuIhpoXQnA5g8cG5geN3QImtXnFnD8canD4FBvUfBlcch+SIG4WllMNfqWfWzL+sNL kQhz5VxUzH23xUTJdFcDu+rpMd8FXNHSaYAwTfTIb125LpiELXr3b9WgvueWvPTFC/zH edmw== X-Gm-Message-State: AOAM532vQ7+z3vstiwfe0pjpuEngiuSgi+kHSZ8Oq8cP9EsT6P2Er4x2 OF4oU7QPj61/gTNyJIjN5QE89P7tXJg0hp6wSW3+rM+D X-Google-Smtp-Source: ABdhPJzSvwCc80hnXJIDCGsg+pRMF+4ky3SqkPOS62sVRO86hoK4gD3XAXZAMHg4eHqHBX25fLBQttWOqfRsNAORVT8= X-Received: by 2002:a63:35c6:: with SMTP id c189mr3639871pga.75.1633953719642; Mon, 11 Oct 2021 05:01:59 -0700 (PDT) MIME-Version: 1.0 References: <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> <20211011105617.5bcd493d@ktm> <20211011101839.GJ2700@arm.com> <20211011134736.57e763ba@ktm> In-Reply-To: <20211011134736.57e763ba@ktm> From: "H.J. Lu" Date: Mon, 11 Oct 2021 05:01:23 -0700 Message-ID: Subject: Re: [PATCH] dl: Use "adr" assembler command to get proper load address To: Lukasz Majewski Cc: Szabolcs Nagy , Adhemerval Zanella , Florian Weimer , libc-alpha , Andreas Schwab , Joseph Myers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3024.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: Mon, 11 Oct 2021 12:02:06 -0000 On Mon, Oct 11, 2021 at 4:47 AM Lukasz Majewski wrote: > > Hi Szabolcs, > > Thank you very much for your input. > > > The 10/11/2021 10:56, Lukasz Majewski wrote: > > > Do we have _any_ plan how to fix it? BSPs for many boards are built > > > with Yocto/OE nowadays... > > > > > > The approach with using 'adr' (pseudo) assembler instruction to > > > calculate the on-runtime addresses was working previously. > > > > > > Shall we revert changes which were introduced recently (to use > > > __ehdr_start)? > > > > the reason for the change was to avoid relying on GOT[0]. > > And why it is requested to not relying on GOT[0]? > > > > > i guess we can revert elf_machine_load_address on arm, but > > keep the new elf_machine_dynamic that does not rely on GOT[0]. > > This was the approach proposed by this patch. > > > > > it is also useful to have the same c code across targets > > for the load address. if we want to do that and support > > vaddr!=0 for ehdr then i think it can be (untested): > > > > __attribute__ ((const)) ElfW(Addr) > > load_addr (void) > > { > > extern const ElfW(Ehdr) __ehdr_start __attribute__ ((visibility > > ("hidden"))); ElfW(Addr) addr = (ElfW(Addr)) &__ehdr_start; > > ElfW(Word) phnum = __ehdr_start.e_phnum; > > const ElfW(Phdr) *phdr = (const void *) (addr + > > __ehdr_start.e_phoff); const ElfW(Phdr) *ph; > > assert (__ehdr_start.e_phentsize == sizeof *phdr); > > for (ph = phdr; ph < &phdr[phnum]; ++ph) > > if (ph->p_type == PT_LOAD && ph->p_offset == 0) > > { > > addr -= ph->p_vaddr; > > The above line is a bit strange for me. Isn't the p_offset set by > prelink as well? > > And most of all - why do we need to perform relocation in such very > early stage of the ld-linux-armhf.so.3 ? > > > break; > > } > > return addr; > > } > > > > i don't have a strong preference either way: > > 1) fix yocto > > Yocto by default uses prelinkg from the very long time. I think that it > would be very difficult to change that. Just don't run prelink on ld.so since the load address is controlled by kernel. > (moreover, IMHO running prelink on any binary and glibc is a valid use > case) > > > 2) partial revert > > Ok. > > > 3) new way to compute the load address. > > This would require some input from developers deeply involved in ELF > loader development. (Florian IIRC). > > Best regards, > > Lukasz Majewski > > -- > > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de -- H.J.