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