From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202408 header.b=IHt7sbg9; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 140375A004E for ; Mon, 23 Sep 2024 05:54:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1727063686; bh=NxpCfseS5hw1VDUg7KsVsTtFsUJkFoAGkyykadpfAao=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IHt7sbg97QXwaqqnFFmNptxYQj/NSFJVsS8q61tZBxi1aJp/XghU6D/hkQ95aPtl2 rywYOlzsx6iaypWYnXAJud6do2fPevF6D4BEri4HdCPUbu0jFFW2OsXItGgp98sET1 LPwRBxHoH4ySOPhZxoubHc/mZNH6B/HYFDmNHGc68tp3aUN4PP5oHws4mNfaD7yj73 mXBBLc1KxWE9FaUZsn3uYM4wMI8jOcPCfdjxkf6TfLGTXDAd/At0RQSTmYQvsejwDT GvD88NnBI1h9AGCxkP8A+zhIl8Kho3N4DrvkMPEb6xvWeO2w7lLzNl45Jje7ewRImk 91dH4AR+VX+qQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XBpzB4Hllz4x4c; Mon, 23 Sep 2024 13:54:46 +1000 (AEST) Date: Mon, 23 Sep 2024 13:54:41 +1000 From: David Gibson To: Lukasz Gut Subject: Re: [PATCH v2 4/4] mbuto: Automatically add links related to linker Message-ID: References: <20240918101532.85299-1-lgut@lgut.eu> <20240918101532.85299-6-lgut@lgut.eu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1PMNJlu7icUo019x" Content-Disposition: inline In-Reply-To: <20240918101532.85299-6-lgut@lgut.eu> Message-ID-Hash: 25W3654Z4IMUPXSU5YIZLMDQIVHKVHWR X-Message-ID-Hash: 25W3654Z4IMUPXSU5YIZLMDQIVHKVHWR X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, sevinj.aghayeva@gmail.com, passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --1PMNJlu7icUo019x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 18, 2024 at 12:12:59PM +0200, Lukasz Gut wrote: > Fix dynamic linking on Arch Linux by adding (some of) missing links. >=20 > The ldd reports linker in many ways: > ldd /usr/lib/libreadline.so.8 > /usr/lib64/ld-linux-x86-64.so.2 (0x000071244211c000) > ldd /bin/sh > /lib64/ld-linux-x86-64.so.2 =3D> /usr/lib64/ld-linux-x86-64.so.2 > (0x000077457d5ec000) > ldd /usr/lib/libc.so.6 > /usr/lib/ld-linux-x86-64.so.2 =3D> /usr/lib64/ld-linux-x86-64.so.2 > (0x000075d218b8b000) >=20 > This patch looks at the left side and determines if there is a link > there, then adds it. Again, having this be specific to ld.so looks bogus to me. AFAICT the same considerations could apply in theory to any shared library. >=20 > Signed-off-by: Lukasz Gut > --- > mbuto | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) >=20 > diff --git a/mbuto b/mbuto > index 4f860cd..7d67160 100755 > --- a/mbuto > +++ b/mbuto > @@ -668,6 +668,27 @@ libs_dlopen_copy() { > done > } > =20 > +# libs_add_links() - Rebuild alternate links to ld as they appear on the= host > +# $1: String returned by ldd in form 's =3D> d' describing location of ld > +libs_add_links() { > + __ld_path=3D"${1##*=3D> }" > + __ld_link=3D"${1%%=3D>*}" > + [ -z "${__ld_link}" ] && return > + [ "${__ld_path}" =3D "${__ld_link}" ] && return > + while [ "${__ld_link}" !=3D "/" ]; do > + if [ -L "${__ld_link}" ]; then > + __target=3D"$("${READLINK}" -f "${__ld_link}")" > + __link=3D"$("${REALPATH}" -s "${__ld_link}" --relative-to "/")" > + __link=3D"${wd}"/"${__link}" > + [ -L "${__link}" ] && break > + __destdir=3D"$("${DIRNAME}" "${__link}")" > + "${MKDIR}" -p "${__destdir}" > + "${LN}" -s "${__target}" "${__link}" > + fi > + __ld_link=3D"$("${DIRNAME}" "${__ld_link}")" > + done > +} > + > # __libs_copy() - Recursively copy shared dependencies for programs, lib= raries > # $1: Host path to program or library > __libs_copy() { > @@ -716,8 +737,13 @@ __libs_copy() { > =20 > if [ -n "${__ld_path}" ]; then > libs_copy_ld_so "${__ld_path}" > - libs_path_add "${__ld_path##${wd}}" > + libs_path_add "${__ld_path##"${wd}"}" > fi > + > + # On Arch Linux, to execute /bin/sh, the system expects the linker > + # to be under /lib64. Linker is located in /usr/lib, and there is > + # a link /lib64 =3D> /usr/lib. > + libs_add_links "${__ld_so}" > } > =20 > # libs_copy() - Call __libs_copy with tabs and newlines as IFS --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --1PMNJlu7icUo019x Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmbw5oAACgkQzQJF27ox 2Gc55BAAo+No3i5Dhrgbw6CxxpWb++P0iBUVNx5FK3WJwNdxJNomiyVYEQI2x5gK OVhZbVcG24JoycQeinCBP+O2O4AeWhyU7dpoRS2iqTH1v5fqtvV8djZz7ECdldA3 KRRVP+/2owuD6Cio38Qa8y//VSc3aaJXP0aePYacOY7ve2Ds6k3B3Yf3InM0QHOD 40hU+YPLkR1Po9ZOeZHXL1yjvo98PBOXDsAvvFAr01yvxUdWY6n1pUmdBzqXAmCO D6K0e00NAu664mQRCLFQ5PC2kwgjkz0kkWzHVwaXCr8q9abfijX4WmTI8/DUOFAU KaRCBwkaz4bZHu2hSQetHBNVC+BJDv3reJ3WS7J2RKsEvO7ozhVkNwCOTAzeHKsK Vn9aiS3PmilqSsBNNRWY2AkzdGerZjmaNnEGkyqm0Br4Ct11efJPNYZsN5j80l2v bUpcoC69TCnB8ltY0ibtp4KS9HPU3T7GYhifeXErTzM5oeQL3y9MHoSUyuDFwQzd AWxmRI0iFntW7K7qruiqsHOzaaj3L2YS3JiaZ7Q19Z6UGeigwwnX6VL+qzSy7qpo GWpL6KSoDZdPXeA7kI/xMGqJ4VH/M2Hw0ijdd8DJwH7h22SguMEQ9SPs+r4kV2eQ kMqSbZd/UVXJ4HkQG+cIb+xzabagr6plxi2cPTJTvuo85434bp0= =E+3S -----END PGP SIGNATURE----- --1PMNJlu7icUo019x--