This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: How to use test-nlist
- From: Mark Wielaard <mark at klomp dot org>
- To: "Yu, Mingli" <mingli dot yu at windriver dot com>
- Cc: elfutils-devel at sourceware dot org
- Date: Thu, 23 May 2019 13:50:29 +0200
- Subject: Re: How to use test-nlist
- References: <5CE65F57.6010900@windriver.com>
On Thu, May 23, 2019 at 04:52:39PM +0800, Yu, Mingli wrote:
> I run some tests about elfutils, but one test as test-nlist always fails as
> below:
>
> # ./tests/test-nlist
> nlist failed
You are supposed to run it with make check.
make check TESTS=test-nlist
test-nlist tries to run nlist on itself.
So it has to be in the current working directory.
As you do below:
> # cd tests
> # ./test-nlist -d
> nl[0].n_name = "var"
> nl[0].n_value = 0
> nl[0].n_scnum = 0
> nl[0].n_type = 0
> nl[0].n_sclass = 0
> nl[0].n_numaux = 0
>
> nl[1].n_name = "bss"
> nl[1].n_value = 0
> nl[1].n_scnum = 0
> nl[1].n_type = 0
> nl[1].n_sclass = 0
> nl[1].n_numaux = 0
>
> nl[2].n_name = "main"
> nl[2].n_value = 0
> nl[2].n_scnum = 0
> nl[2].n_type = 0
> nl[2].n_sclass = 0
> nl[2].n_numaux = 0
>
> nl[3].n_name = "foo"
> nl[3].n_value = 0
> nl[3].n_scnum = 0
> nl[3].n_type = 0
> nl[3].n_sclass = 0
> nl[3].n_numaux = 0
>
> nl[4].n_name = "not-there"
> nl[4].n_value = 0
> nl[4].n_scnum = 0
> nl[4].n_type = 0
> nl[4].n_sclass = 0
> nl[4].n_numaux = 0
> # echo $?
> 1
For some reason all the n_ fields come out as zero. That is not what
the test expects (except for the last "not-there" entry. It should
look somethng like:
nl[0].n_name = "var"
nl[0].n_value = 16456
nl[0].n_scnum = 24
nl[0].n_type = 1
nl[0].n_sclass = 0
nl[0].n_numaux = 0
nl[1].n_name = "bss"
nl[1].n_value = 16464
nl[1].n_scnum = 25
nl[1].n_type = 1
nl[1].n_sclass = 0
nl[1].n_numaux = 0
nl[2].n_name = "main"
nl[2].n_value = 4224
nl[2].n_scnum = 14
nl[2].n_type = 2
nl[2].n_sclass = 0
nl[2].n_numaux = 0
nl[3].n_name = "foo"
nl[3].n_value = 4880
nl[3].n_scnum = 14
nl[3].n_type = 2
nl[3].n_sclass = 0
nl[3].n_numaux = 0
nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0
Basically nlist fills in the n_value and n_scnum with the st_value and
st_shndx of the symbol named if found.
As you can see for me it corresponds to the values found by:
$ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
58: 0000000000004048 4 OBJECT GLOBAL DEFAULT 24 var
61: 0000000000004050 4 OBJECT GLOBAL DEFAULT 25 bss
66: 0000000000001310 3 FUNC GLOBAL DEFAULT 14 foo
71: 0000000000001080 408 FUNC GLOBAL DEFAULT 14 main
Hope that helps you debug.
Cheers,
Mark