public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files
@ 2020-03-15 12:55 Matthias Maennich
  2020-03-15 12:55 ` [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT Matthias Maennich
  2020-03-18 22:07 ` [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Dodji Seketeli
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Maennich @ 2020-03-15 12:55 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, maennich

test-read-dwarf silently succeeded even if the input elf file was not
existing. Hence, make distcheck succeeded even though the testfiles were
not distributed. Assert on the existence of the input file and add the
missing test case files.

	* tests/data/Makefile.am: add missing test case files
	* tests/test-read-dwarf.cc (test_task::perform): assert the
	input elf file exists.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 tests/data/Makefile.am   | 2 ++
 tests/test-read-dwarf.cc | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index bf76ca2e617b..802b709fc5f5 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -435,6 +435,8 @@ test-read-dwarf/PR25007-sdhci.ko \
 test-read-dwarf/PR25007-sdhci.ko.abi \
 test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0 \
 test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi \
+test-read-dwarf/test25-bogus-binary.elf \
+test-read-dwarf/test26-bogus-binary.elf \
 \
 test-annotate/test0.abi			\
 test-annotate/test1.abi			\
diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc
index 11e8425b5a84..a8ea0619ccbb 100644
--- a/tests/test-read-dwarf.cc
+++ b/tests/test-read-dwarf.cc
@@ -328,6 +328,7 @@ struct test_task : public abigail::workers::task
     abigail::dwarf_reader::status status =
     abigail::dwarf_reader::STATUS_UNKNOWN;
     vector<char**> di_roots;
+    ABG_ASSERT(abigail::tools_utils::file_exists(in_elf_path));
     read_context_sptr ctxt = create_read_context(in_elf_path,
 						 di_roots,
 						 env.get());
-- 
2.25.1.481.gfbce0eb801-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT
  2020-03-15 12:55 [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Matthias Maennich
@ 2020-03-15 12:55 ` Matthias Maennich
  2020-03-18 22:19   ` Dodji Seketeli
  2020-03-18 22:07 ` [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Dodji Seketeli
  1 sibling, 1 reply; 4+ messages in thread
From: Matthias Maennich @ 2020-03-15 12:55 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, maennich

maybe_adjust_et_rel_sym_addr_to_abs_addr contained an ABG_ASSERT to
ensure symbol_section is not used on an invalid value. Since
maybe_adjust_et_rel_sym_addr_to_abs_addr handles this case, this assert
can be removed.

	* src/abg-dwarf-reader.cc
	(maybe_adjust_et_rel_sym_addr_to_abs_addr): improve NULL check,
	remove superfluous ABG_ASSERT
	* tests/data/Makefile.am: Add new test case to the distribution.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/data/test-read-dwarf/test27-bogus-binary.elf: New test case.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-dwarf-reader.cc                          |   3 +--
 tests/data/Makefile.am                           |   1 +
 .../data/test-read-dwarf/test27-bogus-binary.elf | Bin 0 -> 1024 bytes
 tests/test-read-dwarf.cc                         |   6 ++++++
 4 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 tests/data/test-read-dwarf/test27-bogus-binary.elf

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 3454fcf5cf7c..ff532cfd244e 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -8585,7 +8585,7 @@ public:
   GElf_Addr
   maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Addr addr, Elf_Scn *section)
   {
-    if (section == 0)
+    if (!section)
       return addr;
 
     Elf* elf = elf_handle();
@@ -8623,7 +8623,6 @@ public:
   maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Sym *sym)
   {
     Elf_Scn *symbol_section = elf_getscn(elf_handle(), sym->st_shndx);
-    ABG_ASSERT(symbol_section);
     GElf_Addr result = sym->st_value;
     result = maybe_adjust_et_rel_sym_addr_to_abs_addr(result, symbol_section);
     return result;
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 802b709fc5f5..3c819b26ad3f 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -437,6 +437,7 @@ test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0 \
 test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi \
 test-read-dwarf/test25-bogus-binary.elf \
 test-read-dwarf/test26-bogus-binary.elf \
+test-read-dwarf/test27-bogus-binary.elf \
 \
 test-annotate/test0.abi			\
 test-annotate/test1.abi			\
diff --git a/tests/data/test-read-dwarf/test27-bogus-binary.elf b/tests/data/test-read-dwarf/test27-bogus-binary.elf
new file mode 100644
index 0000000000000000000000000000000000000000..3240f53915c60f9c9808a6bff9f958b8a136eece
GIT binary patch
literal 1024
zcmb<-^>JflWbAif0D+kd?En9_%m4rXkCA}|ECM3)Ud_M9@FCXnzbC^vCLrHK^%PhR
zS%E%Kf%X3e77d`Fk&&^1nUR?i7H}6TrU;iag0l!Q?5_Xcbtinrk;q3C>w0SMOE82S
zf@oPS2h*wrWGKTp$TS0x^B)50lo%MnE>}=u0QrVNNdQ?T7B)~HNF6t(lp-5QzlE_W
zlBJi?lmRVk_y-aTQIq4_z-7^!8}gSy*!0K8hdVQ0tqPN}dFt5yUwD;9ae;xs)YYF{
zE=>CFv)jCiOd!DLp>TS6Np{-Re_1hAPj@xgc}Yy%eKJuknM?zr+B67)-9S5VDf;k>
zg@5|=;;4_SH?3LgkTK)Qt4X>ync5OQ<nCCs*J}BR<@;o-odmAM{t^BpG_OBJAz^3g
zrRli6694CL&9e6_ugVhlDO4^DTcdoI$`(-U!m}Db1Xj+-TcxV5u`AGUuClX9<I8fL
z&4yP@c@p;SI4fH`t2LeVOyR@biD#J2jxVizUU4Dv=v|h_C-Ya;ACaE@<u3>Ck=uuY
IRA}x~0RO9kcmMzZ

literal 0
HcmV?d00001

diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc
index a8ea0619ccbb..7c99d21889d0 100644
--- a/tests/test-read-dwarf.cc
+++ b/tests/test-read-dwarf.cc
@@ -265,6 +265,12 @@ InOutSpec in_out_specs[] =
     "",
     "",
   },
+  {
+    "data/test-read-dwarf/test27-bogus-binary.elf",
+    "",
+    "",
+    "",
+  },
   // This should be the last entry.
   {NULL, NULL, NULL, NULL}
 };
-- 
2.25.1.481.gfbce0eb801-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files
  2020-03-15 12:55 [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Matthias Maennich
  2020-03-15 12:55 ` [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT Matthias Maennich
@ 2020-03-18 22:07 ` Dodji Seketeli
  1 sibling, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2020-03-18 22:07 UTC (permalink / raw)
  To: Matthias Maennich; +Cc: libabigail, kernel-team

Matthias Maennich <maennich@google.com> a écrit:

> test-read-dwarf silently succeeded even if the input elf file was not
> existing. Hence, make distcheck succeeded even though the testfiles were
> not distributed. Assert on the existence of the input file and add the
> missing test case files.
>
> 	* tests/data/Makefile.am: add missing test case files
> 	* tests/test-read-dwarf.cc (test_task::perform): assert the
> 	input elf file exists.

Applied to master.

Thanks!

-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT
  2020-03-15 12:55 ` [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT Matthias Maennich
@ 2020-03-18 22:19   ` Dodji Seketeli
  0 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2020-03-18 22:19 UTC (permalink / raw)
  To: Matthias Maennich; +Cc: libabigail, kernel-team

Matthias Maennich <maennich@google.com> a écrit:

> maybe_adjust_et_rel_sym_addr_to_abs_addr contained an ABG_ASSERT to
> ensure symbol_section is not used on an invalid value. Since
> maybe_adjust_et_rel_sym_addr_to_abs_addr handles this case, this assert
> can be removed.
>
> 	* src/abg-dwarf-reader.cc
> 	(maybe_adjust_et_rel_sym_addr_to_abs_addr): improve NULL check,
> 	remove superfluous ABG_ASSERT
> 	* tests/data/Makefile.am: Add new test case to the distribution.
> 	* tests/test-read-dwarf.cc: Likewise.
> 	* tests/data/test-read-dwarf/test27-bogus-binary.elf: New test
> 	case.

Applied to master.

Thanks!

-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-18 22:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 12:55 [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Matthias Maennich
2020-03-15 12:55 ` [PATCH 2/2] dwarf-reader: remove superfluous ABG_ASSERT Matthias Maennich
2020-03-18 22:19   ` Dodji Seketeli
2020-03-18 22:07 ` [PATCH 1/2] test-read-dwarf: ensure in_elf_path exists and add missing test files Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).