From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2EF65A0543;
	Wed, 12 Oct 2022 18:16:59 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 2463E4280B;
	Wed, 12 Oct 2022 18:16:59 +0200 (CEST)
Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com
 [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 4DD6740041
 for <dev@dpdk.org>; Wed, 12 Oct 2022 18:16:58 +0200 (CEST)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.46])
 by mailout.west.internal (Postfix) with ESMTP id 084E53200933;
 Wed, 12 Oct 2022 12:16:54 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Wed, 12 Oct 2022 12:16:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 cc:cc:content-transfer-encoding:content-type:date:date:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to; s=fm3; t=1665591414; x=
 1665677814; bh=UDGfWsSyjC+iCIpDp+rVi2mFtvO3e3aWVNqJCU7rV0w=; b=d
 ar/i8fFfAeWC0WwNsZXJ+1Ax2ZGPketFAN9CY/sA3cgTSGjgSZ6q75dN7x5BsoQ2
 Ldi8zBhgC/7yXLIOdQnSkWZgksNFoqwDbkrrgyzo4XJEfPsGqWCQrDW6aHY7ZMjq
 5zTAq24FpF0I47Vbs7fhbN4Dmt/gIvYniDjQgiEMUR+jO8Ok6WGozIR1LAPltiAS
 ftzNc/ObJWErO9IKqyYyZB3f2k6mVeUJuOloU1QRmfe24tqQ5O8KoXJ5Ma1E3cUu
 1Lz7CoiSO8fzVdHUzWkQcMnnfq7nWT52bmzIANBc4rzc4BD7GWJld4eb04Wk8v9Y
 h9pqQr+zUfGFkJUbjJhaQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:date:date:feedback-id:feedback-id:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1665591414; x=
 1665677814; bh=UDGfWsSyjC+iCIpDp+rVi2mFtvO3e3aWVNqJCU7rV0w=; b=o
 Ybh9W26IsvFEXkrOUXA9ktPuKz7sOXEKyS4/8J4bUJrO7ECBzOHP03OhQIThEOwW
 q7QzkxQTR1ExtMo0TDmN7xCoUmBjFWdvCytAF+S0NDHSry/Jp6DtiArE7LYd67pw
 oVg7bV4Xy/EzHGakXCd7nCz7or+TeodXtC0DfXm4c20mArRxDRtWe9MS5LLhynQO
 g4AnzgvJfbtxajkEQPH2SPyM3OS96h38NfMDjY0nfw++k2jQxM2Xy5xG7N8lYxT2
 3hGjvcdGKs9tyE0B+t1FKVFLXqZVzC40AscwGzJRZM8JRpqLUhofE8NE4NKFdnf2
 rN0fUJFdOzEJZL47cicEQ==
X-ME-Sender: <xms:duhGY7SqQJS8faSc8sJEZavvABeG4spIkjV-oG0EwvImU2Ixilvy7Q>
 <xme:duhGY8yCzPbDGZieJ-BGgR_K7jZ-98VJLSxUEFjvKyucwf8PYehoCRCTcgufz9IOE
 HrhWim0gGDNyia2zw>
X-ME-Received: <xmr:duhGYw1RB0bB2qScOFH75WJJDkZwmKsRVsnCSNEr9CgTdxvNBHAWnNQPqLF8paNmsnQ6AzcOCcFBiikvEVkSfwoABw>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejkedguddttdcutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhho
 mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne
 cuggftrfgrthhtvghrnhepkeehieefudetuedvveeuheefteetteegfeekudffieekgfeh
 gedtfeelfffhkeeunecuffhomhgrihhnpegsuhhshigsohigrdhnvghtnecuvehluhhsth
 gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhn
 jhgrlhhonhdrnhgvth
X-ME-Proxy: <xmx:duhGY7Cczqa3e4IUrcj0pOZjJDi969lwuC05AhgpRq8ACg5KiOb9rQ>
 <xmx:duhGY0ibQvUp39qMiq1r84cWrkp9sBEr6OZQOlsTOfQiA0oaaR2GGA>
 <xmx:duhGY_ppJVxSJBx8iqOJF1VfRBrW7kItSm9Fi5BA5IEf_HJIP6MB6Q>
 <xmx:duhGY9tUb5rsPVzhDzR1V_ZCUBh4mge38FeY6K2fjVkMTzN_3wNxvQ>
Feedback-ID: i47234305:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed,
 12 Oct 2022 12:16:53 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: Robin Jarry <rjarry@redhat.com>, dev@dpdk.org,
 Ferruh Yigit <ferruh.yigit@amd.com>,
 Bruce Richardson <bruce.richardson@intel.com>
Subject: Re: [PATCH v7] usertools: rewrite pmdinfo
Date: Wed, 12 Oct 2022 18:16:52 +0200
Message-ID: <25917113.6Emhk5qWAg@thomas>
In-Reply-To: <Y0baaCw7s30cYBL0@platinum>
References: <20220913105811.84384-1-robin@jarry.cc>
 <2415152.uoxibFcf9D@thomas> <Y0baaCw7s30cYBL0@platinum>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

12/10/2022 17:16, Olivier Matz:
> On Tue, Oct 11, 2022 at 12:44:56AM +0200, Thomas Monjalon wrote:
> As discussed off-list with Robin, it appears that "ldd" is not available
> on buildroot-based images. See:
> http://lists.busybox.net/pipermail/buildroot/2013-July/074927.html
> 
> The link is quite old but it seems it's still true today if we don't
> build the toolchain.
> 
> Robin suggested this patch:
> 
> --- a/usertools/dpdk-pmdinfo.py
> +++ b/usertools/dpdk-pmdinfo.py
> @@ -290,8 +290,10 @@ def get_needed_libs(path: Path) -> Iterator[Path]:
>      """
>      Extract the dynamic library dependencies from an ELF executable.
>      """
> +    env = os.environ.copy()
> +    env["LD_TRACE_LOADED_OBJECTS"] = "1"
>      with subprocess.Popen(
> -        ["ldd", str(path)], stdout=subprocess.PIPE, stderr=subprocess.PIPE
> +        [str(path)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env
>      ) as proc:
>          out, err = proc.communicate()
>          if proc.returncode != 0:
> 
> One subtle difference is that the patched version won't work on
> non-executable files, but I don't think it can happen in real-life.
> 
> An alternative for us is to provide a simple "ldd" shell script in our
> buildroot-based images.
> 
> I don't have a strong opinion, I'll tend to say that the patch is a
> better option. Any comment?

What about implementing both?
If ldd is available, use it,
otherwise use LD_TRACE_LOADED_OBJECTS variable.