[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Error out on empty debug section



Hi,

When encountering an empty debug section, we run into the following assert:
...
dwz: dwz.c:9901: read_dwarf: Assertion `data != NULL && data->d_buf != NULL' \
  failed.
...

Error out instead:
...
dwz: a.out: Found empty .debug_gdb_scripts section, not attempting dwz \
  compression
...

OK for trunk?

Thanks,
- Tom

Error out on empty debug section

2019-02-14  Tom de Vries  <tdevries@suse.de>

	PR dwz/24173
	* dwz.c (read_dwarf): Change assert (data->d_buf != NULL) into an error.

---
 dwz.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dwz.c b/dwz.c
index 4ef8657..fc87abe 100644
--- a/dwz.c
+++ b/dwz.c
@@ -9906,7 +9906,13 @@ read_dwarf (DSO *dso, bool quieter)
 
 		  scn = dso->scn[i];
 		  data = elf_rawdata (scn, NULL);
-		  assert (data != NULL && data->d_buf != NULL);
+		  assert (data != NULL);
+		  if (data->d_buf == NULL)
+		    {
+		      error (0, 0, "%s: Found empty %s section, not attempting"
+			     " dwz compression", dso->filename, name);
+		      return 1;
+		    }
 		  assert (elf_rawdata (scn, data) == NULL);
 		  assert (data->d_off == 0);
 		  assert (data->d_size == dso->shdr[i].sh_size);