From: Dodji Seketeli <dodji@seketeli.org>
To: Mark Wielaard <mark@klomp.org>
Cc: libabigail@sourceware.org
Subject: Re: [PATCH] Add --drop-undefined-syms to abidw.
Date: Wed, 15 Apr 2020 14:48:55 +0200 [thread overview]
Message-ID: <877dygoqx4.fsf@seketeli.org> (raw)
In-Reply-To: <20200413014058.57109-1-mark@klomp.org> (Mark Wielaard's message of "Mon, 13 Apr 2020 03:40:58 +0200")
Hello Mark,
Mark Wielaard <mark@klomp.org> a écrit:
> Add a drop_undefined_syms properties to the read_context that
> indicates the reader wants to drop any undefined symbols (which don't
> have associated addresses in the corpus). Implement this for the
> dwarf_reader and abidw (when using the --drop-undefined-syms option).
>
> * include/abg-dwarf-reader.h (set_drop_undefined_syms):
> New declaration.
> * src/abg-dwarf-reader.cc (class read_context): Add private
> bool drop_undefined_syms_.
> (drop_undefined_syms): New getter and setter method.
> (set_drop_undefined_syms): New function.
> (function_is_suppressed): Check drop_undefined_syms on
> read_context.
> (variable_is_suppressed): Likewise.
> * src/abg-reader.cc (read_context): Add private bool
> m_drop_undefined_syms.
> (drop_undefined_syms): New getter and setter method.
> * tools/abidw.cc (struct options): Add drop_undefined_syms.
> (display_usage): Print --drop-undefined-syms.
> (parse_command_line): Parse --drop-undefined-syms.
> (main): Call set_drop_undefined_syms.
I have applied this to master. I have just fixed a few things that I
discuss below.
[...]
> diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
> index 249e196d..f74fb144 100644
> --- a/src/abg-dwarf-reader.cc
> +++ b/src/abg-dwarf-reader.cc
[...]
> /// This flag tells if we should emit verbose logs for various
> @@ -16683,7 +16714,9 @@ function_is_suppressed(const read_context& ctxt,
> string qualified_name = build_qualified_name(scope, fname);
>
> // A non-member function which symbol is not exported is suppressed.
> - if (!is_class_type(scope) && !die_is_declaration_only(function_die))
> + // Or if the reader context drops undefined symbols.
> + if ((!is_class_type(scope) && !die_is_declaration_only(function_die))
> + || ctxt.drop_undefined_syms())
> {
For languages like C++, we don't want to remove member functions (those
that are at class scope) even if they don't have defined symbols (e.g,
inline member functions). So here is how I am writing this:
// A non-member non-static function which symbol is not exported is
// suppressed.
//
// Note that if the non-member non-static function has an undefined
// symbol, by default, it's not suppressed. Unless we are asked to
// drop undefined symbols too.
if (!is_class_type(scope)
&& (!die_is_declaration_only(function_die)
|| ctxt.drop_undefined_syms()))
{
[...]
> @@ -16798,7 +16831,10 @@ variable_is_suppressed(const read_context& ctxt,
> // another concrete variable, then this function looks at
> // suppression specification specifications to know if its
> // suppressed.
> - if (!is_class_type(scope) && !is_required_decl_spec)
> + //
> + // Or if the reader context drops undefined symbols.
> + if ((!is_class_type(scope) && !is_required_decl_spec)
> + || ctxt.drop_undefined_syms())
> {
So, right now, undefined variable (unlike for functions) are dropped
from the IR, unless they are data members or declaration of static data
members. So we don't need the ctxt.drop_undefined_syms() here. So I
re-wrote this as:
// If a non member variable that is a declaration (has no defined
// and exported symbol) and is not the specification of another
// concrete variable, then it's suppressed. This is a size
// optimization; it removes useless declaration-only variables from
// the IR.
if (!is_class_type(scope) && !is_required_decl_spec)
{
[...]
Thanks!
Cheers,
--
Dodji
prev parent reply other threads:[~2020-04-15 12:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-05 20:08 How to drop all non-global/defined function declarations? Mark Wielaard
2020-04-07 9:38 ` Dodji Seketeli
2020-04-08 15:02 ` Mark Wielaard
2020-04-10 8:48 ` Dodji Seketeli
2020-04-13 1:39 ` Mark Wielaard
2020-04-13 1:40 ` [PATCH] Add --drop-undefined-syms to abidw Mark Wielaard
2020-04-15 12:48 ` Dodji Seketeli [this message]
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=877dygoqx4.fsf@seketeli.org \
--to=dodji@seketeli.org \
--cc=libabigail@sourceware.org \
--cc=mark@klomp.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).