aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-01-04 05:35:24 +0000
committerIan Lance Taylor <iant@google.com>2008-01-04 05:35:24 +0000
commitfced7afdce32a299d799f52ebd92a92572c2f9f5 (patch)
treea516bc2854971865b63f828e7ec9be8e865be6f1 /gold
parentDon't create the postprocessing buffer if it already exists. (diff)
downloadbinutils-gdb-fced7afdce32a299d799f52ebd92a92572c2f9f5.tar.gz
binutils-gdb-fced7afdce32a299d799f52ebd92a92572c2f9f5.tar.bz2
binutils-gdb-fced7afdce32a299d799f52ebd92a92572c2f9f5.zip
Add -h/-soname option.
Diffstat (limited to 'gold')
-rw-r--r--gold/layout.cc7
-rw-r--r--gold/options.cc4
-rw-r--r--gold/options.h10
3 files changed, 21 insertions, 0 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index eebb26c5686..75aecfe2b5d 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -1713,6 +1713,13 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
odyn->add_string(elfcpp::DT_NEEDED, (*p)->soname());
}
+ if (parameters->output_is_shared())
+ {
+ const char* soname = this->options_.soname();
+ if (soname != NULL)
+ odyn->add_string(elfcpp::DT_SONAME, soname);
+ }
+
// FIXME: Support --init and --fini.
Symbol* sym = symtab->lookup("_init");
if (sym != NULL && sym->is_defined() && !sym->is_from_dynobj())
diff --git a/gold/options.cc b/gold/options.cc
index 20ddc6ad386..c3f174718bb 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -399,6 +399,9 @@ options::Command_line_options::options[] =
NULL, TWO_DASHES, &General_options::set_export_dynamic),
GENERAL_NOARG('\0', "eh-frame-hdr", N_("Create exception frame header"),
NULL, TWO_DASHES, &General_options::set_create_eh_frame_hdr),
+ GENERAL_ARG('h', "soname", N_("Set shared library name"),
+ N_("-h FILENAME, --soname FILENAME"), ONE_DASH,
+ &General_options::set_soname),
GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"),
N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES,
&General_options::set_dynamic_linker),
@@ -528,6 +531,7 @@ const int options::Command_line_options::debug_options_size =
General_options::General_options()
: export_dynamic_(false),
+ soname_(NULL),
dynamic_linker_(NULL),
search_path_(),
optimization_level_(0),
diff --git a/gold/options.h b/gold/options.h
index cae1b1a4750..86d9bd7b6b2 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -113,6 +113,11 @@ class General_options
export_dynamic() const
{ return this->export_dynamic_; }
+ // -h: shared library name.
+ const char*
+ soname() const
+ { return this->soname_; }
+
// -I: dynamic linker name.
const char*
dynamic_linker() const
@@ -311,6 +316,10 @@ class General_options
{ this->export_dynamic_ = true; }
void
+ set_soname(const char* arg)
+ { this->soname_ = arg; }
+
+ void
set_dynamic_linker(const char* arg)
{ this->dynamic_linker_ = arg; }
@@ -501,6 +510,7 @@ class General_options
add_sysroot();
bool export_dynamic_;
+ const char* soname_;
const char* dynamic_linker_;
Dir_list search_path_;
int optimization_level_;