diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2020-06-05 18:15:26 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2020-07-22 18:02:18 +0100 |
commit | 6dd2819ffc282e644e7feb476cc803d4f39d9f17 (patch) | |
tree | cbbc466b022a0c522c03f398e374e12aa7ab6655 /libctf/ctf-link.c | |
parent | 19d4b1addcafc786360c31d02d5ef2b44aef3152 (diff) | |
download | fsf-binutils-gdb-6dd2819ffc282e644e7feb476cc803d4f39d9f17.zip fsf-binutils-gdb-6dd2819ffc282e644e7feb476cc803d4f39d9f17.tar.gz fsf-binutils-gdb-6dd2819ffc282e644e7feb476cc803d4f39d9f17.tar.bz2 |
libctf, link: add the ability to filter out variables from the link
The CTF variables section (containing variables that have no
corresponding symtab entries) can cause the string table to get very
voluminous if the names of variables are long. Some callers want to
filter out particular variables they know they won't need.
So add a "variable filter" callback that does that: it's passed the name
of the variable and a corresponding ctf_file_t / ctf_id_t pair, and
should return 1 to filter it out.
ld doesn't use this machinery yet, but we could easily add it later if
desired. (But see later for a commit that turns off CTF variable-
section linking in ld entirely by default.)
include/
* ctf-api.h (ctf_link_variable_filter_t): New.
(ctf_link_set_variable_filter): Likewise.
libctf/
* libctf.ver (ctf_link_set_variable_filter): Add.
* ctf-impl.h (ctf_file_t) <ctf_link_variable_filter>: New.
<ctf_link_variable_filter_arg>: Likewise.
* ctf-create.c (ctf_serialize): Adjust.
* ctf-link.c (ctf_link_set_variable_filter): New, set it.
(ctf_link_one_variable): Call it if set.
Diffstat (limited to 'libctf/ctf-link.c')
-rw-r--r-- | libctf/ctf-link.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index 7b0ac38..886106c 100644 --- a/libctf/ctf-link.c +++ b/libctf/ctf-link.c @@ -528,6 +528,16 @@ ctf_link_one_type (ctf_id_t type, int isroot _libctf_unused_, void *arg_) return 0; /* As above: do not lose types. */ } +/* Set a function which is used to filter out unwanted variables from the link. */ +int +ctf_link_set_variable_filter (ctf_file_t *fp, ctf_link_variable_filter_f *filter, + void *arg) +{ + fp->ctf_link_variable_filter = filter; + fp->ctf_link_variable_filter_arg = arg; + return 0; +} + /* Check if we can safely add a variable with the given type to this container. */ static int @@ -564,6 +574,15 @@ ctf_link_one_variable (const char *name, ctf_id_t type, void *arg_) ctf_file_t *check_fp; ctf_dvdef_t *dvd; + /* See if this variable is filtered out. */ + + if (arg->out_fp->ctf_link_variable_filter) + { + void *farg = arg->out_fp->ctf_link_variable_filter_arg; + if (arg->out_fp->ctf_link_variable_filter (arg->in_fp, name, type, farg)) + return 0; + } + /* In unconflicted link mode, if this type is mapped to a type in the parent container, we want to try to add to that first: if it reports a duplicate, or if the type is in a child already, add straight to the child. */ |