From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by sourceware.org (Postfix) with ESMTPS id 5509E3858D28 for ; Mon, 11 Oct 2021 11:47:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5509E3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=denx.de Received: from ktm (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 0D56582B68; Mon, 11 Oct 2021 13:47:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1633952864; bh=BjT9fILA1olL3niMN/nIslHoEf34/MLrqKKjSRta7Ns=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vM5rTjDmzrjldgZm1gIxPSD/dZe1m6YQjCWVEBJ7ML93PD8wQKRVPWowwDSMOf1hq z7mQozBK7Wyhl04h5GY0ITMnJlD7LZI2050ANwxuN8Nw7yW2QrXm6gOlPGmDolrfQu oJbQEU7Ihc6LxWAX0PdgFct9ImXMi/c7OpsK8MWU9IctLNvbsSnIZS7PsnMFDz2qnX YJUzy9Ytd007ESeuAaw+eP/T/5pZyVkVqn09z5GVt0tBr8wCmramLGNgHuhCwezsew 1FYE7SJyR/Liee/rTZkdw+MMASTh8lFQZTLiHUX1HAb63EwzwVmV2qDdaTK/VZ3ikw U3OLqdvA/bUBA== Date: Mon, 11 Oct 2021 13:47:36 +0200 From: Lukasz Majewski To: Szabolcs Nagy Cc: "H.J. Lu" , Adhemerval Zanella , Florian Weimer , libc-alpha , Andreas Schwab , Joseph Myers Subject: Re: [PATCH] dl: Use "adr" assembler command to get proper load address Message-ID: <20211011134736.57e763ba@ktm> In-Reply-To: <20211011101839.GJ2700@arm.com> 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> Organization: denx.de X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/t1yClcWgLSSRkjueC1b9CP_"; protocol="application/pgp-signature" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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 11:47:48 -0000 --Sig_/t1yClcWgLSSRkjueC1b9CP_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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... > >=20 > > The approach with using 'adr' (pseudo) assembler instruction to > > calculate the on-runtime addresses was working previously. > >=20 > > Shall we revert changes which were introduced recently (to use > > __ehdr_start)? =20 >=20 > the reason for the change was to avoid relying on GOT[0]. And why it is requested to not relying on GOT[0]? >=20 > 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. >=20 > 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!=3D0 for ehdr then i think it can be (untested): >=20 > __attribute__ ((const)) ElfW(Addr) > load_addr (void) > { > extern const ElfW(Ehdr) __ehdr_start __attribute__ ((visibility > ("hidden"))); ElfW(Addr) addr =3D (ElfW(Addr)) &__ehdr_start; > ElfW(Word) phnum =3D __ehdr_start.e_phnum; > const ElfW(Phdr) *phdr =3D (const void *) (addr + > __ehdr_start.e_phoff); const ElfW(Phdr) *ph; > assert (__ehdr_start.e_phentsize =3D=3D sizeof *phdr); > for (ph =3D phdr; ph < &phdr[phnum]; ++ph) > if (ph->p_type =3D=3D PT_LOAD && ph->p_offset =3D=3D 0) > { > addr -=3D 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; > } >=20 > 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. (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 --Sig_/t1yClcWgLSSRkjueC1b9CP_ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmFkJFgACgkQAR8vZIA0 zr3qRwf/XroTSZTz9q/GVBHEUfW9cWGq/P70TPHfo6SrOSzKqvWAHhsTXZ7kxacl 1pzYlyrx3+G5S6PHeZQL/2Veytis4jZwIzViNcSUORiMGfS48lygnlI+s3deR3Ke c+MWL9XrbkGOZscps0opbZ49F02/4VXzAWJ4HfMAWHqXUpi7SXmPW2yjAgKgWWYq 3iEzCpoyAF+n3tHOiN+YSxGOu/ODHfOft5glqQ8siW8o5hRUUd6xDWWBN4ZfKMGl Gr14BFtPlyTdAzLvw9nhp0HVvPnudKMWlOgbVCE/czepEpbtcX2TKOzgkmMsAd0j 9araWpVaol8gRovVDebK17TiUS66NA== =AEBv -----END PGP SIGNATURE----- --Sig_/t1yClcWgLSSRkjueC1b9CP_--