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

2022-10-13 Thread Sergei Trofimovich via Elfutils-devel
On Thu, 13 Oct 2022 16:40:36 +0200
Mark Wielaard  wrote:

> Hi,
> 
> On Mon, 2022-08-08 at 01:17 +0200, Mark Wielaard wrote:
> > On Sun, Aug 07, 2022 at 07:31:38PM +0100, Sergei Trofimovich via
> > Elfutils-devel wrote:  
> > > 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  
> > 
> > Thanks for finding this and suggesting a workaround.  But lets first
> > try to fix binutils. This seems like a pretty bad bug, lets hope it
> > gets fixed soon. So we don't need these kind of workarounds.
> > 
> > I added a comment to the binutils bug:
> > https://sourceware.org/bugzilla/show_bug.cgi?id=29451#c2  
> 
> Since this binutils bug was fixed I assume this patch isn't needed
> anymore.

Agreed. https://sourceware.org/PR29450#c8 cosed the bug as RESOLVED/MOVED
to declare it a binutils deficiency. Downstream use binutils-2.39 with a
gas patch and are able to run unmodified elfutils testsuite as is.

Thank you!

-- 

  Sergei


[PATCH] elfutils/configure.ac: use $READELF, not readelf

2020-06-14 Thread Sergei Trofimovich via Elfutils-devel
Allow user to specify own readelf. Use detected readelf,
not 'readelf'.

Noticed when was building elfutils on tuple-prefixed toolchain:

```
checking whether the compiler generates build-ids...
  ./configure: line 5197: readelf: command not found
no
```

Signed-off-by: Sergei Trofimovich 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 74cc749d..8d3bcb7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,7 +200,7 @@ fi
 # We really want build-ids. Warn and force generating them if gcc was
 # configure without --enable-linker-build-id
 AC_CACHE_CHECK([whether the compiler generates build-ids], ac_cv_buildid, [dnl
-AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ac_cv_buildid=yes; readelf -n 
conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || 
ac_cv_buildid=no],AC_MSG_FAILURE([unexpected compile failure]))])
+AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ac_cv_buildid=yes; $READELF -n 
conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || 
ac_cv_buildid=no],AC_MSG_FAILURE([unexpected compile failure]))])
 if test "$ac_cv_buildid" = "no"; then
AC_MSG_WARN([compiler doesn't generate build-id by default])
LDFLAGS="$LDFLAGS -Wl,--build-id"
-- 
2.27.0



[PATCH] src/elflint.c: add debug print for GNU_RETAIN and others

2020-12-31 Thread Sergei Trofimovich via Elfutils-devel
---
 src/elflint.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/elflint.c b/src/elflint.c
index b3cbaade..7b7f7937 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2789,7 +2789,10 @@ section_flags_string (GElf_Word flags, char *buf, size_t 
len)
   NEWFLAG (OS_NONCONFORMING),
   NEWFLAG (GROUP),
   NEWFLAG (TLS),
-  NEWFLAG (COMPRESSED)
+  NEWFLAG (COMPRESSED),
+  NEWFLAG (GNU_RETAIN),
+  NEWFLAG (ORDERED),
+  NEWFLAG (EXCLUDE)
 };
 #undef NEWFLAG
   const size_t nknown_flags = sizeof (known_flags) / sizeof (known_flags[0]);
-- 
2.30.0



[PATCH] src/elflint.c: fix printing of unknown flags

2020-12-31 Thread Sergei Trofimovich via Elfutils-devel
before the change section_flags_string() ignored unknown section
flags: snprintf() did write numeric value int obuffer, but
"*cp = '\0'" hegated the effect.

The change advances the 'cp' pointer'.

While at it add a '|' separator between known and unknown flags.

Signed-off-by: Sergei Trofimovich 
---
 src/elflint.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/elflint.c b/src/elflint.c
index 7b7f7937..8f5227b3 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2815,9 +2815,11 @@ section_flags_string (GElf_Word flags, char *buf, size_t 
len)
flags ^= known_flags[cnt].flag;
   }
 
-  if (flags != 0 || cp == buf)
-snprintf (cp, len - 1, "%" PRIx64, (uint64_t) flags);
-
+  if (flags != 0 || cp == buf) {
+int r = snprintf (cp, len - 1, "%s%" PRIx64, (cp == buf) ? "" : "|", 
(uint64_t) flags);
+if (r > 0)
+  cp += r;
+  }
   *cp = '\0';
 
   return buf;
-- 
2.30.0



Re: [PATCH] src/elflint.c: add debug print for GNU_RETAIN and others

2021-01-12 Thread Sergei Trofimovich via Elfutils-devel
On Tue, 12 Jan 2021 10:14:55 +0100
Mark Wielaard  wrote:

> Hi Sergei,
> 
> On Thu, 2020-12-31 at 12:11 +0000, Sergei Trofimovich via Elfutils-devel 
> wrote:
> > ---
> >  src/elflint.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/elflint.c b/src/elflint.c
> > index b3cbaade..7b7f7937 100644
> > --- a/src/elflint.c
> > +++ b/src/elflint.c
> > @@ -2789,7 +2789,10 @@ section_flags_string (GElf_Word flags, char *buf, 
> > size_t len)
> >NEWFLAG (OS_NONCONFORMING),
> >NEWFLAG (GROUP),
> >NEWFLAG (TLS),
> > -  NEWFLAG (COMPRESSED)
> > +  NEWFLAG (COMPRESSED),
> > +  NEWFLAG (GNU_RETAIN),
> > +  NEWFLAG (ORDERED),
> > +  NEWFLAG (EXCLUDE)
> >  };
> >  #undef NEWFLAG
> >const size_t nknown_flags = sizeof (known_flags) / sizeof 
> > (known_flags[0]);  
> 
> Thanks, this is obviously correct and I pushed it. But normally a patch
> comes with a Signed-off-by line and a ChangeLog entry. I added both.
> But please see:
> https://sourceware.org/git/?p=elfutils.git;a=blob_plain;f=CONTRIBUTING;hb=HEAD

My apologies. Will follow CONTRIBUTING closer to future patches.

Thank you!

-- 

  Sergei


[PATCH] tests: use ${CC} instead of 'gcc' in tests

2021-01-31 Thread Sergei Trofimovich via Elfutils-devel
To better support cross-compilation Gentoo provides a way
to configure system without 'gcc' binary and only provide
tool-prefixed tools, like 'x86_64-pc-linux-gnu-gcc'.
The packages are built as ./configure --host=x86_64-pc-linux-gnu.

In https://bugs.gentoo.org/718872 Agostino Sarubbo found
a few test failures that use hardcoded 'gcc' instead of
expected ${CC}. The change propagates detected ${CC} at
configure time to test scripts.

Signed-off-by: Sergei Trofimovich 
---
 tests/ChangeLog| 10 ++
 tests/Makefile.am  |  6 --
 tests/run-disasm-x86-64.sh |  2 +-
 tests/run-disasm-x86.sh|  2 +-
 tests/run-strip-g.sh   |  2 +-
 tests/run-strip-nothing.sh |  2 +-
 tests/run-test-includes.sh | 14 +++---
 7 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 3e5b630a..c6e9f618 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,13 @@
+2021-01-31  Sergei Trofimovich  
+
+   * Makefile.am (TESTS_ENVIRONMENT): export CC variable
+   to tests for use instead of 'gcc'.
+   * run-disasm-x86-64.sh: use ${CC} instead of 'gcc'.
+   * run-disasm-x86.sh: Likewise.
+   * run-strip-g.sh: Likewise.
+   * run-strip-nothing.sh: Likewise.
+   * run-test-includes.sh: Likewise.
+
 2021-01-06  Timm Bäder  
 
* zstrptr.c (main): Lift print_strings function up to ...
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 502becff..c145720c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -527,7 +527,8 @@ installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
  export libdir; export bindir; \
  export LC_ALL; export LANG; export VALGRIND_CMD; \
  unset DEBUGINFOD_URLS; \
- NM=$(NM); export NM;
+ NM=$(NM); export NM; \
+ CC=$(CC); export CC;
 installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
 installed $(tests_rpath) \
 '$(program_transform_name)'
@@ -538,7 +539,8 @@ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; 
VALGRIND_CMD=$(valgrind_cmd); \
export abs_top_builddir; \
export LC_ALL; export LANG; export VALGRIND_CMD; \
unset DEBUGINFOD_URLS; \
-   NM=$(NM); export NM;
+   NM=$(NM); export NM; \
+   CC=$(CC); export CC;
 LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
   
$(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm:$(abs_top_builddir)/debuginfod
 
diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
index a6be62bb..07b612b0 100755
--- a/tests/run-disasm-x86-64.sh
+++ b/tests/run-disasm-x86-64.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64)
 tempfiles testfile45.o
 testfiles testfile45.S testfile45.expect
-gcc -m64 -c -o testfile45.o testfile45.S
+${CC} -m64 -c -o testfile45.o testfile45.S
 testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < 
testfile45.expect
 ;;
 esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
index 28a3df74..7ac73ad7 100755
--- a/tests/run-disasm-x86.sh
+++ b/tests/run-disasm-x86.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64 | i?86 )
 tempfiles testfile44.o
 testfiles testfile44.S testfile44.expect
-gcc -m32 -c -o testfile44.o testfile44.S
+${CC} -m32 -c -o testfile44.o testfile44.S
 testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < 
testfile44.expect
 ;;
 esac
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
index 13038195..15921215 100755
--- a/tests/run-strip-g.sh
+++ b/tests/run-strip-g.sh
@@ -25,7 +25,7 @@
 tempfiles a.out strip.out debug.out readelf.out
 
 echo Create debug a.out.
-echo "int main() { return 1; }" | gcc -g -xc -
+echo "int main() { return 1; }" | ${CC} -g -xc -
 
 echo strip -g to file with debug file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
index 914fdfbf..710c200d 100755
--- a/tests/run-strip-nothing.sh
+++ b/tests/run-strip-nothing.sh
@@ -23,7 +23,7 @@
 tempfiles a.out strip.out debug.out
 
 # Create no-debug a.out.
-echo "int main() { return 1; }" | gcc -s -xc -
+echo "int main() { return 1; }" | ${CC} -s -xc -
 
 # strip to file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out ||
diff --git a/tests/run-test-includes.sh b/tests/run-test-includes.sh
index b0ccdd9b..b107c6b9 100755
--- a/tests/run-test-includes.sh
+++ b/tests/run-test-includes.sh
@@ -3,24 +3,24 @@
 . $srcdir/test-subr.sh
 
 echo '#include "libelf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
+  | ${CC} -c -o /dev/null -I ${abs_srcdir}/../libelf -xc -
 echo '#include "gelf.h"' \
-  | gcc -c -o /dev/null -I ${abs_srcdir}/../libelf

[PATCH] elflint: fix undefined 'buffer_left' reference

2021-06-06 Thread Sergei Trofimovich via Elfutils-devel
Link failure is reproducible on gcc-11.1.0 target:

```
$ autoreconf -i -f
$ ./configure --enable-maintainer-mode --disable-debuginfod \
--host=x86_64-pc-linux-gnu \
CFLAGS=-march=znver3 \
CXXFLAGS=-march=znver3 \
LDFLAGS=" "
$ make

  CCLD elflint
ld: elflint.o: in function `check_attributes':
elflint.c:(.text+0xdcff): undefined reference to `buffer_left'
ld: elflint.c:(.text+0xe557): undefined reference to `buffer_left'
```

It happens due to possible external linkage of `buffer_left()`.

The change forces local linkkage to always use local definition
(either inline or out-of-line).

Reported-by: Toralf Förster
Bug: https://bugs.gentoo.org/794601
Signed-off-by: Sergei Trofimovich 
---
 src/ChangeLog | 5 +
 src/elflint.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 2c7be185..e030de0d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-06  Sergei Trofimovich  
+
+   * elflint.c (buffer_left): Mark as 'inline' to avoid external linkage
+   failure.
+
 2021-05-12  Dmitry V. Levin  
 
* elfcompress.c (process_file): Return 1 instead of -1 in case of an
diff --git a/src/elflint.c b/src/elflint.c
index 85cc7833..35b40500 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -3434,7 +3434,7 @@ buffer_pos (Elf_Data *data, const unsigned char *p)
   return p - (const unsigned char *) data->d_buf;
 }
 
-inline size_t
+static inline size_t
 buffer_left (Elf_Data *data, const unsigned char *p)
 {
   return (const unsigned char *) data->d_buf + data->d_size - p;
-- 
2.31.1



[PATCH v2] elflint: fix undefined 'buffer_left' reference

2021-06-07 Thread Sergei Trofimovich via Elfutils-devel
Link failure is reproducible on gcc-11.1.0 target:

```
$ autoreconf -i -f
$ ./configure --enable-maintainer-mode --disable-debuginfod \
--host=x86_64-pc-linux-gnu \
CFLAGS=-march=znver3 \
CXXFLAGS=-march=znver3 \
LDFLAGS=" "
$ make

  CCLD elflint
ld: elflint.o: in function `check_attributes':
elflint.c:(.text+0xdcff): undefined reference to `buffer_left'
ld: elflint.c:(.text+0xe557): undefined reference to `buffer_left'
```

It happens due to possible external linkage of `buffer_left()`.

The change forces local linkkage to always use local definition
(either inline or out-of-line).

Reported-by: Toralf Förster
Bug: https://bugs.gentoo.org/794601
Signed-off-by: Sergei Trofimovich 
Fixes: e95d1fbb ("elflint: Pull left() in file scope")
---
Change since v1 suggested by Dmitry:
- fixed changelog to spell 'static' correctly :)
- added 'Fixes' annotation

Did not drop 'inline' to be consistent with other tiny helpers
in the same file.

 src/ChangeLog | 5 +
 src/elflint.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 2c7be185..698b3c77 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-06  Sergei Trofimovich  
+
+   * elflint.c (buffer_left): Mark as 'static' to avoid external linkage
+   failure.
+
 2021-05-12  Dmitry V. Levin  
 
* elfcompress.c (process_file): Return 1 instead of -1 in case of an
diff --git a/src/elflint.c b/src/elflint.c
index 85cc7833..35b40500 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -3434,7 +3434,7 @@ buffer_pos (Elf_Data *data, const unsigned char *p)
   return p - (const unsigned char *) data->d_buf;
 }
 
-inline size_t
+static inline size_t
 buffer_left (Elf_Data *data, const unsigned char *p)
 {
   return (const unsigned char *) data->d_buf + data->d_size - p;
-- 
2.32.0



[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



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

2022-08-07 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 | 8 +---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0c6f68ef..59b4252a 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2022-08-07  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 78b6ad08..63268f4c 100644
--- a/tests/low_high_pc.c
+++ b/tests/low_high_pc.c
@@ -66,11 +66,13 @@ handle_die (Dwarf_Die *die, void *arg)
 fail (off, name, "has DW_AT_high_pc but dwarf_highpc fails");
 
   /* GCC < 4.7 had a bug where no code CUs got a highpc == lowpc.
- Allow that, because it is not the main purpose of this test.  */
+ Allow that, because it is not the main purpose of this test.
+ gas-2.39 produces zero sized DIEs for subprograms sometimes:
+ https://sourceware.org/PR29451.
+   */
   if (dwarf_hasattr (die, DW_AT_low_pc)
   && dwarf_hasattr (die, DW_AT_high_pc)
-  && highpc <= lowpc
-  && ! (dwarf_tag (die) == DW_TAG_compile_unit && highpc == lowpc))
+  && highpc < lowpc)
 {
   printf("lowpc: %" PRIx64 ", highpc: %" PRIx64 "lx\n", lowpc, highpc);
   fail (off, name, "highpc <= lowpc");
-- 
2.37.1