aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog17
-rw-r--r--gold/options.cc25
-rw-r--r--gold/options.h10
-rw-r--r--gold/plugin.cc33
-rw-r--r--gold/plugin.h28
-rw-r--r--gold/testsuite/Makefile.am2
-rw-r--r--gold/testsuite/Makefile.in2
7 files changed, 80 insertions, 37 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 7d0d9cc..fbad1ee 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,20 @@
+2008-12-05 Rafael Avila de Espindola <espindola@google.com>
+
+ * options.cc (General_options::parse_plugin_opt): New.
+ (General_options::add_plugin): The argument now is just the filename.
+ (General_options::add_plugin_option): New.
+ * options.h (plugin_opt): New.
+ (add_plugin): Change argument name.
+ (add_plugin_option): New.
+ * plugin.cc (Plugin::load): Don't parse the plugin option.
+ * plugin.h (Plugin::Plugin): Rename argument. Init filename_.
+ (Plugin::add_option): New.
+ (Plugin::args_): Change type.
+ (Plugin::filename_): New.
+ (Plugin_manager::add_plugin_option): New.
+ * testsuite/Makefile.am (plugin_test_1): Use new syntax.
+ * testsuite/Makefile.in: Regenerate.
+
2008-12-05 Cary Coutant <ccoutant@google.com>
* layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
diff --git a/gold/options.cc b/gold/options.cc
index 90fa163..6b2b5cf 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -304,6 +304,15 @@ General_options::parse_plugin(const char*, const char* arg,
{
this->add_plugin(arg);
}
+
+// Parse --plugin-opt.
+
+void
+General_options::parse_plugin_opt(const char*, const char* arg,
+ Command_line*)
+{
+ this->add_plugin_option(arg);
+}
#endif // ENABLE_PLUGINS
void
@@ -650,14 +659,24 @@ General_options::add_sysroot()
free(canonical_sysroot);
}
-// Add a plugin and its arguments to the list of plugins.
+// Add a plugin to the list of plugins.
void
-General_options::add_plugin(const char* arg)
+General_options::add_plugin(const char* filename)
{
if (this->plugins_ == NULL)
this->plugins_ = new Plugin_manager(*this);
- this->plugins_->add_plugin(arg);
+ this->plugins_->add_plugin(filename);
+}
+
+// Add a plugin option to a plugin.
+
+void
+General_options::add_plugin_option(const char* arg)
+{
+ if (this->plugins_ == NULL)
+ gold_fatal("--plugin-opt requires --plugin.");
+ this->plugins_->add_plugin_option(arg);
}
// Set up variables and other state that isn't set up automatically by
diff --git a/gold/options.h b/gold/options.h
index f92184f..8d936d0 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -704,7 +704,9 @@ class General_options
#ifdef ENABLE_PLUGINS
DEFINE_special(plugin, options::TWO_DASHES, '\0',
- N_("Load a plugin library"), N_("PLUGIN[,ARG,...]"));
+ N_("Load a plugin library"), N_("PLUGIN"));
+ DEFINE_special(plugin_opt, options::TWO_DASHES, '\0',
+ N_("Pass an option to the plugin"), N_("OPTION"));
#endif
DEFINE_bool(preread_archive_symbols, options::TWO_DASHES, '\0', false,
@@ -991,7 +993,11 @@ class General_options
// Add a plugin and its arguments to the list of plugins.
void
- add_plugin(const char* arg);
+ add_plugin(const char *filename);
+
+ // Add a plugin option.
+ void
+ add_plugin_option(const char* opt);
// Whether to mark the stack as executable.
Execstack execstack_status_;
diff --git a/gold/plugin.cc b/gold/plugin.cc
index 1b0eb01..9056a3b 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -85,31 +85,13 @@ void
Plugin::load()
{
#ifdef ENABLE_PLUGINS
- std::string filename;
- std::vector<std::string> args;
-
- // Parse the filename and arguments, each separated by commas.
- // FIXME: Temporarily allowing semicolon as an argument separator
- // so args can be passed through gcc's -Wl,... option, which
- // breaks arguments at the commas.
- const char* p = this->args_;
- int n = strcspn(p, ",;");
- filename.assign(p, n);
- p += n;
- while (*p == ',' || *p == ';')
- {
- ++p;
- n = strcspn(p, ",;");
- args.push_back(std::string(p, n));
- p += n;
- }
-
// Load the plugin library.
// FIXME: Look for the library in standard locations.
- this->handle_ = dlopen(filename.c_str(), RTLD_NOW);
+ this->handle_ = dlopen(this->filename_.c_str(), RTLD_NOW);
if (this->handle_ == NULL)
{
- gold_error(_("%s: could not load plugin library"), filename.c_str());
+ gold_error(_("%s: could not load plugin library"),
+ this->filename_.c_str());
return;
}
@@ -118,7 +100,8 @@ Plugin::load()
(dlsym(this->handle_, "onload"));
if (onload == NULL)
{
- gold_error(_("%s: could not find onload entry point"), filename.c_str());
+ gold_error(_("%s: could not find onload entry point"),
+ this->filename_.c_str());
return;
}
@@ -130,7 +113,7 @@ Plugin::load()
// Allocate and populate a transfer vector.
const int tv_fixed_size = 11;
- int tv_size = args.size() + tv_fixed_size;
+ int tv_size = this->args_.size() + tv_fixed_size;
ld_plugin_tv *tv = new ld_plugin_tv[tv_size];
int i = 0;
@@ -150,11 +133,11 @@ Plugin::load()
else
tv[i].tv_u.tv_val = LDPO_EXEC;
- for (unsigned int j = 0; j < args.size(); ++j)
+ for (unsigned int j = 0; j < this->args_.size(); ++j)
{
++i;
tv[i].tv_tag = LDPT_OPTION;
- tv[i].tv_u.tv_string = args[j].c_str();
+ tv[i].tv_u.tv_string = this->args_[j].c_str();
}
++i;
diff --git a/gold/plugin.h b/gold/plugin.h
index 3f573ce..5b6fa1f 100644
--- a/gold/plugin.h
+++ b/gold/plugin.h
@@ -48,9 +48,10 @@ class Pluginobj;
class Plugin
{
public:
- Plugin(const char* args)
+ Plugin(const char* filename)
: handle_(NULL),
- args_(args),
+ filename_(filename),
+ args_(),
claim_file_handler_(NULL),
all_symbols_read_handler_(NULL),
cleanup_handler_(NULL)
@@ -90,6 +91,13 @@ class Plugin
set_cleanup_handler(ld_plugin_cleanup_handler handler)
{ this->cleanup_handler_ = handler; }
+ // Add an argument
+ void
+ add_option(const char *arg)
+ {
+ this->args_.push_back(arg);
+ }
+
private:
Plugin(const Plugin&);
Plugin& operator=(const Plugin&);
@@ -97,7 +105,9 @@ class Plugin
// The shared library handle returned by dlopen.
void* handle_;
// The argument string given to --plugin.
- const char* args_;
+ std::string filename_;
+ // The list of argument string given to --plugin-opt.
+ std::vector<std::string> args_;
// The plugin's event handlers.
ld_plugin_claim_file_handler claim_file_handler_;
ld_plugin_all_symbols_read_handler all_symbols_read_handler_;
@@ -119,8 +129,16 @@ class Plugin_manager
// Add a plugin library.
void
- add_plugin(const char* args)
- { this->plugins_.push_back(new Plugin(args)); }
+ add_plugin(const char* filename)
+ { this->plugins_.push_back(new Plugin(filename)); }
+
+ // Add an argument to the current plugin.
+ void
+ add_plugin_option(const char* opt)
+ {
+ Plugin* last = this->plugins_.back();
+ last->add_option(opt);
+ }
// Load all plugin libraries.
void
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index dcb8bad..78c0529 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -959,7 +959,7 @@ check_SCRIPTS += plugin_test_1.sh
check_DATA += plugin_test_1.err
MOSTLYCLEANFILES += plugin_test_1.err
plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
- $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
plugin_test_1.err: plugin_test_1
@touch plugin_test_1.err
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 7271bb0..bb9d0ce 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -2454,7 +2454,7 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1.err: plugin_test_1
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_1.err
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so