This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
embedspu invocation
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Mon, 18 Jun 2007 11:52:48 +0930
- Subject: embedspu invocation
If a powerpc targetted binutils is built with spu support, ld can
automatically invoke embedspu when given an spu executable to link
into a powerpc binary. The various binutils tools may be installed
with a prefix, eg. ld may be installed as powerpc-linux-ld, embedspu
as powerpc-linux-embedspu. This teaches ld to invoke embedspu with
the right prefix.
ld/
* emultempl/spuelf.em: Deduce embedspu program name prefix from
that of ld.
Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.6
diff -u -p -r1.6 spuelf.em
--- ld/emultempl/spuelf.em 29 May 2007 13:10:10 -0000 1.6
+++ ld/emultempl/spuelf.em 16 Jun 2007 03:04:01 -0000
@@ -306,6 +306,8 @@ embedded_spu_file (lang_input_statement_
union lang_statement_union **old_file_tail;
union lang_statement_union *new_ent;
lang_input_statement_type *search;
+ const char *prefix;
+ size_t prefix_len;
if (entry->the_bfd->format != bfd_object
|| strcmp (entry->the_bfd->xvec->name, "elf32-spu") != 0
@@ -360,7 +362,23 @@ embedded_spu_file (lang_input_statement_
/* Use fork() and exec() rather than system() so that we don't
need to worry about quoting args. */
- cmd[0] = "embedspu";
+ prefix = base_name (program_name);
+ prefix_len = strlen (prefix);
+ if (prefix_len > 2
+ && (prefix[prefix_len - 2] == 'l'
+ || prefix[prefix_len - 2] == 'L')
+ && (prefix[prefix_len - 1] == 'd'
+ || prefix[prefix_len - 1] == 'D'))
+ {
+ cmd[0] = xmalloc (prefix_len + 7);
+ memcpy (cmd[0], prefix, prefix_len - 2);
+ memcpy (cmd[0] + prefix_len - 2, "embedspu", 9);
+ }
+ else
+ {
+ prefix_len = 0;
+ cmd[0] = "embedspu";
+ }
cmd[1] = flags;
cmd[2] = handle;
cmd[3] = entry->the_bfd->filename;
@@ -379,6 +397,11 @@ embedded_spu_file (lang_input_statement_
if (pid == 0)
{
execvp (cmd[0], (char *const *) cmd);
+ if (prefix_len != 0)
+ {
+ cmd[0] = "embedspu";
+ execvp (cmd[0], (char *const *) cmd);
+ }
perror (cmd[0]);
_exit (127);
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre