aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-08-22 05:06:38 +0000
committerIan Lance Taylor <iant@google.com>2007-08-22 05:06:38 +0000
commita6badf5a97374debb5be7b7e6e624f409e14e00d (patch)
tree5becd23e990a6d3cc72b377591a6652673fb1b72
parent6b2d86bda4d98894598f17fb8682e7cd4eafd833 (diff)
downloadgdb-a6badf5a97374debb5be7b7e6e624f409e14e00d.zip
gdb-a6badf5a97374debb5be7b7e6e624f409e14e00d.tar.gz
gdb-a6badf5a97374debb5be7b7e6e624f409e14e00d.tar.bz2
Add support for -E/--export-dynamic. Also clean up --help output a bit.
-rw-r--r--gold/options.cc16
-rw-r--r--gold/options.h10
-rw-r--r--gold/symtab.cc5
-rw-r--r--gold/symtab.h8
4 files changed, 33 insertions, 6 deletions
diff --git a/gold/options.cc b/gold/options.cc
index 0b858a2..12703bd 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -138,6 +138,7 @@ help(int, char**, char*, gold::Command_line*)
}
printf(options[j].help_output);
len += std::strlen(options[i].help_output);
+ comma = true;
}
else
{
@@ -150,6 +151,7 @@ help(int, char**, char*, gold::Command_line*)
}
printf("-%c", options[j].short_option);
len += 2;
+ comma = true;
}
if (options[j].long_option != NULL)
@@ -171,13 +173,14 @@ help(int, char**, char*, gold::Command_line*)
}
printf("%s", options[j].long_option);
len += std::strlen(options[j].long_option);
+ comma = true;
}
}
++j;
}
while (j < options_size && options[j].doc == NULL);
- if (len > 30)
+ if (len >= 30)
{
printf("\n");
len = 0;
@@ -225,12 +228,14 @@ const options::One_option
options::Command_line_options::options[] =
{
SPECIAL('l', "library", N_("Search for library LIBNAME"),
- N_("-lLIBNAME --library LIBNAME"), TWO_DASHES,
+ N_("-lLIBNAME, --library LIBNAME"), TWO_DASHES,
&library),
SPECIAL('(', "start-group", N_("Start a library search group"), NULL,
TWO_DASHES, &start_group),
SPECIAL(')', "end-group", N_("End a library search group"), NULL,
TWO_DASHES, &end_group),
+ GENERAL_NOARG('E', "export-dynamic", N_("Export all dynamic symbols"),
+ NULL, TWO_DASHES, &General_options::set_export_dynamic),
GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"),
N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES,
&General_options::set_dynamic_linker),
@@ -252,10 +257,10 @@ options::Command_line_options::options[] =
GENERAL_NOARG('\0', "static", N_("Do not link against shared libraries"),
NULL, ONE_DASH, &General_options::set_static),
POSDEP_NOARG('\0', "as-needed",
- N_("Only set DT_NEEDED for following dynamic libs if used"),
+ N_("Only set DT_NEEDED for dynamic libs if used"),
NULL, TWO_DASHES, &Position_dependent_options::set_as_needed),
POSDEP_NOARG('\0', "no-as-needed",
- N_("Always DT_NEEDED for following dynamic libs (default)"),
+ N_("Always DT_NEEDED for dynamic libs (default)"),
NULL, TWO_DASHES, &Position_dependent_options::clear_as_needed),
POSDEP_NOARG('\0', "whole-archive",
N_("Include all archive contents"),
@@ -275,7 +280,8 @@ const int options::Command_line_options::options_size =
// The default values for the general options.
General_options::General_options()
- : dynamic_linker_(NULL),
+ : export_dynamic_(false),
+ dynamic_linker_(NULL),
search_path_(),
output_file_name_("a.out"),
is_relocatable_(false),
diff --git a/gold/options.h b/gold/options.h
index 3c13deb..05203b1 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -37,6 +37,11 @@ class General_options
public:
General_options();
+ // -E: export dynamic symbols.
+ bool
+ export_dynamic() const
+ { return this->export_dynamic_; }
+
// -I: dynamic linker name.
const char*
dynamic_linker() const
@@ -83,6 +88,10 @@ class General_options
friend class options::Command_line_options;
void
+ set_export_dynamic()
+ { this->export_dynamic_ = true; }
+
+ void
set_dynamic_linker(const char* arg)
{ this->dynamic_linker_ = arg; }
@@ -114,6 +123,7 @@ class General_options
ignore(const char*)
{ }
+ bool export_dynamic_;
const char* dynamic_linker_;
Dir_list search_path_;
const char* output_file_name_;
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 01e000d..70fa890 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -1001,7 +1001,10 @@ Symbol_table::set_dynsym_indexes(const General_options* options,
// some symbols appear more than once in the symbol table, with
// and without a version.
- if (!sym->needs_dynsym_entry())
+ if (!sym->needs_dynsym_entry()
+ && (!options->export_dynamic()
+ || !sym->in_reg()
+ || !sym->is_externally_visible()))
sym->set_dynsym_index(-1U);
else if (!sym->has_dynsym_index())
{
diff --git a/gold/symtab.h b/gold/symtab.h
index 66e98bc..cba97d0 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -337,6 +337,14 @@ class Symbol
|| this->type_ == elfcpp::STT_COMMON));
}
+ // Return whether this symbol can be seen outside this object.
+ bool
+ is_externally_visible() const
+ {
+ return (this->visibility_ == elfcpp::STV_DEFAULT
+ || this->visibility_ == elfcpp::STV_PROTECTED);
+ }
+
// Return whether there should be a warning for references to this
// symbol.
bool