summaryrefslogtreecommitdiffstats
path: root/tools/gold
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
commit7ff99155c39edd73ebf1c6adfa023b1048fee9a4 (patch)
treeb4dc751bcee540346911aa4115729eff2f991657 /tools/gold
parentd1f06de484602e72707476a6152974847bac1570 (diff)
downloadFreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.zip
FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.tar.gz
Update LLVM to r86025.
Diffstat (limited to 'tools/gold')
-rw-r--r--tools/gold/gold-plugin.cpp64
1 files changed, 44 insertions, 20 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index b1562d1..0e1db1b 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -46,9 +46,6 @@ namespace {
int api_version = 0;
int gold_version = 0;
- bool generate_api_file = false;
- const char *as_path = NULL;
-
struct claimed_file {
lto_module_t M;
void *handle;
@@ -60,6 +57,37 @@ namespace {
std::vector<sys::Path> Cleanup;
}
+namespace options {
+ bool generate_api_file = false;
+ const char *as_path = NULL;
+ // 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.
+ // For example, "generate-api-file" and "as"options are for the plugin
+ // use only and will not be passed.
+ std::vector<std::string> extra;
+
+ void process_plugin_option(const char* opt)
+ {
+ if (opt == NULL)
+ return;
+
+ if (strcmp("generate-api-file", opt) == 0) {
+ generate_api_file = true;
+ } else if (strncmp("as=", opt, 3) == 0) {
+ if (as_path) {
+ (*message)(LDPL_WARNING, "Path to as specified twice. "
+ "Discarding %s", opt);
+ } else {
+ as_path = strdup(opt + 3);
+ }
+ } else {
+ // Save this option to pass to the code generator.
+ extra.push_back(std::string(opt));
+ }
+ }
+}
+
ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
int *claimed);
ld_plugin_status all_symbols_read_hook(void);
@@ -103,18 +131,7 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
//output_type = LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC;
break;
case LDPT_OPTION:
- if (strcmp("generate-api-file", tv->tv_u.tv_string) == 0) {
- generate_api_file = true;
- } else if (strncmp("as=", tv->tv_u.tv_string, 3) == 0) {
- if (as_path) {
- (*message)(LDPL_WARNING, "Path to as specified twice. "
- "Discarding %s", tv->tv_u.tv_string);
- } else {
- as_path = strdup(tv->tv_u.tv_string + 3);
- }
- } else {
- (*message)(LDPL_WARNING, "Ignoring flag %s", tv->tv_u.tv_string);
- }
+ options::process_plugin_option(tv->tv_u.tv_string);
break;
case LDPT_REGISTER_CLAIM_FILE_HOOK: {
ld_plugin_register_claim_file callback;
@@ -307,7 +324,7 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_add_module(cg, I->M);
std::ofstream api_file;
- if (generate_api_file) {
+ if (options::generate_api_file) {
api_file.open("apifile.txt", std::ofstream::out | std::ofstream::trunc);
if (!api_file.is_open()) {
(*message)(LDPL_FATAL, "Unable to open apifile.txt for writing.");
@@ -329,13 +346,13 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_add_must_preserve_symbol(cg, I->syms[i].name);
anySymbolsPreserved = true;
- if (generate_api_file)
+ if (options::generate_api_file)
api_file << I->syms[i].name << "\n";
}
}
}
- if (generate_api_file)
+ if (options::generate_api_file)
api_file.close();
if (!anySymbolsPreserved) {
@@ -347,10 +364,17 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_set_pic_model(cg, output_type);
lto_codegen_set_debug_model(cg, LTO_DEBUG_MODEL_DWARF);
- if (as_path) {
- sys::Path p = sys::Program::FindProgramByName(as_path);
+ if (options::as_path) {
+ sys::Path p = sys::Program::FindProgramByName(options::as_path);
lto_codegen_set_assembler_path(cg, p.c_str());
}
+ // Pass through extra options to the code generator.
+ if (!options::extra.empty()) {
+ for (std::vector<std::string>::iterator it = options::extra.begin();
+ it != options::extra.end(); ++it) {
+ lto_codegen_debug_options(cg, (*it).c_str());
+ }
+ }
size_t bufsize = 0;
const char *buffer = static_cast<const char *>(lto_codegen_compile(cg,
OpenPOWER on IntegriCloud