bfd/
[deliverable/binutils-gdb.git] / ld / emultempl / spuelf.em
1 # This shell script emits a C file. -*- C -*-
2 # Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # This file is sourced from elf32.em, and defines extra spu specific
23 # features.
24 #
25 fragment <<EOF
26 #include "ldctor.h"
27 #include "elf32-spu.h"
28
29 static void spu_place_special_section (asection *, asection *, const char *);
30 static bfd_size_type spu_elf_load_ovl_mgr (void);
31 static FILE *spu_elf_open_overlay_script (void);
32 static void spu_elf_relink (void);
33
34 static struct spu_elf_params params =
35 {
36 &spu_place_special_section,
37 &spu_elf_load_ovl_mgr,
38 &spu_elf_open_overlay_script,
39 &spu_elf_relink,
40 0, ovly_normal, 0, 0, 0, 0, 0, 0, 0,
41 0, 0x3ffff,
42 1, 0, 16, 0, 0, 2000
43 };
44
45 static unsigned int no_overlays = 0;
46 static unsigned int num_lines_set = 0;
47 static unsigned int line_size_set = 0;
48 static char *auto_overlay_file = 0;
49 int my_argc;
50 char **my_argv;
51
52 static const char ovl_mgr[] = {
53 EOF
54
55 if ! cat ${srcdir}/emultempl/spu_ovl.o_c >> e${EMULATION_NAME}.c
56 then
57 echo >&2 "Missing ${srcdir}/emultempl/spu_ovl.o_c"
58 echo >&2 "You must build gas/as-new with --target=spu"
59 exit 1
60 fi
61
62 fragment <<EOF
63 };
64
65 static const char icache_mgr[] = {
66 EOF
67
68 if ! cat ${srcdir}/emultempl/spu_icache.o_c >> e${EMULATION_NAME}.c
69 then
70 echo >&2 "Missing ${srcdir}/emultempl/spu_icache.o_c"
71 echo >&2 "You must build gas/as-new with --target=spu"
72 exit 1
73 fi
74
75 fragment <<EOF
76 };
77
78 static const struct _ovl_stream ovl_mgr_stream = {
79 ovl_mgr,
80 ovl_mgr + sizeof (ovl_mgr)
81 };
82
83 static const struct _ovl_stream icache_mgr_stream = {
84 icache_mgr,
85 icache_mgr + sizeof (icache_mgr)
86 };
87
88
89 static int
90 is_spu_target (void)
91 {
92 extern const bfd_target bfd_elf32_spu_vec;
93
94 return link_info.output_bfd->xvec == &bfd_elf32_spu_vec;
95 }
96
97 /* Create our note section. */
98
99 static void
100 spu_after_open (void)
101 {
102 if (is_spu_target ())
103 {
104 /* Pass params to backend. */
105 if ((params.auto_overlay & AUTO_OVERLAY) == 0)
106 params.auto_overlay = 0;
107 params.emit_stub_syms |= link_info.emitrelocations;
108 spu_elf_setup (&link_info, &params);
109
110 if (link_info.relocatable)
111 lang_add_unique (".text.ia.*");
112
113 if (!link_info.relocatable
114 && link_info.input_bfds != NULL
115 && !spu_elf_create_sections (&link_info))
116 einfo ("%X%P: can not create note section: %E\n");
117 }
118
119 gld${EMULATION_NAME}_after_open ();
120 }
121
122 /* If O is NULL, add section S at the end of output section OUTPUT_NAME.
123 If O is not NULL, add section S at the beginning of output section O,
124 except for soft-icache which adds to the end.
125
126 Really, we should be duplicating ldlang.c map_input_to_output_sections
127 logic here, ie. using the linker script to find where the section
128 goes. That's rather a lot of code, and we don't want to run
129 map_input_to_output_sections again because most sections are already
130 mapped. So cheat, and put the section in a fixed place, ignoring any
131 attempt via a linker script to put .stub, .ovtab, and built-in
132 overlay manager code somewhere else. */
133
134 static void
135 spu_place_special_section (asection *s, asection *o, const char *output_name)
136 {
137 lang_output_section_statement_type *os;
138
139 if (o != NULL)
140 output_name = o->name;
141 os = lang_output_section_find (output_name);
142 if (os == NULL)
143 {
144 os = gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
145 os->addr_tree = NULL;
146 }
147 else if (params.ovly_flavour != ovly_soft_icache
148 && o != NULL && os->children.head != NULL)
149 {
150 lang_statement_list_type add;
151
152 lang_list_init (&add);
153 lang_add_section (&add, s, os);
154 *add.tail = os->children.head;
155 os->children.head = add.head;
156 }
157 else
158 {
159 if (params.ovly_flavour == ovly_soft_icache && o != NULL)
160 {
161 /* Pad this stub section so that it finishes at the
162 end of the icache line. */
163 etree_type *e_size;
164
165 push_stat_ptr (&os->children);
166 e_size = exp_intop (params.line_size - s->size);
167 lang_add_assignment (exp_assop ('=', ".", e_size));
168 pop_stat_ptr ();
169 }
170 lang_add_section (&os->children, s, os);
171 }
172
173 s->output_section->size += s->size;
174 }
175
176 /* Load built-in overlay manager. */
177
178 static bfd_size_type
179 spu_elf_load_ovl_mgr (void)
180 {
181 struct elf_link_hash_entry *h;
182 const char *ovly_mgr_entry;
183 const struct _ovl_stream *mgr_stream;
184 bfd_size_type total = 0;
185
186 ovly_mgr_entry = "__ovly_load";
187 mgr_stream = &ovl_mgr_stream;
188 if (params.ovly_flavour == ovly_soft_icache)
189 {
190 ovly_mgr_entry = "__icache_br_handler";
191 mgr_stream = &icache_mgr_stream;
192 }
193 h = elf_link_hash_lookup (elf_hash_table (&link_info),
194 ovly_mgr_entry, FALSE, FALSE, FALSE);
195
196 if (h != NULL
197 && (h->root.type == bfd_link_hash_defined
198 || h->root.type == bfd_link_hash_defweak)
199 && h->def_regular)
200 {
201 /* User supplied __ovly_load. */
202 }
203 else if (mgr_stream->start == mgr_stream->end)
204 einfo ("%F%P: no built-in overlay manager\n");
205 else
206 {
207 lang_input_statement_type *ovl_is;
208
209 ovl_is = lang_add_input_file ("builtin ovl_mgr",
210 lang_input_file_is_file_enum,
211 NULL);
212
213 if (!spu_elf_open_builtin_lib (&ovl_is->the_bfd, mgr_stream))
214 einfo ("%X%P: can not open built-in overlay manager: %E\n");
215 else
216 {
217 asection *in;
218
219 if (!load_symbols (ovl_is, NULL))
220 einfo ("%X%P: can not load built-in overlay manager: %E\n");
221
222 /* Map overlay manager sections to output sections.
223 First try for a matching output section name, if that
224 fails then try mapping .abc.xyz to .abc, otherwise map
225 to .text. */
226 for (in = ovl_is->the_bfd->sections; in != NULL; in = in->next)
227 if ((in->flags & (SEC_ALLOC | SEC_LOAD))
228 == (SEC_ALLOC | SEC_LOAD))
229 {
230 const char *oname = in->name;
231 if (strncmp (in->name, ".ovl.init", 9) != 0)
232 {
233 total += in->size;
234 if (!lang_output_section_find (oname))
235 {
236 lang_output_section_statement_type *os = NULL;
237 char *p = strchr (oname + 1, '.');
238 if (p != NULL)
239 {
240 size_t len = p - oname;
241 p = memcpy (xmalloc (len + 1), oname, len);
242 p[len] = '\0';
243 os = lang_output_section_find (p);
244 free (p);
245 }
246 if (os != NULL)
247 oname = os->name;
248 else
249 oname = ".text";
250 }
251 }
252
253 spu_place_special_section (in, NULL, oname);
254 }
255 }
256 }
257 return total;
258 }
259
260 /* Go find if we need to do anything special for overlays. */
261
262 static void
263 spu_before_allocation (void)
264 {
265 if (is_spu_target ()
266 && !link_info.relocatable
267 && !no_overlays)
268 {
269 int ret;
270
271 /* Size the sections. This is premature, but we need to know the
272 rough layout so that overlays can be found. */
273 expld.phase = lang_mark_phase_enum;
274 expld.dataseg.phase = exp_dataseg_none;
275 one_lang_size_sections_pass (NULL, TRUE);
276
277 /* Find overlays by inspecting section vmas. */
278 ret = spu_elf_find_overlays (&link_info);
279 if (ret == 0)
280 einfo ("%X%P: can not find overlays: %E\n");
281 else if (ret == 2)
282 {
283 lang_output_section_statement_type *os;
284
285 if (params.auto_overlay != 0)
286 {
287 einfo ("%P: --auto-overlay ignored with user overlay script\n");
288 params.auto_overlay = 0;
289 }
290
291 /* Ensure alignment of overlay sections is sufficient. */
292 for (os = &lang_output_section_statement.head->output_section_statement;
293 os != NULL;
294 os = os->next)
295 if (os->bfd_section != NULL
296 && spu_elf_section_data (os->bfd_section) != NULL
297 && spu_elf_section_data (os->bfd_section)->u.o.ovl_index != 0)
298 {
299 if (os->bfd_section->alignment_power < 4)
300 os->bfd_section->alignment_power = 4;
301
302 /* Also ensure size rounds up. */
303 os->block_value = 16;
304 }
305
306 ret = spu_elf_size_stubs (&link_info);
307 if (ret == 0)
308 einfo ("%X%P: can not size overlay stubs: %E\n");
309 else if (ret == 2)
310 spu_elf_load_ovl_mgr ();
311 }
312
313 /* We must not cache anything from the preliminary sizing. */
314 lang_reset_memory_regions ();
315 }
316
317 gld${EMULATION_NAME}_before_allocation ();
318 }
319
320 struct tflist {
321 struct tflist *next;
322 char name[9];
323 };
324
325 static struct tflist *tmp_file_list;
326
327 static void clean_tmp (void)
328 {
329 for (; tmp_file_list != NULL; tmp_file_list = tmp_file_list->next)
330 unlink (tmp_file_list->name);
331 }
332
333 static int
334 new_tmp_file (char **fname)
335 {
336 struct tflist *tf;
337 int fd;
338
339 if (tmp_file_list == NULL)
340 atexit (clean_tmp);
341 tf = xmalloc (sizeof (*tf));
342 tf->next = tmp_file_list;
343 tmp_file_list = tf;
344 memcpy (tf->name, "ldXXXXXX", sizeof (tf->name));
345 *fname = tf->name;
346 #ifdef HAVE_MKSTEMP
347 fd = mkstemp (*fname);
348 #else
349 *fname = mktemp (*fname);
350 if (*fname == NULL)
351 return -1;
352 fd = open (fname, O_RDWR | O_CREAT | O_EXCL, 0600);
353 #endif
354 return fd;
355 }
356
357 static FILE *
358 spu_elf_open_overlay_script (void)
359 {
360 FILE *script = NULL;
361
362 if (auto_overlay_file == NULL)
363 {
364 int fd = new_tmp_file (&auto_overlay_file);
365 if (fd == -1)
366 goto file_err;
367 script = fdopen (fd, "w");
368 }
369 else
370 script = fopen (auto_overlay_file, "w");
371
372 if (script == NULL)
373 {
374 file_err:
375 einfo ("%F%P: can not open script: %E\n");
376 }
377 return script;
378 }
379
380 static void
381 spu_elf_relink (void)
382 {
383 char **argv = xmalloc ((my_argc + 4) * sizeof (*argv));
384
385 memcpy (argv, my_argv, my_argc * sizeof (*argv));
386 argv[my_argc++] = "--no-auto-overlay";
387 if (tmp_file_list->name == auto_overlay_file)
388 argv[my_argc - 1] = concat (argv[my_argc - 1], "=",
389 auto_overlay_file, (const char *) NULL);
390 argv[my_argc++] = "-T";
391 argv[my_argc++] = auto_overlay_file;
392 argv[my_argc] = 0;
393 execvp (argv[0], (char *const *) argv);
394 perror (argv[0]);
395 _exit (127);
396 }
397
398 /* Final emulation specific call. */
399
400 static void
401 gld${EMULATION_NAME}_finish (void)
402 {
403 int need_laying_out;
404
405 need_laying_out = bfd_elf_discard_info (link_info.output_bfd, &link_info);
406
407 gld${EMULATION_NAME}_map_segments (need_laying_out);
408
409 if (is_spu_target ())
410 {
411 if (params.local_store_lo < params.local_store_hi)
412 {
413 asection *s;
414
415 s = spu_elf_check_vma (&link_info);
416 if (s != NULL && !params.auto_overlay)
417 einfo ("%X%P: %A exceeds local store range\n", s);
418 }
419 else if (params.auto_overlay)
420 einfo ("%P: --auto-overlay ignored with zero local store range\n");
421 }
422
423 finish_default ();
424 }
425
426 static char *
427 gld${EMULATION_NAME}_choose_target (int argc, char *argv[])
428 {
429 my_argc = argc;
430 my_argv = argv;
431 return ldemul_default_target (argc, argv);
432 }
433
434 EOF
435
436 if grep -q 'ld_elf.*ppc.*_emulation' ldemul-list.h; then
437 fragment <<EOF
438 #include "filenames.h"
439 #include <fcntl.h>
440 #include <sys/wait.h>
441
442 static const char *
443 base_name (const char *path)
444 {
445 const char *file = strrchr (path, '/');
446 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
447 {
448 char *bslash = strrchr (path, '\\\\');
449
450 if (file == NULL || (bslash != NULL && bslash > file))
451 file = bslash;
452 if (file == NULL
453 && path[0] != '\0'
454 && path[1] == ':')
455 file = path + 1;
456 }
457 #endif
458 if (file == NULL)
459 file = path;
460 else
461 ++file;
462 return file;
463 }
464
465 /* This function is called when building a ppc32 or ppc64 executable
466 to handle embedded spu images. */
467 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
468
469 bfd_boolean
470 embedded_spu_file (lang_input_statement_type *entry, const char *flags)
471 {
472 const char *cmd[6];
473 const char *sym;
474 char *handle, *p;
475 char *oname;
476 int fd;
477 pid_t pid;
478 int status;
479 union lang_statement_union **old_stat_tail;
480 union lang_statement_union **old_file_tail;
481 union lang_statement_union *new_ent;
482 lang_input_statement_type *search;
483
484 if (entry->the_bfd->format != bfd_object
485 || strcmp (entry->the_bfd->xvec->name, "elf32-spu") != 0
486 || (entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_EXEC
487 && entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_DYN))
488 return FALSE;
489
490 /* Use the filename as the symbol marking the program handle struct. */
491 sym = base_name (entry->the_bfd->filename);
492
493 handle = xstrdup (sym);
494 for (p = handle; *p; ++p)
495 if (!(ISALNUM (*p) || *p == '$' || *p == '.'))
496 *p = '_';
497
498 fd = new_tmp_file (&oname);
499 if (fd == -1)
500 return FALSE;
501 close (fd);
502
503 for (search = (lang_input_statement_type *) input_file_chain.head;
504 search != NULL;
505 search = (lang_input_statement_type *) search->next_real_file)
506 if (search->filename != NULL)
507 {
508 const char *infile = base_name (search->filename);
509
510 if (strncmp (infile, "crtbegin", 8) == 0)
511 {
512 if (infile[8] == 'S')
513 flags = concat (flags, " -fPIC", (const char *) NULL);
514 else if (infile[8] == 'T')
515 flags = concat (flags, " -fpie", (const char *) NULL);
516 break;
517 }
518 }
519
520 /* Use fork() and exec() rather than system() so that we don't
521 need to worry about quoting args. */
522 cmd[0] = EMBEDSPU;
523 cmd[1] = flags;
524 cmd[2] = handle;
525 cmd[3] = entry->the_bfd->filename;
526 cmd[4] = oname;
527 cmd[5] = NULL;
528 if (trace_file_tries)
529 {
530 info_msg (_("running: %s \"%s\" \"%s\" \"%s\" \"%s\"\n"),
531 cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]);
532 fflush (stdout);
533 }
534
535 pid = fork ();
536 if (pid == -1)
537 return FALSE;
538 if (pid == 0)
539 {
540 execvp (cmd[0], (char *const *) cmd);
541 if (strcmp ("embedspu", EMBEDSPU) != 0)
542 {
543 cmd[0] = "embedspu";
544 execvp (cmd[0], (char *const *) cmd);
545 }
546 perror (cmd[0]);
547 _exit (127);
548 }
549 #ifdef HAVE_WAITPID
550 #define WAITFOR(PID, STAT) waitpid (PID, STAT, 0)
551 #else
552 #define WAITFOR(PID, STAT) wait (STAT)
553 #endif
554 if (WAITFOR (pid, &status) != pid
555 || !WIFEXITED (status)
556 || WEXITSTATUS (status) != 0)
557 return FALSE;
558 #undef WAITFOR
559
560 old_stat_tail = stat_ptr->tail;
561 old_file_tail = input_file_chain.tail;
562 if (lang_add_input_file (oname, lang_input_file_is_file_enum, NULL) == NULL)
563 return FALSE;
564
565 /* lang_add_input_file puts the new list entry at the end of the statement
566 and input file lists. Move it to just after the current entry. */
567 new_ent = *old_stat_tail;
568 *old_stat_tail = NULL;
569 stat_ptr->tail = old_stat_tail;
570 *old_file_tail = NULL;
571 input_file_chain.tail = old_file_tail;
572 new_ent->header.next = entry->header.next;
573 entry->header.next = new_ent;
574 new_ent->input_statement.next_real_file = entry->next_real_file;
575 entry->next_real_file = new_ent;
576
577 /* Ensure bfd sections are excluded from the output. */
578 bfd_section_list_clear (entry->the_bfd);
579 entry->loaded = TRUE;
580 return TRUE;
581 }
582
583 EOF
584 fi
585
586 # Define some shell vars to insert bits of code into the standard elf
587 # parse_args and list_options functions.
588 #
589 PARSE_AND_LIST_PROLOGUE='
590 #define OPTION_SPU_PLUGIN 301
591 #define OPTION_SPU_NO_OVERLAYS (OPTION_SPU_PLUGIN + 1)
592 #define OPTION_SPU_COMPACT_STUBS (OPTION_SPU_NO_OVERLAYS + 1)
593 #define OPTION_SPU_STUB_SYMS (OPTION_SPU_COMPACT_STUBS + 1)
594 #define OPTION_SPU_NON_OVERLAY_STUBS (OPTION_SPU_STUB_SYMS + 1)
595 #define OPTION_SPU_LOCAL_STORE (OPTION_SPU_NON_OVERLAY_STUBS + 1)
596 #define OPTION_SPU_STACK_ANALYSIS (OPTION_SPU_LOCAL_STORE + 1)
597 #define OPTION_SPU_STACK_SYMS (OPTION_SPU_STACK_ANALYSIS + 1)
598 #define OPTION_SPU_AUTO_OVERLAY (OPTION_SPU_STACK_SYMS + 1)
599 #define OPTION_SPU_AUTO_RELINK (OPTION_SPU_AUTO_OVERLAY + 1)
600 #define OPTION_SPU_OVERLAY_RODATA (OPTION_SPU_AUTO_RELINK + 1)
601 #define OPTION_SPU_SOFT_ICACHE (OPTION_SPU_OVERLAY_RODATA + 1)
602 #define OPTION_SPU_LINE_SIZE (OPTION_SPU_SOFT_ICACHE + 1)
603 #define OPTION_SPU_NUM_LINES (OPTION_SPU_LINE_SIZE + 1)
604 #define OPTION_SPU_LRLIVE (OPTION_SPU_NUM_LINES + 1)
605 #define OPTION_SPU_NON_IA_TEXT (OPTION_SPU_LRLIVE + 1)
606 #define OPTION_SPU_FIXED_SPACE (OPTION_SPU_NON_IA_TEXT + 1)
607 #define OPTION_SPU_RESERVED_SPACE (OPTION_SPU_FIXED_SPACE + 1)
608 #define OPTION_SPU_EXTRA_STACK (OPTION_SPU_RESERVED_SPACE + 1)
609 #define OPTION_SPU_NO_AUTO_OVERLAY (OPTION_SPU_EXTRA_STACK + 1)
610 '
611
612 PARSE_AND_LIST_LONGOPTS='
613 { "plugin", no_argument, NULL, OPTION_SPU_PLUGIN },
614 { "soft-icache", no_argument, NULL, OPTION_SPU_SOFT_ICACHE },
615 { "lrlive-analysis", no_argument, NULL, OPTION_SPU_LRLIVE },
616 { "num-lines", required_argument, NULL, OPTION_SPU_NUM_LINES },
617 { "line-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
618 { "non-ia-text", no_argument, NULL, OPTION_SPU_NON_IA_TEXT },
619 { "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
620 { "compact-stubs", no_argument, NULL, OPTION_SPU_COMPACT_STUBS },
621 { "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
622 { "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
623 { "local-store", required_argument, NULL, OPTION_SPU_LOCAL_STORE },
624 { "stack-analysis", no_argument, NULL, OPTION_SPU_STACK_ANALYSIS },
625 { "emit-stack-syms", no_argument, NULL, OPTION_SPU_STACK_SYMS },
626 { "auto-overlay", optional_argument, NULL, OPTION_SPU_AUTO_OVERLAY },
627 { "auto-relink", no_argument, NULL, OPTION_SPU_AUTO_RELINK },
628 { "overlay-rodata", no_argument, NULL, OPTION_SPU_OVERLAY_RODATA },
629 { "num-regions", required_argument, NULL, OPTION_SPU_NUM_LINES },
630 { "region-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
631 { "fixed-space", required_argument, NULL, OPTION_SPU_FIXED_SPACE },
632 { "reserved-space", required_argument, NULL, OPTION_SPU_RESERVED_SPACE },
633 { "extra-stack-space", required_argument, NULL, OPTION_SPU_EXTRA_STACK },
634 { "no-auto-overlay", optional_argument, NULL, OPTION_SPU_NO_AUTO_OVERLAY },
635 '
636
637 PARSE_AND_LIST_OPTIONS='
638 fprintf (file, _("\
639 --plugin Make SPU plugin.\n\
640 --no-overlays No overlay handling.\n\
641 --compact-stubs Use smaller and possibly slower call stubs.\n\
642 --emit-stub-syms Add symbols on overlay call stubs.\n\
643 --extra-overlay-stubs Add stubs on all calls out of overlay regions.\n\
644 --local-store=lo:hi Valid address range.\n\
645 --stack-analysis Estimate maximum stack requirement.\n\
646 --emit-stack-syms Add sym giving stack needed for each func.\n\
647 --auto-overlay [=filename] Create an overlay script in filename if\n\
648 executable does not fit in local store.\n\
649 --auto-relink Rerun linker using auto-overlay script.\n\
650 --overlay-rodata Place read-only data with associated function\n\
651 code in overlays.\n\
652 --num-regions Number of overlay buffers (default 1).\n\
653 --region-size Size of overlay buffers (default 0, auto).\n\
654 --fixed-space=bytes Local store for non-overlay code and data.\n\
655 --reserved-space=bytes Local store for stack and heap. If not specified\n\
656 ld will estimate stack size and assume no heap.\n\
657 --extra-stack-space=bytes Space for negative sp access (default 2000) if\n\
658 --reserved-space not given.\n\
659 --soft-icache Generate software icache overlays.\n\
660 --num-lines Number of soft-icache lines (default 32).\n\
661 --line-size Size of soft-icache lines (default 1k).\n\
662 --non-ia-text Allow non-icache code in icache lines.\n\
663 --lrlive-analysis Scan function prologue for lr liveness.\n"
664 ));
665 '
666
667 PARSE_AND_LIST_ARGS_CASES='
668 case OPTION_SPU_PLUGIN:
669 spu_elf_plugin (1);
670 break;
671
672 case OPTION_SPU_NO_OVERLAYS:
673 no_overlays = 1;
674 break;
675
676 case OPTION_SPU_COMPACT_STUBS:
677 params.compact_stub = 1;
678 break;
679
680 case OPTION_SPU_STUB_SYMS:
681 params.emit_stub_syms = 1;
682 break;
683
684 case OPTION_SPU_NON_OVERLAY_STUBS:
685 params.non_overlay_stubs = 1;
686 break;
687
688 case OPTION_SPU_LOCAL_STORE:
689 {
690 char *end;
691 params.local_store_lo = strtoul (optarg, &end, 0);
692 if (*end == '\'':'\'')
693 {
694 params.local_store_hi = strtoul (end + 1, &end, 0);
695 if (*end == 0)
696 break;
697 }
698 einfo (_("%P%F: invalid --local-store address range `%s'\''\n"), optarg);
699 }
700 break;
701
702 case OPTION_SPU_STACK_ANALYSIS:
703 params.stack_analysis = 1;
704 break;
705
706 case OPTION_SPU_STACK_SYMS:
707 params.emit_stack_syms = 1;
708 break;
709
710 case OPTION_SPU_AUTO_OVERLAY:
711 params.auto_overlay |= 1;
712 if (optarg != NULL)
713 {
714 auto_overlay_file = optarg;
715 break;
716 }
717 /* Fall thru */
718
719 case OPTION_SPU_AUTO_RELINK:
720 params.auto_overlay |= 2;
721 break;
722
723 case OPTION_SPU_OVERLAY_RODATA:
724 params.auto_overlay |= 4;
725 break;
726
727 case OPTION_SPU_SOFT_ICACHE:
728 params.ovly_flavour = ovly_soft_icache;
729 if (!num_lines_set)
730 params.num_lines = 32;
731 else if ((params.num_lines & -params.num_lines) != params.num_lines)
732 einfo (_("%P%F: invalid --num-lines/--num-regions `%u'\''\n"),
733 params.num_lines);
734 if (!line_size_set)
735 params.line_size = 1024;
736 else if ((params.line_size & -params.line_size) != params.line_size)
737 einfo (_("%P%F: invalid --line-size/--region-size `%u'\''\n"),
738 params.line_size);
739 break;
740
741 case OPTION_SPU_LRLIVE:
742 params.lrlive_analysis = 1;
743 break;
744
745 case OPTION_SPU_NON_IA_TEXT:
746 params.non_ia_text = 1;
747 break;
748
749 case OPTION_SPU_NUM_LINES:
750 {
751 char *end;
752 params.num_lines = strtoul (optarg, &end, 0);
753 num_lines_set = 1;
754 if (*end == 0
755 && (params.ovly_flavour != ovly_soft_icache
756 || (params.num_lines & -params.num_lines) == params.num_lines))
757 break;
758 einfo (_("%P%F: invalid --num-lines/--num-regions `%s'\''\n"), optarg);
759 }
760 break;
761
762 case OPTION_SPU_LINE_SIZE:
763 {
764 char *end;
765 params.line_size = strtoul (optarg, &end, 0);
766 line_size_set = 1;
767 if (*end == 0
768 && (params.ovly_flavour != ovly_soft_icache
769 || (params.line_size & -params.line_size) == params.line_size))
770 break;
771 einfo (_("%P%F: invalid --line-size/--region-size `%s'\''\n"), optarg);
772 }
773 break;
774
775 case OPTION_SPU_FIXED_SPACE:
776 {
777 char *end;
778 params.auto_overlay_fixed = strtoul (optarg, &end, 0);
779 if (*end != 0)
780 einfo (_("%P%F: invalid --fixed-space value `%s'\''\n"), optarg);
781 }
782 break;
783
784 case OPTION_SPU_RESERVED_SPACE:
785 {
786 char *end;
787 params.auto_overlay_reserved = strtoul (optarg, &end, 0);
788 if (*end != 0)
789 einfo (_("%P%F: invalid --reserved-space value `%s'\''\n"), optarg);
790 }
791 break;
792
793 case OPTION_SPU_EXTRA_STACK:
794 {
795 char *end;
796 params.extra_stack_space = strtol (optarg, &end, 0);
797 if (*end != 0)
798 einfo (_("%P%F: invalid --extra-stack-space value `%s'\''\n"), optarg);
799 }
800 break;
801
802 case OPTION_SPU_NO_AUTO_OVERLAY:
803 params.auto_overlay = 0;
804 if (optarg != NULL)
805 {
806 struct tflist *tf;
807 size_t len;
808
809 if (tmp_file_list == NULL)
810 atexit (clean_tmp);
811
812 len = strlen (optarg) + 1;
813 tf = xmalloc (sizeof (*tf) - sizeof (tf->name) + len);
814 memcpy (tf->name, optarg, len);
815 tf->next = tmp_file_list;
816 tmp_file_list = tf;
817 break;
818 }
819 break;
820 '
821
822 LDEMUL_AFTER_OPEN=spu_after_open
823 LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
824 LDEMUL_FINISH=gld${EMULATION_NAME}_finish
825 LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
This page took 0.046578 seconds and 5 git commands to generate.