[Bug general/25227] New: "eu-nm --extern" skips first symbol

2019-11-27 Thread ematsumiya at suse dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25227

Bug ID: 25227
   Summary: "eu-nm --extern" skips first symbol
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: general
  Assignee: unassigned at sourceware dot org
  Reporter: ematsumiya at suse dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Reproduction steps:

> # cat example.c
> void *SYM1;
> void *SYM2;
> void *SYM3;
> # gcc -c -std=gnu89 -fstack-protector-all -funsigned-char -fPIC -Wall 
> -Wconversion -Wextra -g -O0 example.c
> # eu-nm --extern example.o
> 
> 
> Symbols from /home/enzo/tmp/eu-nm-bug/example.o:
> 
> Name ValueClass  Type Size Line Section
> 
> SYM2|0008|GLOBAL|OBJECT  |0008||COMMON
> SYM3|0008|GLOBAL|OBJECT  |0008||COMMON

Expected result:

> NameValueClass  Type Size   Line Section
> 
> SYM1|0008|GLOBAL|OBJECT  |0008||COMMON
> SYM2|0008|GLOBAL|OBJECT  |0008||COMMON
> SYM3|0008|GLOBAL|OBJECT  |0008||COMMON

i.e. "SYM1" line is not present.

Reverting this change fixes the problem:

commit 66f4c37d497bdde040a33f299b12163f044b1bf2
Author: Ulrich Drepper 
Date:   Mon Oct 3 15:53:12 2011 -0400

Fix nm output for sysv format

Undefined symbols need no address and siz printed.  Avoid the initial
entry which is no real symbol.  Avoid section symbols.

@@ -808,8 +808,12 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char
*fullname,
 #endif

   /* Iterate over all symbols.  */
-  for (cnt = 0; cnt < nsyms; ++cnt)
+  for (cnt = 1; cnt < nsyms; ++cnt)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug general/25227] "eu-nm --extern" skips first symbol

2019-11-27 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=25227

Mark Wielaard  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-11-27
 CC||mark at klomp dot org
 Ever confirmed|0   |1

--- Comment #1 from Mark Wielaard  ---
Yes, that is odd. Thank for the reproducer.
I think that must be a typo in the patch.
The other formats show_symbols_bsd and show_symbols_posix do start at zero.
And they are all three called with the same nsyms and syms array.

-- 
You are receiving this mail because:
You are on the CC list for the bug.