This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RFA: GOLD: Allow INPUT linker script commands to input libraries
- From: Nick Clifton <nickc at redhat dot com>
- To: ian at airs dot com
- Cc: binutils at sourceware dot org
- Date: Tue, 08 Jun 2010 12:57:25 +0100
- Subject: RFA: GOLD: Allow INPUT linker script commands to input libraries
Hi Ian,
Currently GOLD's implementation of the INPUT linker script command
does not support inputting libraries via the "-l<name>" syntax. This
is a problem as some current Linux libraries make use of this
feature. Eg the 64-bit version of the wide-character ncurses library
looks like this:
% cat /usr/lib64/libncursesw.so
INPUT(libncursesw.so.5 -ltinfo)
The attached patch is my poor attempt at adding support for this
feature. It works for the small test case I have been using locally,
but I would certainly some guidance as to whether it is acceptable for
inclusion into the gold sources.
(Incidentally I wanted to put the check for the 'l' character in the
"-l<name>" sequence into the yyscript.y file, but I could not get this
to work. I think that my bison-fu must be weak).
Cheers
Nick
gold/ChangeLog
2010-06-08 Nick Clifton <nickc@redhat.com>
* yyscript.y (input_list_element): Allow strings prefixed with
the '-' character. Treat these as libraries.
* script.cc (script_add_library): New function. Adds a library
specified by "-l<name>" found in an input script.
* script-c.h: Add prototype for script_add_library.
Index: gold/script-c.h
===================================================================
RCS file: /cvs/src/src/gold/script-c.h,v
retrieving revision 1.17
diff -c -3 -p -r1.17 script-c.h
*** gold/script-c.h 9 Apr 2010 17:32:58 -0000 1.17
--- gold/script-c.h 8 Jun 2010 11:46:22 -0000
*************** script_add_extern(void* closure, const c
*** 236,241 ****
--- 236,246 ----
extern void
script_add_file(void* closure, const char*, size_t);
+ /* Called by the bison parser to add a library to the link. */
+
+ extern void
+ script_add_library(void* closure, const char*, size_t);
+
/* Called by the bison parser to start and stop a group. */
extern void
Index: gold/script.cc
===================================================================
RCS file: /cvs/src/src/gold/script.cc,v
retrieving revision 1.72
diff -c -3 -p -r1.72 script.cc
*** gold/script.cc 18 May 2010 18:08:03 -0000 1.72
--- gold/script.cc 8 Jun 2010 11:46:22 -0000
*************** script_add_file(void* closurev, const ch
*** 2593,2598 ****
--- 2593,2616 ----
closure->inputs()->add_file(file);
}
+ // Called by the bison parser to add a library to the link.
+
+ extern "C" void
+ script_add_library(void* closurev, const char* name, size_t length)
+ {
+ Parser_closure* closure = static_cast<Parser_closure*>(closurev);
+ std::string name_string(name, length);
+
+ if (name_string[0] != 'l')
+ gold_error (_("library name must be prefixed with -l"));
+
+ Input_file_argument file(name_string.c_str() + 1,
+ Input_file_argument::INPUT_FILE_TYPE_LIBRARY,
+ "", false,
+ closure->position_dependent_options());
+ closure->inputs()->add_file(file);
+ }
+
// Called by the bison parser to start a group. If we are already in
// a group, that means that this script was invoked within a
// --start-group --end-group sequence on the command line, or that
Index: gold/yyscript.y
===================================================================
RCS file: /cvs/src/src/gold/yyscript.y,v
retrieving revision 1.23
diff -c -3 -p -r1.23 yyscript.y
*** gold/yyscript.y 9 Apr 2010 17:32:58 -0000 1.23
--- gold/yyscript.y 8 Jun 2010 11:46:22 -0000
*************** input_list:
*** 320,325 ****
--- 320,327 ----
input_list_element:
string
{ script_add_file(closure, $1.value, $1.length); }
+ | '-' STRING
+ { script_add_library(closure, $2.value, $2.length); }
| AS_NEEDED
{ script_start_as_needed(closure); }
'(' input_list ')'