[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-06 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #3 from Sergei Trofimovich  ---
gas-2.39 started adding 0-sized DIE for function without a .size marking:

$ cat crti.S.S

 .section .init,"ax",@progbits
 .p2align 2
 .globl _init
 .hidden _init
 .type _init, @function
_init:
  .section
.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
.globl __x86.get_pc_thunk.bx
.hidden __x86.get_pc_thunk.bx
.p2align 4
.type __x86.get_pc_thunk.bx,@function
__x86.get_pc_thunk.bx:
  ud2
.size __x86.get_pc_thunk.bx, . - __x86.get_pc_thunk.bx
.previous
  ud2

$ as-2.39 --gdwarf2 --32 -o crti.o crti.S.S
$ readelf -aW --debug-dump crti.o

 <0>: Abbrev Number: 1 (DW_TAG_compile_unit)
   DW_AT_stmt_list   : (data4) 0x0
<10>   DW_AT_ranges  : (data4) 0x0
<14>   DW_AT_name: (strp) (offset: 0x0): crti.S.S
<18>   DW_AT_comp_dir: (strp) (offset: 0x9):
/home/slyfox/dev/bugs/binutils-2.39-crti-size/delta
<1c>   DW_AT_producer: (strp) (offset: 0x3d): GNU AS 2.39
<20>   DW_AT_language: (data2) 32769(MIPS assembler)
 <1><22>: Abbrev Number: 2 (DW_TAG_subprogram)
<23>   DW_AT_name: (strp) (offset: 0x49): _init
<27>   DW_AT_external: (flag) 1
<28>   DW_AT_low_pc  : (addr) 0x0
<2c>   DW_AT_high_pc : (addr) 0x0
 <1><30>: Abbrev Number: 2 (DW_TAG_subprogram)
<31>   DW_AT_name: (strp) (offset: 0x4f): __x86.get_pc_thunk.bx
<35>   DW_AT_external: (flag) 1
<36>   DW_AT_low_pc  : (addr) 0x0
<3a>   DW_AT_high_pc : (addr) 0x2
 <1><3e>: Abbrev Number: 0

$ as-2.38 --gdwarf2 --32 -o crti.o crti.S.S
$ readelf -aW --debug-dump crti.o

 <0>: Abbrev Number: 1 (DW_TAG_compile_unit)
   DW_AT_stmt_list   : (data4) 0x0
<10>   DW_AT_ranges  : (data4) 0x0
<14>   DW_AT_name: (strp) (offset: 0x0): crti.S.S
<18>   DW_AT_comp_dir: (strp) (offset: 0x9):
/home/slyfox/dev/bugs/binutils-2.39-crti-size/delta
<1c>   DW_AT_producer: (strp) (offset: 0x3d): GNU AS 2.38
<20>   DW_AT_language: (data2) 32769(MIPS assembler)

Not sure if it's a discrepancy in binutils.

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

[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-06 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #4 from Sergei Trofimovich  ---
Filed https://sourceware.org/PR29451 against gas.

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

[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-06 Thread slyich at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

Sergei Trofimovich  changed:

   What|Removed |Added

   See Also||https://sourceware.org/bugz
   ||illa/show_bug.cgi?id=29451

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

[PATCH] tests: do not fail on zero sized DIEs (binutils-2.39 compatible)

2022-08-06 Thread Sergei Trofimovich via Elfutils-devel
binutils started producing 0-sized DIEs on functions interspersed
by nested sections (".section ...; .previous). This led to
run-low_high_pc.sh failure in form of:

FAIL: run-low_high_pc.sh


[b] main.c
[2d] main

[b] ../sysdeps/i386/start.S
[26] _start
[40] ../sysdeps/x86/abi-note.c
[b52] init.c
[b8e] static-reloc.c
[2dba] _dl_relocate_static_pie
[2dd8] ../sysdeps/i386/crti.S
[2def] _init
lowpc: 8049000, highpc: 8049000lx
../sysdeps/i386/crti.S: [2def] '_init' highpc <= lowpc
FAIL run-low_high_pc.sh (exit status: 255)

To work it around let's allow lowpc == highpc special case.

https://sourceware.org/bugzilla/show_bug.cgi?id=29450

Signed-off-by: Sergei Trofimovich 
---
 tests/ChangeLog | 4 
 tests/low_high_pc.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0c6f68ef..8296e0b6 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2022-08-04  Sergei Trofimovich  
+
+   * low_high_pc.c (handle_die): Allow zero sized DIEs for binutils-2.39.
+
 2022-08-01  Mark Wielaard  
 
* run-debuginfod-percent-escape.sh: Add initial scan wait_ready.
diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
index cd022b1c..80c83b6d 100644
--- a/tests/low_high_pc.c
+++ b/tests/low_high_pc.c
@@ -70,6 +70,9 @@ handle_die (Dwarf_Die *die, void *arg)
   if (dwarf_hasattr (die, DW_AT_low_pc)
   && dwarf_hasattr (die, DW_AT_high_pc)
   && highpc <= lowpc
+  /* gas-2.39 produces zero sized DIEs sometimes:
+ https://sourceware.org/PR29451.  */
+  && highpc != lowpc
   && ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))
 {
   printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "\n", lowpc, highpc);
-- 
2.37.1



[PATCH] tests: run-low_high_pc.sh: drop redundant 'lx' suffix

2022-08-06 Thread Sergei Trofimovich via Elfutils-devel
Noticed when debugged test failure:

lowpc: 8049000, highpc: 8049000lx
../sysdeps/i386/crti.S: [2def] '_init' highpc <= lowpc

Signed-off-by: Sergei Trofimovich 
---
 tests/ChangeLog | 4 
 tests/low_high_pc.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0c6f68ef..d2952cc9 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2022-08-04  Sergei Trofimovich  
+
+   * low_high_pc.c (handle_die): Drop redundant 'lx' suffix.
+
 2022-08-01  Mark Wielaard  
 
* run-debuginfod-percent-escape.sh: Add initial scan wait_ready.
diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
index 78b6ad08..cd022b1c 100644
--- a/tests/low_high_pc.c
+++ b/tests/low_high_pc.c
@@ -72,7 +72,7 @@ handle_die (Dwarf_Die *die, void *arg)
   && highpc <= lowpc
   && ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))
 {
-  printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "lx\n", lowpc, highpc);
+  printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "\n", lowpc, highpc);
   fail (off, name, "highpc <= lowpc");
 }
 
-- 
2.37.1