From: David Gibson <david@gibson.dropbear.id.au>
To: Lukasz Gut <lgut@lgut.eu>
Cc: sbrivio@redhat.com, sevinj.aghayeva@gmail.com, passt-dev@passt.top
Subject: Re: [PATCH v2 4/4] mbuto: Automatically add links related to linker
Date: Mon, 23 Sep 2024 13:54:41 +1000 [thread overview]
Message-ID: <ZvDmgXpZb96-vNGb@zatzit.fritz.box> (raw)
In-Reply-To: <20240918101532.85299-6-lgut@lgut.eu>
[-- Attachment #1: Type: text/plain, Size: 2711 bytes --]
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.
>
> 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 => /usr/lib64/ld-linux-x86-64.so.2
> (0x000077457d5ec000)
> ldd /usr/lib/libc.so.6
> /usr/lib/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2
> (0x000075d218b8b000)
>
> 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.
>
> Signed-off-by: Lukasz Gut <lgut@lgut.eu>
> ---
> mbuto | 28 +++++++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/mbuto b/mbuto
> index 4f860cd..7d67160 100755
> --- a/mbuto
> +++ b/mbuto
> @@ -668,6 +668,27 @@ libs_dlopen_copy() {
> done
> }
>
> +# libs_add_links() - Rebuild alternate links to ld as they appear on the host
> +# $1: String returned by ldd in form 's => d' describing location of ld
> +libs_add_links() {
> + __ld_path="${1##*=> }"
> + __ld_link="${1%%=>*}"
> + [ -z "${__ld_link}" ] && return
> + [ "${__ld_path}" = "${__ld_link}" ] && return
> + while [ "${__ld_link}" != "/" ]; do
> + if [ -L "${__ld_link}" ]; then
> + __target="$("${READLINK}" -f "${__ld_link}")"
> + __link="$("${REALPATH}" -s "${__ld_link}" --relative-to "/")"
> + __link="${wd}"/"${__link}"
> + [ -L "${__link}" ] && break
> + __destdir="$("${DIRNAME}" "${__link}")"
> + "${MKDIR}" -p "${__destdir}"
> + "${LN}" -s "${__target}" "${__link}"
> + fi
> + __ld_link="$("${DIRNAME}" "${__ld_link}")"
> + done
> +}
> +
> # __libs_copy() - Recursively copy shared dependencies for programs, libraries
> # $1: Host path to program or library
> __libs_copy() {
> @@ -716,8 +737,13 @@ __libs_copy() {
>
> 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 => /usr/lib.
> + libs_add_links "${__ld_so}"
> }
>
> # libs_copy() - Call __libs_copy with tabs and newlines as IFS
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-09-23 3:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-18 10:12 [PATCH v2 0/4] mbuto: Make it work on Arch Linux Lukasz Gut
2024-09-18 10:12 ` [PATCH v2 1/4] mbuto: Pick a src when ld reported as link by ldd Lukasz Gut
2024-09-23 3:51 ` David Gibson
2024-09-23 10:09 ` Lukasz Gut
2024-09-18 10:12 ` [PATCH v2 2/4] mbuto: Use realpath to copy ld Lukasz Gut
2024-09-23 3:53 ` David Gibson
2024-09-23 10:09 ` Lukasz Gut
2024-09-18 10:12 ` [PATCH v2 3/4] mbuto: Don't try to add ld when adding libraries Lukasz Gut
2024-09-18 10:12 ` [PATCH v2 4/4] mbuto: Automatically add links related to linker Lukasz Gut
2024-09-23 3:54 ` David Gibson [this message]
2024-09-23 10:09 ` Lukasz Gut
2024-09-23 3:45 ` [PATCH v2 0/4] mbuto: Make it work on Arch Linux David Gibson
2024-09-23 10:09 ` Lukasz Gut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZvDmgXpZb96-vNGb@zatzit.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=lgut@lgut.eu \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
--cc=sevinj.aghayeva@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).