From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=lgut.eu Authentication-Results: passt.top; dkim=pass (2048-bit key; unprotected) header.d=lgut-eu.20230601.gappssmtp.com header.i=@lgut-eu.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=yremVaNr; dkim-atps=neutral Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by passt.top (Postfix) with ESMTPS id 9AA205A004C for ; Mon, 23 Sep 2024 12:09:19 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5c275491c61so5605794a12.0 for ; Mon, 23 Sep 2024 03:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lgut-eu.20230601.gappssmtp.com; s=20230601; t=1727086159; x=1727690959; darn=passt.top; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=9c4R1g+bac3s4qLLhR0MLYMmmCIJFM00+OqTp9QxZTc=; b=yremVaNr9Giyoh16QaGuiy1Hm8jGf8R6qbrybvcXDFo6ipyNf7vhKA1nVW21vQjUmu XJMOIDxxl2ANoaiAPLcAyo5dbz+wbpMpnqq4/FSEZlEj8dP+2bC7jaJXRe5eXSKxLTF1 NVu86Qaq3QS2hMtm33FZTyTcw5cC4jtlegXFIHcaQZdyk8cbY8uInXDWNYO7eip0IRcP x4X5ykTsq78GC62/bn0U7eNdToBmUYD24UihtYPemx8vE+1kSKNY1y7neVyMNe98SiQm R5LOo5hKbVIaSFUgZoxczeiA0NlxznfVKYejiDLGRfZNNkETh6Rz9aJZP3MIM0l8Gaa6 YoHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727086159; x=1727690959; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9c4R1g+bac3s4qLLhR0MLYMmmCIJFM00+OqTp9QxZTc=; b=TwxdpKuGfkqQdAAR6oWMlmdftjC7gt4lkA//9E4Jv+javPfhOvD202pIhc+B0DE37m 8fvpBqEDeVNPsDM8knt/BANmyki7iNZsjAXynCIkd7Z+m6wlJ3trFvjSBUFktXtGxV4c xOjmIZUhkb/VQBog5achXFQh1xewcCWLVzx6ksO5XkSbnbBPlFudmXjPQbsSdZ9IHIFJ Oaurlgk6PNMXX0ddI7KChw9LWStYPO9zk8IBjP0qBzodlhewuAWBHfMXwtnKwLUObd5I DDUNcWRiEOzMXRgyw4K3f4ZexQk+dDg393xXpouIv5VrULmhn2cXiBYf076oqPfm+OU0 n8rQ== X-Forwarded-Encrypted: i=1; AJvYcCXR6npnlZIeOhYsyha7DcNN3fiVNf7dcKRYd2x0bhDGO5c206SIZEwCAWfk6PoClrOX/DQ8wXBRg5c=@passt.top X-Gm-Message-State: AOJu0YwYgr+/v+AMUqFHLrdKdT5+n3B4jdZkYiiQvoagdMojh0dU3FRJ lkVcMBz3vfBDihCTJdtFjvLbJDHp0kfT9LUA4n2ykeTQuzMppSxUURlFh4bUTY4= X-Google-Smtp-Source: AGHT+IFF7+YyUTynjzqyaMC1duxUDxR6628iy0zV8WkHPggK5x75dyxcW9pXic6V/dCNntTz+9PzpQ== X-Received: by 2002:a17:907:efde:b0:a86:b46b:860a with SMTP id a640c23a62f3a-a90d58ba1a2mr1229941666b.54.1727086158971; Mon, 23 Sep 2024 03:09:18 -0700 (PDT) Received: from [192.168.1.135] (ip-046-005-003-117.um12.pools.vodafone-ip.de. [46.5.3.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9061328dd2sm1186975666b.200.2024.09.23.03.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 03:09:18 -0700 (PDT) Message-ID: Subject: Re: [PATCH v2 4/4] mbuto: Automatically add links related to linker From: Lukasz Gut To: David Gibson Date: Mon, 23 Sep 2024 12:09:17 +0200 In-Reply-To: References: <20240918101532.85299-1-lgut@lgut.eu> <20240918101532.85299-6-lgut@lgut.eu> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.0 MIME-Version: 1.0 Message-ID-Hash: NTILCMZOSHXL54CHI2YD357TYUMJJFIT X-Message-ID-Hash: NTILCMZOSHXL54CHI2YD357TYUMJJFIT X-MailFrom: lgut@lgut.eu 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: On Mon, 2024-09-23 at 13:54 +1000, David Gibson wrote: > 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. >=20 > Again, having this be specific to ld.so looks bogus to me. AFAICT the > same considerations could apply in theory to any shared library. Yes, I will rework it to use a single function for every shared library. >=20 > >=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 t= he 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, l= ibraries > > # $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 -- Lukasz