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

Message ID 20220806085310.2603348-1-slyich@gmail.com
State Superseded
Headers
Series tests: do not fail on zero sized DIEs (binutils-2.39 compatible) |

Commit Message

Sergei Trofimovich Aug. 6, 2022, 8:53 a.m. UTC
  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 <slyich@gmail.com>
---
 tests/ChangeLog     | 4 ++++
 tests/low_high_pc.c | 3 +++
 2 files changed, 7 insertions(+)
  

Comments

Martin Liška Aug. 7, 2022, 3:32 p.m. UTC | #1
On 8/6/22 10:53, Sergei Trofimovich via Elfutils-devel wrote:

Hi.

Thanks for catching this. Btw. I've also noticed the elfutils failure
in openSUSE staging project.

> 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 <slyich@gmail.com>
> ---
>  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  <slyich@gmail.com>
> +
> +	* low_high_pc.c (handle_die): Allow zero sized DIEs for binutils-2.39.
> +
>  2022-08-01  Mark Wielaard  <mark@klomp.org>
>  
>  	* 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

What about rather changing 'highpc <= lowpc' to 'highpc < lowpc'
and note that ...

>        && ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))

... here 'highpc == lowpc' would be always false and the entire condition:
'&& ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))' always true.

Cheers,
Martin

>      {
>        printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "\n", lowpc, highpc);
  

Patch

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  <slyich@gmail.com>
+
+	* low_high_pc.c (handle_die): Allow zero sized DIEs for binutils-2.39.
+
 2022-08-01  Mark Wielaard  <mark@klomp.org>
 
 	* 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);