summaryrefslogtreecommitdiff
path: root/ld/emultempl/spuelf.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2009-01-12 00:23:58 +0000
committerAlan Modra <amodra@bigpond.net.au>2009-01-12 00:23:58 +0000
commitb707fe761140b54617889b083d873edfe5ca346e (patch)
tree6b23511fb081e5e0c2f143b9c51a91524934b177 /ld/emultempl/spuelf.em
parent2c9ef631d960b4047a3f973a79f39275e5516e73 (diff)
downloadbinutils-redhat-b707fe761140b54617889b083d873edfe5ca346e.tar.gz
bfd/
* elf32-spu.c (struct spu_link_hash_table): Add init, line_size_log2, num_lines_log2. (struct got_entry): Add br_addr. (struct call_info): Add priority. (struct function_info): Add lr_store and sp_adjust. (spu_elf_setup): Init line_size_log2 and num_lines_log2. (spu_elf_find_overlays): For soft-icache, mark any section within cache area as an overlay, and check that no other overlays exist. Look up icache overlay manager entry sym. (BRA_STUBS, BRA, BRASL): Define. (enum _stub_type): Replace ovl_stub with call_ovl_stub and br*_ovl_stub. (needs_ovl_stub): Adjust for soft-icache. Return priority encoded in branch insn. (count_stub, build_stub): Support soft-icache. (build_spuear_stubs, process_stubs): Adjust build_stub call. (spu_elf_size_stubs): Size soft-icache stubs. (overlay_index): New function. (spu_elf_build_stubs): Make static. Support soft-icache. (spu_elf_check_vma): Don't turn off auto_overlay if soft-icache. (find_function_stack_adjust): Save lr store and stack adjust insn offsets. (maybe_insert_function): Adjust find_function_stack_adjust call. (mark_functions_via_relocs): Retrieve priority. (remove_cycles): Only warn about pruned arcs when stack_analysis. (sort_calls): Sort by priority first. (mark_overlay_section): Ignore .ovl.init. (sum_stack): Only print when stack_analysis. (print_one_overlay_section): New function, extracted from.. (spu_elf_auto_overlay): ..here. Support soft-icache overlays. (spu_elf_stack_analysis): Only print when htab->stack_analysis. (spu_elf_final_link): Call spu_elf_stack_analysis for lrlive analysis. Call spu_elf_build_stubs. (spu_elf_relocate_section): For soft-icache encode overlay index into addresses. (spu_elf_output_symbol_hook): Support soft-icache. (spu_elf_modify_program_headers: Likewise. * elf32-spu.h (struct spu_elf_params): Add lrlive_analysis. Rename num_regions to num_lines. Add line_size and max_branch. (enum _ovly_flavour): Add ovly_soft_icache. (spu_elf_build_stubs): Delete. gas/ * config/tc-spu.c (md_pseudo_table): Add "brinfo". (brinfo): New var. (md_assemble): Poke brinfo into branch instructions. (spu_brinfo): New function. (md_apply_fix): Don't assume insn fields start off at zero, mask them to remove possible brinfo. ld/ * emultempl/spuelf.em (params): Init new fields. (num_lines_set, line_size_set, icache_mgr, icache_mgr_stream): New vars. (spu_place_special_section): Adjust placement for soft-icache. Pad soft-icache section to a fixed size. Clear addr_tree. (spu_elf_load_ovl_mgr): Support soft-icache. Map overlay manager sections a little more intelligently. (gld${EMULATION_NAME}_finish): Don't call spu_elf_build_stubs. (OPTION_SPU_NUM_LINES): Rename from OPTION_SPU_NUM_REGIONS. (OPTION_SPU_SOFT_ICACHE, OPTION_SPU_LINE_SIZE): Define. (OPTION_SPU_LRLIVE): Define. (PARSE_AND_LIST_LONGOPTS): Add new soft-icache options. (PARSE_AND_LIST_OPTIONS): Likewise. (PARSE_AND_LIST_ARGS_CASES): Handle them. * emultempl/spu_icache.S: Dummy file. * emultempl/spu_icache.o_c: Regenerate. * Makefile.am (eelf32_spu.c): Depend on spu_icache.o_c. (spu_icache.o_c): Add rule to build. (CLEANFILES): Zap temp files. (EXTRA_DIST): Add spu_icache.o_c. * Makefile.in: Regenerate. ld/testsuite/ * ld-spu/ovl.d: Allow for absolute branches in stubs. * ld-spu/ovl2.d: Likewise.
Diffstat (limited to 'ld/emultempl/spuelf.em')
-rw-r--r--ld/emultempl/spuelf.em167
1 files changed, 142 insertions, 25 deletions
diff --git a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em
index bfabb8b72e..f72690d178 100644
--- a/ld/emultempl/spuelf.em
+++ b/ld/emultempl/spuelf.em
@@ -1,5 +1,5 @@
# This shell script emits a C file. -*- C -*-
-# Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
@@ -37,11 +37,13 @@ static struct spu_elf_params params =
&spu_elf_load_ovl_mgr,
&spu_elf_open_overlay_script,
&spu_elf_relink,
- 0, ovly_normal, 0, 0, 0, 0,
+ 0, ovly_normal, 0, 0, 0, 0, 0,
0, 0x3ffff,
- 1, 0, 0, 2000
+ 1, 0, 16, 0, 0, 2000
};
+static unsigned int num_lines_set = 0;
+static unsigned int line_size_set = 0;
static char *auto_overlay_file = 0;
int my_argc;
char **my_argv;
@@ -52,7 +54,20 @@ EOF
if ! cat ${srcdir}/emultempl/spu_ovl.o_c >> e${EMULATION_NAME}.c
then
echo >&2 "Missing ${srcdir}/emultempl/spu_ovl.o_c"
- echo >&2 "You must build gas/as-new with --target=spu to build spu_ovl.o"
+ echo >&2 "You must build gas/as-new with --target=spu"
+ exit 1
+fi
+
+fragment <<EOF
+};
+
+static const char icache_mgr[] = {
+EOF
+
+if ! cat ${srcdir}/emultempl/spu_icache.o_c >> e${EMULATION_NAME}.c
+then
+ echo >&2 "Missing ${srcdir}/emultempl/spu_icache.o_c"
+ echo >&2 "You must build gas/as-new with --target=spu"
exit 1
fi
@@ -64,6 +79,11 @@ static const struct _ovl_stream ovl_mgr_stream = {
ovl_mgr + sizeof (ovl_mgr)
};
+static const struct _ovl_stream icache_mgr_stream = {
+ icache_mgr,
+ icache_mgr + sizeof (icache_mgr)
+};
+
static int
is_spu_target (void)
@@ -96,7 +116,8 @@ spu_after_open (void)
}
/* If O is NULL, add section S at the end of output section OUTPUT_NAME.
- If O is not NULL, add section S at the beginning of output section O.
+ If O is not NULL, add section S at the beginning of output section O,
+ except for soft-icache which adds to the end.
Really, we should be duplicating ldlang.c map_input_to_output_sections
logic here, ie. using the linker script to find where the section
@@ -115,8 +136,12 @@ spu_place_special_section (asection *s, asection *o, const char *output_name)
output_name = o->name;
os = lang_output_section_find (output_name);
if (os == NULL)
- gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
- else if (o != NULL && os->children.head != NULL)
+ {
+ os = gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
+ os->addr_tree = NULL;
+ }
+ else if (params.ovly_flavour != ovly_soft_icache
+ && o != NULL && os->children.head != NULL)
{
lang_statement_list_type add;
@@ -126,7 +151,21 @@ spu_place_special_section (asection *s, asection *o, const char *output_name)
os->children.head = add.head;
}
else
- lang_add_section (&os->children, s, os);
+ {
+ if (params.ovly_flavour == ovly_soft_icache && o != NULL)
+ {
+ /* Pad this stub section so that it finishes at the
+ end of the icache line. */
+ etree_type *e_size;
+ lang_statement_list_type *save = stat_ptr;
+
+ stat_ptr = &os->children;
+ e_size = exp_intop (params.line_size - s->size);
+ lang_add_assignment (exp_assop ('=', ".", e_size));
+ stat_ptr = save;
+ }
+ lang_add_section (&os->children, s, os);
+ }
s->output_section->size += s->size;
}
@@ -137,10 +176,19 @@ static bfd_size_type
spu_elf_load_ovl_mgr (void)
{
struct elf_link_hash_entry *h;
+ const char *ovly_mgr_entry;
+ const struct _ovl_stream *mgr_stream;
bfd_size_type total = 0;
+ ovly_mgr_entry = "__ovly_load";
+ mgr_stream = &ovl_mgr_stream;
+ if (params.ovly_flavour == ovly_soft_icache)
+ {
+ ovly_mgr_entry = "__icache_br_handler";
+ mgr_stream = &icache_mgr_stream;
+ }
h = elf_link_hash_lookup (elf_hash_table (&link_info),
- "__ovly_load", FALSE, FALSE, FALSE);
+ ovly_mgr_entry, FALSE, FALSE, FALSE);
if (h != NULL
&& (h->root.type == bfd_link_hash_defined
@@ -149,7 +197,7 @@ spu_elf_load_ovl_mgr (void)
{
/* User supplied __ovly_load. */
}
- else if (ovl_mgr_stream.start == ovl_mgr_stream.end)
+ else if (mgr_stream->start == mgr_stream->end)
einfo ("%F%P: no built-in overlay manager\n");
else
{
@@ -159,7 +207,7 @@ spu_elf_load_ovl_mgr (void)
lang_input_file_is_file_enum,
NULL);
- if (!spu_elf_open_builtin_lib (&ovl_is->the_bfd, &ovl_mgr_stream))
+ if (!spu_elf_open_builtin_lib (&ovl_is->the_bfd, mgr_stream))
einfo ("%X%P: can not open built-in overlay manager: %E\n");
else
{
@@ -168,13 +216,38 @@ spu_elf_load_ovl_mgr (void)
if (!load_symbols (ovl_is, NULL))
einfo ("%X%P: can not load built-in overlay manager: %E\n");
- /* Map overlay manager sections to output sections. */
+ /* Map overlay manager sections to output sections.
+ First try for a matching output section name, if that
+ fails then try mapping .abc.xyz to .abc, otherwise map
+ to .text. */
for (in = ovl_is->the_bfd->sections; in != NULL; in = in->next)
if ((in->flags & (SEC_ALLOC | SEC_LOAD))
== (SEC_ALLOC | SEC_LOAD))
{
- total += in->size;
- spu_place_special_section (in, NULL, ".text");
+ const char *oname = in->name;
+ if (strncmp (in->name, ".ovl.init", 9) != 0)
+ {
+ total += in->size;
+ if (!lang_output_section_find (oname))
+ {
+ lang_output_section_statement_type *os = NULL;
+ char *p = strchr (oname + 1, '.');
+ if (p != NULL)
+ {
+ size_t len = p - oname;
+ p = memcpy (xmalloc (len + 1), oname, len);
+ p[len] = '\0';
+ os = lang_output_section_find (p);
+ free (p);
+ }
+ if (os != NULL)
+ oname = os->name;
+ else
+ oname = ".text";
+ }
+ }
+
+ spu_place_special_section (in, NULL, oname);
}
}
}
@@ -338,9 +411,6 @@ gld${EMULATION_NAME}_finish (void)
}
else if (params.auto_overlay)
einfo ("%P: --auto-overlay ignored with zero local store range\n");
-
- if (!spu_elf_build_stubs (&link_info))
- einfo ("%F%P: can not build overlay stubs: %E\n");
}
finish_default ();
@@ -520,8 +590,11 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_SPU_AUTO_OVERLAY (OPTION_SPU_STACK_SYMS + 1)
#define OPTION_SPU_AUTO_RELINK (OPTION_SPU_AUTO_OVERLAY + 1)
#define OPTION_SPU_OVERLAY_RODATA (OPTION_SPU_AUTO_RELINK + 1)
-#define OPTION_SPU_NUM_REGIONS (OPTION_SPU_OVERLAY_RODATA + 1)
-#define OPTION_SPU_FIXED_SPACE (OPTION_SPU_NUM_REGIONS + 1)
+#define OPTION_SPU_SOFT_ICACHE (OPTION_SPU_OVERLAY_RODATA + 1)
+#define OPTION_SPU_LINE_SIZE (OPTION_SPU_SOFT_ICACHE + 1)
+#define OPTION_SPU_NUM_LINES (OPTION_SPU_LINE_SIZE + 1)
+#define OPTION_SPU_LRLIVE (OPTION_SPU_NUM_LINES + 1)
+#define OPTION_SPU_FIXED_SPACE (OPTION_SPU_LRLIVE + 1)
#define OPTION_SPU_RESERVED_SPACE (OPTION_SPU_FIXED_SPACE + 1)
#define OPTION_SPU_EXTRA_STACK (OPTION_SPU_RESERVED_SPACE + 1)
#define OPTION_SPU_NO_AUTO_OVERLAY (OPTION_SPU_EXTRA_STACK + 1)
@@ -529,6 +602,10 @@ PARSE_AND_LIST_PROLOGUE='
PARSE_AND_LIST_LONGOPTS='
{ "plugin", no_argument, NULL, OPTION_SPU_PLUGIN },
+ { "soft-icache", no_argument, NULL, OPTION_SPU_SOFT_ICACHE },
+ { "lrlive-analysis", no_argument, NULL, OPTION_SPU_LRLIVE },
+ { "num-lines", required_argument, NULL, OPTION_SPU_NUM_LINES },
+ { "line-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
{ "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
{ "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
{ "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
@@ -538,7 +615,8 @@ PARSE_AND_LIST_LONGOPTS='
{ "auto-overlay", optional_argument, NULL, OPTION_SPU_AUTO_OVERLAY },
{ "auto-relink", no_argument, NULL, OPTION_SPU_AUTO_RELINK },
{ "overlay-rodata", no_argument, NULL, OPTION_SPU_OVERLAY_RODATA },
- { "num-regions", required_argument, NULL, OPTION_SPU_NUM_REGIONS },
+ { "num-regions", required_argument, NULL, OPTION_SPU_NUM_LINES },
+ { "region-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
{ "fixed-space", required_argument, NULL, OPTION_SPU_FIXED_SPACE },
{ "reserved-space", required_argument, NULL, OPTION_SPU_RESERVED_SPACE },
{ "extra-stack-space", required_argument, NULL, OPTION_SPU_EXTRA_STACK },
@@ -560,11 +638,16 @@ PARSE_AND_LIST_OPTIONS='
--overlay-rodata Place read-only data with associated function\n\
code in overlays.\n\
--num-regions Number of overlay buffers (default 1).\n\
+ --region-size Size of overlay buffers (default 0, auto).\n\
--fixed-space=bytes Local store for non-overlay code and data.\n\
--reserved-space=bytes Local store for stack and heap. If not specified\n\
ld will estimate stack size and assume no heap.\n\
--extra-stack-space=bytes Space for negative sp access (default 2000) if\n\
- --reserved-space not given.\n"
+ --reserved-space not given.\n\
+ --soft-icache Generate software icache overlays.\n\
+ --num-lines Number of soft-icache lines (default 32).\n\
+ --line-size Size of soft-icache lines (default 1k).\n\
+ --lrlive-analysis Scan function prologue for lr liveness.\n"
));
'
@@ -624,13 +707,47 @@ PARSE_AND_LIST_ARGS_CASES='
params.auto_overlay |= 4;
break;
- case OPTION_SPU_NUM_REGIONS:
+ case OPTION_SPU_SOFT_ICACHE:
+ params.ovly_flavour = ovly_soft_icache;
+ if (!num_lines_set)
+ params.num_lines = 32;
+ else if ((params.num_lines & -params.num_lines) != params.num_lines)
+ einfo (_("%P%F: invalid --num-lines/--num-regions `%u'\''\n"),
+ params.num_lines);
+ if (!line_size_set)
+ params.line_size = 1024;
+ else if ((params.line_size & -params.line_size) != params.line_size)
+ einfo (_("%P%F: invalid --line-size/--region-size `%u'\''\n"),
+ params.line_size);
+ break;
+
+ case OPTION_SPU_LRLIVE:
+ params.lrlive_analysis = 1;
+ break;
+
+ case OPTION_SPU_NUM_LINES:
+ {
+ char *end;
+ params.num_lines = strtoul (optarg, &end, 0);
+ num_lines_set = 1;
+ if (*end == 0
+ && (params.ovly_flavour != ovly_soft_icache
+ || (params.num_lines & -params.num_lines) == params.num_lines))
+ break;
+ einfo (_("%P%F: invalid --num-lines/--num-regions `%s'\''\n"), optarg);
+ }
+ break;
+
+ case OPTION_SPU_LINE_SIZE:
{
char *end;
- params.num_regions = strtoul (optarg, &end, 0);
- if (*end == 0)
+ params.line_size = strtoul (optarg, &end, 0);
+ line_size_set = 1;
+ if (*end == 0
+ && (params.ovly_flavour != ovly_soft_icache
+ || (params.line_size & -params.line_size) == params.line_size))
break;
- einfo (_("%P%F: invalid --num-regions `%s'\''\n"), optarg);
+ einfo (_("%P%F: invalid --line-size/--region-size `%s'\''\n"), optarg);
}
break;