This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New gold plugin interface for getting --wrap symbols


>>      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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]