How to use test-nlist

Yu, Mingli mingli.yu@windriver.com
Fri May 24 02:54:00 GMT 2019



On 2019年05月23日 19:50, Mark Wielaard wrote:
> 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.

Thanks Mark for your respond!
As you said "So it has to be in the current working directory.", what do 
you mean? test-nlist needs to locate 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

# which eu-readelf
/usr/bin/eu-readelf

# /usr/bin/eu-readelf -s tests/test-nlist
Symbol table [ 5] '.dynsym' contains 11 entries:
  1 local symbol  String table: [ 6] '.dynstr'
   Num:            Value   Size Type    Bind   Vis          Ndx Name
     0: 0000000000000000      0 NOTYPE  LOCAL  DEFAULT    UNDEF
     1: 0000000000000000      0 NOTYPE  WEAK   DEFAULT    UNDEF 
_ITM_deregisterTMCloneTable
     2: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
puts@GLIBC_2.2.5 (2)
     3: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
__stack_chk_fail@GLIBC_2.4 (3)
     4: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
__libc_start_main@GLIBC_2.2.5 (2)
     5: 0000000000000000      0 NOTYPE  WEAK   DEFAULT    UNDEF 
__gmon_start__
     6: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
nlist@ELFUTILS_1.0 (4)
     7: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
__printf_chk@GLIBC_2.3.4 (5)
     8: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF 
exit@GLIBC_2.2.5 (2)
     9: 0000000000000000      0 NOTYPE  WEAK   DEFAULT    UNDEF 
_ITM_registerTMCloneTable
    10: 0000000000000000      0 FUNC    WEAK   DEFAULT    UNDEF 
__cxa_finalize@GLIBC_2.2.5 (2)

Thanks,

>
> Hope that helps you debug.
>
> Cheers,
>
> Mark
>



More information about the Elfutils-devel mailing list