This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gold doesn't accept object file as script


Vladimir Simonov <sv@sw.ru> writes:

> According "man ld" "If the linker cannot recognize the format
> of an object file, it will assume that it is a linker script."
>
> But gold doesn't follow above. For details, see test case below.

That turns out not to be the case.  Gold does implement that.

> Briefly, the command "gcc -fuse-ld=gold -o a.4 -shared exports.ld a.a"
> if exports.ld is linker script leads to warning
> "exports.ld:1:8: ignoring command OPTION; OPTION is only valid for
> scripts specified via -T/--script" and resulted shared library
> doesn't contain func_a.
> exports.ld contains only EXTERN(func_a)

Internally gold implements EXTERN via OPTION, and as the warning says
gold only permits OPTION in a script specified via -T/--script.  So the
bug is that EXTERN is implemented as OPTION.

Fortunately, the fix is simple, as the necessary framework was
introduced for other reasons.  Would you mind giving this patch a try to
see if it fixes your problem?

Ian

Index: script.cc
===================================================================
RCS file: /cvs/src/src/gold/script.cc,v
retrieving revision 1.79
diff -u -p -r1.79 script.cc
--- script.cc	3 Nov 2010 17:18:23 -0000	1.79
+++ script.cc	25 Jan 2011 15:13:08 -0000
@@ -2576,12 +2576,8 @@ yyerror(void* closurev, const char* mess
 extern "C" void
 script_add_extern(void* closurev, const char* name, size_t length)
 {
-  // We treat exactly like -u NAME.  FIXME: If it seems useful, we
-  // could handle this after the command line has been read, by adding
-  // entries to the symbol table directly.
-  std::string arg("--undefined=");
-  arg.append(name, length);
-  script_parse_option(closurev, arg.c_str(), arg.size());
+  Parser_closure* closure = static_cast<Parser_closure*>(closurev);
+  closure->script_options()->add_symbol_reference(name, length);
 }
 
 // Called by the bison parser to add a file to the link.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]