From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Cc: gprocida@google.com, Dodji Seketeli <dodji@redhat.com>
Subject: [PATCH 3/4] corpus: Handle empty symbol table cases
Date: Fri, 03 Feb 2023 12:48:27 +0100 [thread overview]
Message-ID: <877cwzt1f8.fsf_-_@redhat.com> (raw)
In-Reply-To: <87mt5vt3op.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 03 Feb 2023 11:59:34 +0100")
Hello,
There can be cases where the symbol table associated with a given
corpus is empty. This patch handles those cases to avoid crashes.
* src/abg-corpus.cc (corpus::priv::{get_sorted_fun_symbols,
get_sorted_undefined_fun_symbols, get_sorted_var_symbols,
get_sorted_undefined_var_symbols}): If the symbol is null, then
return an empty vector of symbols.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
src/abg-corpus.cc | 58 ++++++++++++++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 18 deletions(-)
diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc
index b6f760bb..4f20a888 100644
--- a/src/abg-corpus.cc
+++ b/src/abg-corpus.cc
@@ -313,9 +313,15 @@ corpus::priv::get_sorted_fun_symbols() const
{
if (!sorted_fun_symbols)
{
- auto filter = symtab_->make_filter();
- filter.set_functions();
- sorted_fun_symbols = elf_symbols(symtab_->begin(filter), symtab_->end());
+ if (symtab_)
+ {
+ auto filter = symtab_->make_filter();
+ filter.set_functions();
+ sorted_fun_symbols = elf_symbols(symtab_->begin(filter),
+ symtab_->end());
+ }
+ else
+ sorted_fun_symbols = elf_symbols();
}
return *sorted_fun_symbols;
}
@@ -349,13 +355,18 @@ corpus::priv::get_sorted_undefined_fun_symbols() const
{
if (!sorted_undefined_fun_symbols)
{
- auto filter = symtab_->make_filter();
- filter.set_functions();
- filter.set_undefined_symbols();
- filter.set_public_symbols(false);
+ if (symtab_)
+ {
+ auto filter = symtab_->make_filter();
+ filter.set_functions();
+ filter.set_undefined_symbols();
+ filter.set_public_symbols(false);
- sorted_undefined_fun_symbols =
- elf_symbols(symtab_->begin(filter), symtab_->end());
+ sorted_undefined_fun_symbols =
+ elf_symbols(symtab_->begin(filter), symtab_->end());
+ }
+ else
+ sorted_undefined_fun_symbols = elf_symbols();
}
return *sorted_undefined_fun_symbols;
}
@@ -446,10 +457,16 @@ corpus::priv::get_sorted_var_symbols() const
{
if (!sorted_var_symbols)
{
- auto filter = symtab_->make_filter();
- filter.set_variables();
+ if (symtab_)
+ {
+ auto filter = symtab_->make_filter();
+ filter.set_variables();
- sorted_var_symbols = elf_symbols(symtab_->begin(filter), symtab_->end());
+ sorted_var_symbols = elf_symbols(symtab_->begin(filter),
+ symtab_->end());
+ }
+ else
+ sorted_var_symbols = elf_symbols();
}
return *sorted_var_symbols;
}
@@ -483,13 +500,18 @@ corpus::priv::get_sorted_undefined_var_symbols() const
{
if (!sorted_undefined_var_symbols)
{
- auto filter = symtab_->make_filter();
- filter.set_variables();
- filter.set_undefined_symbols();
- filter.set_public_symbols(false);
+ if (symtab_)
+ {
+ auto filter = symtab_->make_filter();
+ filter.set_variables();
+ filter.set_undefined_symbols();
+ filter.set_public_symbols(false);
- sorted_undefined_var_symbols =
- elf_symbols(symtab_->begin(filter), symtab_->end());
+ sorted_undefined_var_symbols =
+ elf_symbols(symtab_->begin(filter), symtab_->end());
+ }
+ else
+ sorted_undefined_var_symbols = elf_symbols();
}
return *sorted_undefined_var_symbols;
}
--
2.31.1
--
Dodji
next prev parent reply other threads:[~2023-02-03 11:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 10:48 [PATCH, RFC] {dwarf,elf_based}-reader,writer: Avoid duplicating corpora in corpus_group Dodji Seketeli
2023-02-03 10:59 ` [PATCH 0/4] Fix duplicated corpora in corpus group Dodji Seketeli
2023-02-03 11:47 ` [PATCH 1/4] fe-iface: Add missing virtual destructor Dodji Seketeli
2023-02-03 11:47 ` [PATCH 2/4] dwarf-reader: Remove unused code Dodji Seketeli
2023-02-03 11:48 ` Dodji Seketeli [this message]
2023-02-03 11:49 ` [PATCH 4/4] {dwarf,elf_based}-reader,writer: Avoid duplicating corpora in corpus_group Dodji Seketeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877cwzt1f8.fsf_-_@redhat.com \
--to=dodji@redhat.com \
--cc=gprocida@google.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).