This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH]: gold support for -Y and -relax
- From: Ian Lance Taylor <iant at google dot com>
- To: David Miller <davem at davemloft dot net>
- Cc: binutils at sourceware dot org
- Date: Fri, 11 Apr 2008 13:29:16 -0700
- Subject: Re: [PATCH]: gold support for -Y and -relax
- References: <20080410.174121.05169305.davem@davemloft.net>
David Miller <davem@davemloft.net> writes:
> 2008-04-10 David S. Miller <davem@davemloft.net>
>
> * options.h (General_options): Add entries for '-Y' and
> '-relax'.
> * options.cc (General_options::parse_Y): New.
> (General_options:finalize): If default_dirlist is non-NULL,
> add those entries to the library path instead of the
> default "/lib" and "/usr/lib".
I rewrote this code to be more C++ like, and committed it as follows.
Ian
2008-04-11 David S. Miller <davem@davemloft.net>
Ian Lance Taylor <iant@google.com>
* options.h (General_options): Add entries for '-Y' and
'-relax'.
* options.cc (General_options:finalize): If -Y was used, add those
entries to the library path instead of the default "/lib" and
"/usr/lib".
Index: options.cc
===================================================================
RCS file: /cvs/src/src/gold/options.cc,v
retrieving revision 1.68
diff -p -u -r1.68 options.cc
--- options.cc 9 Apr 2008 00:48:13 -0000 1.68
+++ options.cc 11 Apr 2008 20:27:02 -0000
@@ -717,10 +717,33 @@ General_options::finalize()
program_name);
#endif
- // Even if they don't specify it, we add -L /lib and -L /usr/lib.
- // FIXME: We should only do this when configured in native mode.
- this->add_to_library_path_with_sysroot("/lib");
- this->add_to_library_path_with_sysroot("/usr/lib");
+ if (this->user_set_Y())
+ {
+ std::string s = this->Y();
+ if (s.compare(0, 2, "P,") == 0)
+ s.erase(0, 2);
+
+ size_t pos = 0;
+ size_t next_pos;
+ do
+ {
+ next_pos = s.find(':', pos);
+ size_t len = (next_pos == std::string::npos
+ ? next_pos
+ : next_pos - pos);
+ if (len != 0)
+ this->add_to_library_path_with_sysroot(s.substr(pos, len).c_str());
+ pos = next_pos + 1;
+ }
+ while (next_pos != std::string::npos);
+ }
+ else
+ {
+ // Even if they don't specify it, we add -L /lib and -L /usr/lib.
+ // FIXME: We should only do this when configured in native mode.
+ this->add_to_library_path_with_sysroot("/lib");
+ this->add_to_library_path_with_sysroot("/usr/lib");
+ }
// Normalize library_path() by adding the sysroot to all directories
// in the path, as appropriate.
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.68
diff -p -u -r1.68 options.h
--- options.h 9 Apr 2008 01:19:09 -0000 1.68
+++ options.h 11 Apr 2008 20:27:02 -0000
@@ -556,6 +556,9 @@ class General_options
DEFINE_bool(relocatable, options::EXACTLY_ONE_DASH, 'r', false,
N_("Generate relocatable output"), NULL);
+ DEFINE_bool(relax, options::TWO_DASHES, '\0', false,
+ N_("Relax branches on certain targets"), NULL);
+
// -R really means -rpath, but can mean --just-symbols for
// compatibility with GNU ld. -rpath is always -rpath, so we list
// it separately.
@@ -626,6 +629,10 @@ class General_options
DEFINE_special(wrap, options::TWO_DASHES, '\0',
N_("Use wrapper functions for SYMBOL"), N_("SYMBOL"));
+ DEFINE_string(Y, options::EXACTLY_ONE_DASH, 'Y', "",
+ N_("Default search path for Solaris compatibility"),
+ N_("PATH"));
+
DEFINE_special(start_group, options::TWO_DASHES, '(',
N_("Start a library search group"), NULL);
DEFINE_special(end_group, options::TWO_DASHES, ')',