This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: New gold plugin interface for getting --wrap symbols
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: binutils <binutils at sourceware dot org>, Xinliang David Li <davidxl at google dot com>, Teresa Johnson <tejohnson at google dot com>
- Date: Mon, 27 Nov 2017 22:31:39 -0800
- Subject: Re: New gold plugin interface for getting --wrap symbols
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8Hmzq+11BitwNknrA8o6GNPXiWK+7asWU8rBaFRcsMs16_Q@mail.gmail.com> <CAAs8HmxjaR087175sZRAa19VUz6xca4j+oE8riH2uf0qRhStUA@mail.gmail.com>
>> LLVM ThinLTO needs a gold plugin API to get the list of symbols that
>> are wrapped using the --wrap option to avoid garbage collection of some of
>> the associated functions like __wrap_symbol and __real_symbol.
>>
>> This patch adds an interface, get_wrap_symbols, to get the count and
>> the list of symbols that are wrapped.
There's a difference between the list of --wrap options passed to the
linker (which is what this API returns), and a list of which symbols
actually got wrapped. How is this useful compared to simply
pattern-matching for symbols whose name begins with "__wrap" and
"__real" (which will give you the symbols that were actually wrapped)?
Assuming this is what you want...
+ std::vector<const char *> wrapped_symbols;
+ uint64_t total = 0;
+
+ for (options::String_set::const_iterator
+ it = parameters->options().wrap_begin();
+ it != parameters->options().wrap_end(); ++it) {
+ total++;
+ wrapped_symbols.push_back(it->c_str());
+ }
total is redundant -- just use wrapped_symbols.size().
Furthermore, if you add an extra member function to DEFINE_set that
exposes the String_set::size() method, e.g.:
options::String_set::size_type
varname__##_size() const
{ return this->varname__##_.value.size(); }
... you could avoid copying to and from the intermediate vector.
(I *think* all of the various alternative implementations we might use
for Unordered_set provide a constant-time size() method.)
-cary