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] |
On Mon, Nov 27, 2017 at 10:31 PM, Cary Coutant <ccoutant@gmail.com> wrote: >>> 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.) I have attached the patch with those changes. * plugin.cc (get_wrap_symbols): New plugin interface. (load): Add get_wrap_symbols to transfer vector. * plugin-api.h (ld_plugin_get_wrap_symbols): New plugin interface. * options.h (options::String_set::size_type): New macro function. * testsuite/plugin_test.c (onload): Call and check get_wrap_symbols interface. * testsuite/plugin_test_wrap_symbols.sh: New test script. * testsuite/plugin_test_wrap_symbols_1.cc: New file. * testsuite/plugin_test_wrap_symbols_2.cc: New file. * testsuite/Makefile.am (plugin_test_wrap_symbols): New test. * testsuite/Makefile.in: Regenerate. Thanks Sri > > -cary
Attachment:
plugin_wrap_symbol_patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |