diff options
author | Alan Modra <amodra@gmail.com> | 2007-05-29 13:10:10 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2007-05-29 13:10:10 +0000 |
commit | 3ba20bde7e5976625515b62ba462f7bf2dbf8b23 (patch) | |
tree | 59e32e8fcc6a06aad5cf9feff4ce8768a5e98380 /ld | |
parent | a7e4b3fed3e1b19a06dbc8461e127c282b20b735 (diff) | |
download | gdb-3ba20bde7e5976625515b62ba462f7bf2dbf8b23.zip gdb-3ba20bde7e5976625515b62ba462f7bf2dbf8b23.tar.gz gdb-3ba20bde7e5976625515b62ba462f7bf2dbf8b23.tar.bz2 |
binutils/
* embedspu.sh: Emit SPU ELF image to .data.rel.ro.speelf if
pic or pie and image needs relocs.
ld/
* emultempl/spuelf.em (base_name): New function, split out from..
(embedded_spu_file) ..here. Pass -fPIC or -fpie to embedspu
invocation if we deduce a shared lib or position independent
executable build by looking at ctrbegin* linker input files.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 7 | ||||
-rw-r--r-- | ld/emultempl/spuelf.em | 59 |
2 files changed, 49 insertions, 17 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index cf99ae3..c2a1470 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,12 @@ 2007-05-29 Alan Modra <amodra@bigpond.net.au> + * emultempl/spuelf.em (base_name): New function, split out from.. + (embedded_spu_file) ..here. Pass -fPIC or -fpie to embedspu + invocation if we deduce a shared lib or position independent + executable build by looking at ctrbegin* linker input files. + +2007-05-29 Alan Modra <amodra@bigpond.net.au> + * emultempl/spu_ovl.S (__rv_pattern, __cg_pattern): Set symbol types and sizes. * emultempl/spu_ovl.o: Regenerate. diff --git a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em index fe8b127..db0542f 100644 --- a/ld/emultempl/spuelf.em +++ b/ld/emultempl/spuelf.em @@ -264,6 +264,29 @@ static void clean_tmp (void) unlink (tmp_file_list->name); } +static const char * +base_name (const char *path) +{ + const char *file = strrchr (path, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + { + char *bslash = strrchr (path, '\\'); + + if (file == NULL || (bslash != NULL && bslash > file)) + file = bslash; + if (file == NULL + && path[0] != '\0' + && path[1] == ':') + file = path + 1; + } +#endif + if (file == NULL) + file = path; + else + ++file; + return file; +} + /* This function is called when building a ppc32 or ppc64 executable to handle embedded spu images. */ extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *); @@ -282,6 +305,7 @@ embedded_spu_file (lang_input_statement_type *entry, const char *flags) union lang_statement_union **old_stat_tail; union lang_statement_union **old_file_tail; union lang_statement_union *new_ent; + lang_input_statement_type *search; if (entry->the_bfd->format != bfd_object || strcmp (entry->the_bfd->xvec->name, "elf32-spu") != 0 @@ -290,23 +314,7 @@ embedded_spu_file (lang_input_statement_type *entry, const char *flags) return FALSE; /* Use the filename as the symbol marking the program handle struct. */ - sym = strrchr (entry->the_bfd->filename, '/'); -#ifdef HAVE_DOS_BASED_FILE_SYSTEM - { - char *bslash = strrchr (entry->the_bfd->filename, '\\'); - - if (sym == NULL || (bslash != NULL && bslash > sym)) - sym = bslash; - if (sym == NULL - && entry->the_bfd->filename[0] != '\0' - && entry->the_bfd->filename[1] == ':') - sym = entry->the_bfd->filename + 1; - } -#endif - if (sym == NULL) - sym = entry->the_bfd->filename; - else - ++sym; + sym = base_name (entry->the_bfd->filename); handle = xstrdup (sym); for (p = handle; *p; ++p) @@ -333,6 +341,23 @@ embedded_spu_file (lang_input_statement_type *entry, const char *flags) return FALSE; close (fd); + for (search = (lang_input_statement_type *) input_file_chain.head; + search != NULL; + search = (lang_input_statement_type *) search->next_real_file) + { + const char *infile = base_name (search->filename); + + if (infile != NULL + && strncmp (infile, "crtbegin", 8) == 0) + { + if (infile[8] == 'S') + flags = concat (flags, " -fPIC", NULL); + else if (infile[8] == 'T') + flags = concat (flags, " -fpie", NULL); + break; + } + } + /* Use fork() and exec() rather than system() so that we don't need to worry about quoting args. */ cmd[0] = "embedspu"; |