diff options
author | Craig Silverstein <csilvers@google.com> | 2009-09-18 20:03:22 +0000 |
---|---|---|
committer | Craig Silverstein <csilvers@google.com> | 2009-09-18 20:03:22 +0000 |
commit | 8c60465154ed694fac2531f65e7ca1ae51093174 (patch) | |
tree | 5b1e1c166e0d5f50c40988974cf4a87e9dfcb216 /gold/options.cc | |
parent | f43030c448dc1938d6fc7a6072f1a76853b1b70d (diff) | |
download | gdb-8c60465154ed694fac2531f65e7ca1ae51093174.zip gdb-8c60465154ed694fac2531f65e7ca1ae51093174.tar.gz gdb-8c60465154ed694fac2531f65e7ca1ae51093174.tar.bz2 |
* object.cc (Sized_relobj::do_count): Test should_retain_symbol map.
* options.cc: Include <cerrno> and <fstream>.
(General_options::finalize): Parse -retain-symbols-file tag.
* options.h: New flag.
(General_options): New method should_retain_symbol, new
variable symbols_to_retain.
* symtab.cc (Symbol_table::sized_finalize_symbol): Test
should_retain_symbol map.
* testsuite/Makefile.am (retain_symbols_file_test): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain_symbols_file_test.sh: New file.
Diffstat (limited to 'gold/options.cc')
-rw-r--r-- | gold/options.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gold/options.cc b/gold/options.cc index bf420c6..bf3eb55 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -22,8 +22,10 @@ #include "gold.h" +#include <cerrno> #include <cstdlib> #include <cstring> +#include <fstream> #include <vector> #include <iostream> #include <sys/stat.h> @@ -938,6 +940,25 @@ General_options::finalize() this->add_to_library_path_with_sysroot("/usr/lib"); } + // Parse the contents of -retain-symbols-file into a set. + if (this->retain_symbols_file()) + { + std::ifstream in; + in.open(this->retain_symbols_file()); + if (!in) + gold_fatal(_("unable to open -retain-symbols-file file %s: %s"), + this->retain_symbols_file(), strerror(errno)); + std::string line; + std::getline(in, line); // this chops off the trailing \n, if any + while (in) + { + if (!line.empty() && line[line.length() - 1] == '\r') // Windows + line.resize(line.length() - 1); + this->symbols_to_retain_.insert(line); + std::getline(in, line); + } + } + if (this->shared() && !this->user_set_allow_shlib_undefined()) this->set_allow_shlib_undefined(true); @@ -952,6 +973,10 @@ General_options::finalize() if (this->shared() && this->relocatable()) gold_fatal(_("-shared and -r are incompatible")); + // TODO: implement support for -retain-symbols-file with -r, if needed. + if (this->relocatable() && this->retain_symbols_file()) + gold_fatal(_("-retain-symbols-file does not yet work with -r")); + if (this->oformat_enum() != General_options::OBJECT_FORMAT_ELF && (this->shared() || this->relocatable())) gold_fatal(_("binary output format not compatible with -shared or -r")); |