From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 906B843863 for ; Mon, 8 Jan 2024 10:16:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82833402B0; Mon, 8 Jan 2024 10:16:41 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by mails.dpdk.org (Postfix) with ESMTP id 1E9E240263 for ; Mon, 8 Jan 2024 10:16:40 +0100 (CET) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 90125320127D; Mon, 8 Jan 2024 04:16:36 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 08 Jan 2024 04:16:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1704705396; x=1704791796; bh=pPk0VYcG2rvXncY1yjiQGjqQoXsUzF5TnR+hy773SUU=; b= AKAIyaxMsyFYZq1NHJ704U0HyL2kvIyZX51rzG50FwfJE84JErNsLKOnDojFQtT8 leCOYRZbZ0REkYYHqzcDmYxn+ordOj08iqYNrJiNKUEr2WB7I1BApF40ifOtbrK4 vnA3qPpu8Z/dkomHXCK6BotuB9jLhUdrANv6XIzjaFuiDQkzj6td8zJMQsh2H9xM LTy6+SEdkBJOSJXqx5O+TLOkbxAmHDNRlcthikWak48izZSS6bskZyYmfTyhU3Zi l5axyqiIlzs+vR0jnk0sBWKuD7Ov00wnp6CPTUnroNlyiAb+PeIMaiTFhAUv/3vr rtqprUCD9lmU4X/IKDi14Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1704705396; x= 1704791796; bh=pPk0VYcG2rvXncY1yjiQGjqQoXsUzF5TnR+hy773SUU=; b=6 QFzlLZB5PduMYpnks6oZG+c7hTYJzJDWi3WC1iZblOO3G43RilvdTGKAXr/+YQ5W UZl0Ugx7isxpW5u3GJy+Mj201rtNTygAYQst9AYuO6CREvkY40aQqg1GfENPviVZ t5Lcf2UWHow3bUHAKkYoD9N+9S7L4xr79OwobK2LdWawzDeF0dDdheupeACXcsFg 6ZYLyrhy49/fhFGCJTl5xg54jAPDgwCIluRAGsKB0augEeEvPq0VlV0yTEiYoDh6 j7NnoCPdczulYI8/Ct7he69G/RlTzY3eNyPtmGdWeb1DluHjUQyi3yDKG/qnR09l B/O502f6P9VZCRu6rGP/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehjedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedtjeeiieefhedtfffgvdelteeufeefheeujefgueetfedttdei kefgkeduhedtgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Jan 2024 04:16:34 -0500 (EST) From: Thomas Monjalon To: "jiangheng (G)" Cc: Matan Azrad , Slava Ovsiienko , "orika@nvidia.com" , "suanmingm@nvidia.com" , "users@dpdk.org" Subject: Re: when link librte_net_mlx5.so and use gdb, my program can't get environment variable Date: Mon, 08 Jan 2024 10:16:32 +0100 Message-ID: <4274415.mogB4TqSGs@thomas> In-Reply-To: <282c6e61a40f40ab81d8d14adce84f1e@huawei.com> References: <282c6e61a40f40ab81d8d14adce84f1e@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Hello, We could dig in details what happens in constructors, but first I don't understand why you want to LD_PRELOAD some drivers. The DPDK drivers are already loaded dynamically with dlopen() from EAL. 04/12/2023 10:45, jiangheng (G): > Environment: > [root@localhost jh]# cat /etc/centos-release > CentOS Linux release 8.5.2111 > root@localhost jh]# uname -r > 4.18.0-348.el8.x86_64 > [root@localhost jh]# rpm -qa gcc > gcc-8.5.0-3.el8.x86_64 > [root@localhost jh]# rpm -qa dpdk > dpdk-21.11-3.el8.x86_64 > > Reproduction Procedure: > 1. We need create test.c and init.c > > [root@localhost jh]# cat init.c > #include > #include > #include > > __attribute__ ((constructor)) void init(void) > { > char *enval = NULL; > enval = getenv("LD_PRELOAD"); > printf("enval LD_PRELOAD : %s\n", enval); > return; > } > > [root@localhost jh]# cat test.c > #include > > int main(int argc, char **argv) > { > printf("Hello World\n"); > return 0; > } > > 2. Build test.c > gcc test.c -o test > > 3. Build init.c as so in three cases: > 3.1 only link librte_eal.so > gcc --shared -fPIC -lrte_eal init.c -o libinit.so > 3.2 link librte_eal.so and librte_net_i40e.so > gcc --shared -fPIC -lrte_eal -lrte_net_i40e init.c -o libinit_i40e.so > 3.3 link librte_eal.so and librte_net_mlx5.so > gcc --shared -fPIC -lrte_eal -lrte_net_mlx5 init.c -o libinit_mlx5.so > > 4. run test using gdb and LD_PRELOAD > 4.1 : libinit.so links only librte_eal.so > LD_PRELOAD=./libinit.so gdb ./test > (gdb) r > enval LD_PRELOAD : ./libinit.so > enval LD_PRELOAD : ./libinit.so (I don't know why the constrctor function is executed twice.) > Hello World > > 4.2 libinit.so links librte_eal.so and librte_net_i40e.so > LD_PRELOAD=./libinit_i40e.so gdb ./test > enval LD_PRELOAD : ./libinit_i40e.so > enval LD_PRELOAD : ./libinit_i40e.so (I don't know why the constrctor function is executed twice.) > Hello World > > 4.3 4.3 libinit.so links librte_eal.so and librte_net_mlx5.so > LD_PRELOAD=./libinit_mlx5.so gdb ./test > enval LD_PRELOAD : (null) // ? ? ? ? > enval LD_PRELOAD : ./libinit_mlx5.so > Hello World > > > After libinit.so is linked to librte_net_mlx5.so, the symptom when the gdb is used to execute the program is different from the preceding two cases. The value of LD_PRELOAD obtained is NULL for the first time. > Have you ever had the same problem? > Looking forward to your favourable reply. > > Thanks > > >