DPDK usage discussions
 help / color / mirror / Atom feed
From: "jiangheng (G)" <jiangheng14@huawei.com>
To: Matan Azrad <matan@nvidia.com>,
	Slava Ovsiienko <viacheslavo@nvidia.com>,
	 "orika@nvidia.com" <orika@nvidia.com>,
	"suanmingm@nvidia.com" <suanmingm@nvidia.com>,
	"users@dpdk.org" <users@dpdk.org>
Subject: when link librte_net_mlx5.so and use gdb, my program can't get environment variable
Date: Mon, 4 Dec 2023 09:45:52 +0000	[thread overview]
Message-ID: <282c6e61a40f40ab81d8d14adce84f1e@huawei.com> (raw)

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 <string.h>
#include <stdio.h>
#include <stdlib.h>

__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 <stdio.h>

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



             reply	other threads:[~2023-12-04  9:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  9:45 jiangheng (G) [this message]
2024-01-08  9:16 ` Thomas Monjalon

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=282c6e61a40f40ab81d8d14adce84f1e@huawei.com \
    --to=jiangheng14@huawei.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=users@dpdk.org \
    --cc=viacheslavo@nvidia.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.
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 NNTP newsgroup(s).