summaryrefslogtreecommitdiff
path: root/tools/gold/gold-plugin.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-06-18 19:18:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-06-18 19:18:58 +0000
commitdd76f18f90f3d9934353d852e45271b3be747743 (patch)
tree31dfb8154f331f269bd1f38f9a212bd7680de4b7 /tools/gold/gold-plugin.cpp
parente0f0c7b024f4c884b0671cb4e137dffc92a53b5e (diff)
downloadllvm-dd76f18f90f3d9934353d852e45271b3be747743.tar.gz
llvm-dd76f18f90f3d9934353d852e45271b3be747743.tar.bz2
llvm-dd76f18f90f3d9934353d852e45271b3be747743.tar.xz
Add a pass-through option to the plugin. The use case for this option is to
ask the linker to take another look into some library or object. The case when one might want to do this is when codegen introduces a new undefined reference. The canonical example is libgcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106303 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gold/gold-plugin.cpp')
-rw-r--r--tools/gold/gold-plugin.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 15df7d0315..c8542b1752 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -41,6 +41,7 @@ namespace {
ld_plugin_add_symbols add_symbols = NULL;
ld_plugin_get_symbols get_symbols = NULL;
ld_plugin_add_input_file add_input_file = NULL;
+ ld_plugin_add_input_library add_input_library = NULL;
ld_plugin_message message = discard_message;
int api_version = 0;
@@ -64,6 +65,7 @@ namespace options {
static generate_bc generate_bc_file = BC_NO;
static std::string bc_path;
static std::string as_path;
+ static std::vector<std::string> pass_through;
// Additional options to pass into the code generator.
// Note: This array will contain all plugin options which are not claimed
// as plugin exclusive to pass to the code generator.
@@ -86,6 +88,9 @@ namespace options {
} else {
as_path = opt.substr(strlen("as="));
}
+ } else if (opt.startswith("pass-through=")) {
+ llvm::StringRef item = opt.substr(strlen("pass-through="));
+ pass_through.push_back(item.str());
} else if (opt == "emit-llvm") {
generate_bc_file = BC_ONLY;
} else if (opt == "also-emit-llvm") {
@@ -190,6 +195,9 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
case LDPT_ADD_INPUT_FILE:
add_input_file = tv->tv_u.tv_add_input_file;
break;
+ case LDPT_ADD_INPUT_LIBRARY:
+ add_input_library = tv->tv_u.tv_add_input_file;
+ break;
case LDPT_MESSAGE:
message = tv->tv_u.tv_message;
break;
@@ -437,6 +445,24 @@ static ld_plugin_status all_symbols_read_hook(void) {
return LDPS_ERR;
}
+ for (std::vector<std::string>::iterator i = options::pass_through.begin(),
+ e = options::pass_through.end();
+ i != e; ++i) {
+ std::string &item = *i;
+ char *item_p = const_cast<char*>(item.c_str());
+ if (llvm::StringRef(item).startswith("-l")) {
+ if (add_input_library(item_p + 2) != LDPS_OK) {
+ (*message)(LDPL_ERROR, "Unable to add library to the link.");
+ return LDPS_ERR;
+ }
+ } else {
+ if (add_input_file(item_p) != LDPS_OK) {
+ (*message)(LDPL_ERROR, "Unable to add .o file to the link.");
+ return LDPS_ERR;
+ }
+ }
+ }
+
Cleanup.push_back(uniqueObjPath);
return LDPS_OK;