aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-08-21 20:37:32 +0000
committerIan Lance Taylor <iant@google.com>2007-08-21 20:37:32 +0000
commit41f542e70b89b9ea2875c438b0c9a60ac46092dd (patch)
treee731637699fca298f82185865790dd38321e4f69 /gold/layout.cc
parentfcb7aa2f6b17eb5211fe4d361eab8d985c40065e (diff)
downloadgdb-41f542e70b89b9ea2875c438b0c9a60ac46092dd.zip
gdb-41f542e70b89b9ea2875c438b0c9a60ac46092dd.tar.gz
gdb-41f542e70b89b9ea2875c438b0c9a60ac46092dd.tar.bz2
Add support for -rpath.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index 62ba5f3..2f85db4 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -1148,6 +1148,35 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
odyn->add_symbol(elfcpp::DT_FINI, sym);
// FIXME: Support DT_INIT_ARRAY and DT_FINI_ARRAY.
+
+ // Add a DT_RPATH entry if needed.
+ const General_options::Dir_list& rpath(this->options_.rpath());
+ if (!rpath.empty())
+ {
+ std::string rpath_val;
+ for (General_options::Dir_list::const_iterator p = rpath.begin();
+ p != rpath.end();
+ ++p)
+ {
+ if (rpath_val.empty())
+ rpath_val = *p;
+ else
+ {
+ // Eliminate duplicates.
+ General_options::Dir_list::const_iterator q;
+ for (q = rpath.begin(); q != p; ++q)
+ if (strcmp(*q, *p) == 0)
+ break;
+ if (q == p)
+ {
+ rpath_val += ':';
+ rpath_val += *p;
+ }
+ }
+ }
+
+ odyn->add_string(elfcpp::DT_RPATH, rpath_val);
+ }
}
// The mapping of .gnu.linkonce section names to real section names.