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, 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 spu_elf_place_overlay_data (&link_info);
313 }
314
315 /* We must not cache anything from the preliminary sizing. */
316 lang_reset_memory_regions ();
317 }
318
319 if (is_spu_target ()
320 && !link_info.relocatable)
321 spu_elf_size_sections (link_info.output_bfd, &link_info);
322
323 gld${EMULATION_NAME}_before_allocation ();
324 }
325
326 struct tflist {
327 struct tflist *next;
328 char name[9];
329 };
330
331 static struct tflist *tmp_file_list;
332
333 static void clean_tmp (void)
334 {
335 for (; tmp_file_list != NULL; tmp_file_list = tmp_file_list->next)
336 unlink (tmp_file_list->name);
337 }
338
339 static int
340 new_tmp_file (char **fname)
341 {
342 struct tflist *tf;
343 int fd;
344
345 if (tmp_file_list == NULL)
346 atexit (clean_tmp);
347 tf = xmalloc (sizeof (*tf));
348 tf->next = tmp_file_list;
349 tmp_file_list = tf;
350 memcpy (tf->name, "ldXXXXXX", sizeof (tf->name));
351 *fname = tf->name;
352 #ifdef HAVE_MKSTEMP
353 fd = mkstemp (*fname);
354 #else
355 *fname = mktemp (*fname);
356 if (*fname == NULL)
357 return -1;
358 fd = open (fname, O_RDWR | O_CREAT | O_EXCL, 0600);
359 #endif
360 return fd;
361 }
362
363 static FILE *
364 spu_elf_open_overlay_script (void)
365 {
366 FILE *script = NULL;
367
368 if (auto_overlay_file == NULL)
369 {
370 int fd = new_tmp_file (&auto_overlay_file);
371 if (fd == -1)
372 goto file_err;
373 script = fdopen (fd, "w");
374 }
375 else
376 script = fopen (auto_overlay_file, "w");
377
378 if (script == NULL)
379 {
380 file_err:
381 einfo ("%F%P: can not open script: %E\n");
382 }
383 return script;
384 }
385
386 static void
387 spu_elf_relink (void)
388 {
389 char **argv = xmalloc ((my_argc + 4) * sizeof (*argv));
390
391 memcpy (argv, my_argv, my_argc * sizeof (*argv));
392 argv[my_argc++] = "--no-auto-overlay";
393 if (tmp_file_list->name == auto_overlay_file)
394 argv[my_argc - 1] = concat (argv[my_argc - 1], "=",
395 auto_overlay_file, (const char *) NULL);
396 argv[my_argc++] = "-T";
397 argv[my_argc++] = auto_overlay_file;
398 argv[my_argc] = 0;
399 execvp (argv[0], (char *const *) argv);
400 perror (argv[0]);
401 _exit (127);
402 }
403
404 /* Final emulation specific call. */
405
406 static void
407 gld${EMULATION_NAME}_finish (void)
408 {
409 int need_laying_out;
410
411 need_laying_out = bfd_elf_discard_info (link_info.output_bfd, &link_info);
412
413 gld${EMULATION_NAME}_map_segments (need_laying_out);
414
415 if (is_spu_target ())
416 {
417 if (params.local_store_lo < params.local_store_hi)
418 {
419 asection *s;
420
421 s = spu_elf_check_vma (&link_info);
422 if (s != NULL && !params.auto_overlay)
423 einfo ("%X%P: %A exceeds local store range\n", s);
424 }
425 else if (params.auto_overlay)
426 einfo ("%P: --auto-overlay ignored with zero local store range\n");
427 }
428
429 finish_default ();
430 }
431
432 static char *
433 gld${EMULATION_NAME}_choose_target (int argc, char *argv[])
434 {
435 my_argc = argc;
436 my_argv = argv;
437 return ldemul_default_target (argc, argv);
438 }
439
440 EOF
441
442 if grep -q 'ld_elf.*ppc.*_emulation' ldemul-list.h; then
443 fragment <<EOF
444 #include <errno.h>
445 #include "filenames.h"
446 #include "libiberty.h"
447
448 static const char *
449 base_name (const char *path)
450 {
451 const char *file = strrchr (path, '/');
452 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
453 {
454 char *bslash = strrchr (path, '\\\\');
455
456 if (file == NULL || (bslash != NULL && bslash > file))
457 file = bslash;
458 if (file == NULL
459 && path[0] != '\0'
460 && path[1] == ':')
461 file = path + 1;
462 }
463 #endif
464 if (file == NULL)
465 file = path;
466 else
467 ++file;
468 return file;
469 }
470
471 /* This function is called when building a ppc32 or ppc64 executable
472 to handle embedded spu images. */
473 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
474
475 bfd_boolean
476 embedded_spu_file (lang_input_statement_type *entry, const char *flags)
477 {
478 const char *cmd[6];
479 const char *pex_return;
480 const char *sym;
481 char *handle, *p;
482 char *oname;
483 int fd;
484 int status;
485 union lang_statement_union **old_stat_tail;
486 union lang_statement_union **old_file_tail;
487 union lang_statement_union *new_ent;
488 lang_input_statement_type *search;
489
490 if (entry->the_bfd->format != bfd_object
491 || strcmp (entry->the_bfd->xvec->name, "elf32-spu") != 0
492 || (entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_EXEC
493 && entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_DYN))
494 return FALSE;
495
496 /* Use the filename as the symbol marking the program handle struct. */
497 sym = base_name (entry->the_bfd->filename);
498
499 handle = xstrdup (sym);
500 for (p = handle; *p; ++p)
501 if (!(ISALNUM (*p) || *p == '$' || *p == '.'))
502 *p = '_';
503
504 fd = new_tmp_file (&oname);
505 if (fd == -1)
506 return FALSE;
507 close (fd);
508
509 for (search = (lang_input_statement_type *) input_file_chain.head;
510 search != NULL;
511 search = (lang_input_statement_type *) search->next_real_file)
512 if (search->filename != NULL)
513 {
514 const char *infile = base_name (search->filename);
515
516 if (strncmp (infile, "crtbegin", 8) == 0)
517 {
518 if (infile[8] == 'S')
519 flags = concat (flags, " -fPIC", (const char *) NULL);
520 else if (infile[8] == 'T')
521 flags = concat (flags, " -fpie", (const char *) NULL);
522 break;
523 }
524 }
525
526 cmd[0] = EMBEDSPU;
527 cmd[1] = flags;
528 cmd[2] = handle;
529 cmd[3] = entry->the_bfd->filename;
530 cmd[4] = oname;
531 cmd[5] = NULL;
532 if (trace_file_tries)
533 {
534 info_msg (_("running: %s \"%s\" \"%s\" \"%s\" \"%s\"\n"),
535 cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]);
536 fflush (stdout);
537 }
538
539 pex_return = pex_one (PEX_SEARCH | PEX_LAST, cmd[0], (char *const *) cmd,
540 cmd[0], NULL, NULL, &status, &errno);
541 if (NULL != pex_return) {
542 if (strcmp ("embedspu", EMBEDSPU) != 0)
543 {
544 cmd[0] = "embedspu";
545 pex_return = pex_one (PEX_SEARCH | PEX_LAST, cmd[0], (char *const *) cmd,
546 cmd[0], NULL, NULL, &status, &errno);
547 }
548 if (NULL != pex_return) {
549 perror (pex_return);
550 _exit (127);
551 }
552 }
553 if (status)
554 return FALSE;
555
556
557 old_stat_tail = stat_ptr->tail;
558 old_file_tail = input_file_chain.tail;
559 if (lang_add_input_file (oname, lang_input_file_is_file_enum, NULL) == NULL)
560 return FALSE;
561
562 /* lang_add_input_file puts the new list entry at the end of the statement
563 and input file lists. Move it to just after the current entry. */
564 new_ent = *old_stat_tail;
565 *old_stat_tail = NULL;
566 stat_ptr->tail = old_stat_tail;
567 *old_file_tail = NULL;
568 input_file_chain.tail = old_file_tail;
569 new_ent->header.next = entry->header.next;
570 entry->header.next = new_ent;
571 new_ent->input_statement.next_real_file = entry->next_real_file;
572 entry->next_real_file = new_ent;
573
574 /* Ensure bfd sections are excluded from the output. */
575 bfd_section_list_clear (entry->the_bfd);
576 entry->loaded = TRUE;
577 return TRUE;
578 }
579
580 EOF
581 fi
582
583 # Define some shell vars to insert bits of code into the standard elf
584 # parse_args and list_options functions.
585 #
586 PARSE_AND_LIST_PROLOGUE='
587 #define OPTION_SPU_PLUGIN 301
588 #define OPTION_SPU_NO_OVERLAYS (OPTION_SPU_PLUGIN + 1)
589 #define OPTION_SPU_COMPACT_STUBS (OPTION_SPU_NO_OVERLAYS + 1)
590 #define OPTION_SPU_STUB_SYMS (OPTION_SPU_COMPACT_STUBS + 1)
591 #define OPTION_SPU_NON_OVERLAY_STUBS (OPTION_SPU_STUB_SYMS + 1)
592 #define OPTION_SPU_LOCAL_STORE (OPTION_SPU_NON_OVERLAY_STUBS + 1)
593 #define OPTION_SPU_STACK_ANALYSIS (OPTION_SPU_LOCAL_STORE + 1)
594 #define OPTION_SPU_STACK_SYMS (OPTION_SPU_STACK_ANALYSIS + 1)
595 #define OPTION_SPU_AUTO_OVERLAY (OPTION_SPU_STACK_SYMS + 1)
596 #define OPTION_SPU_AUTO_RELINK (OPTION_SPU_AUTO_OVERLAY + 1)
597 #define OPTION_SPU_OVERLAY_RODATA (OPTION_SPU_AUTO_RELINK + 1)
598 #define OPTION_SPU_SOFT_ICACHE (OPTION_SPU_OVERLAY_RODATA + 1)
599 #define OPTION_SPU_LINE_SIZE (OPTION_SPU_SOFT_ICACHE + 1)
600 #define OPTION_SPU_NUM_LINES (OPTION_SPU_LINE_SIZE + 1)
601 #define OPTION_SPU_LRLIVE (OPTION_SPU_NUM_LINES + 1)
602 #define OPTION_SPU_NON_IA_TEXT (OPTION_SPU_LRLIVE + 1)
603 #define OPTION_SPU_FIXED_SPACE (OPTION_SPU_NON_IA_TEXT + 1)
604 #define OPTION_SPU_RESERVED_SPACE (OPTION_SPU_FIXED_SPACE + 1)
605 #define OPTION_SPU_EXTRA_STACK (OPTION_SPU_RESERVED_SPACE + 1)
606 #define OPTION_SPU_NO_AUTO_OVERLAY (OPTION_SPU_EXTRA_STACK + 1)
607 #define OPTION_SPU_EMIT_FIXUPS (OPTION_SPU_NO_AUTO_OVERLAY + 1)
608 '
609
610 PARSE_AND_LIST_LONGOPTS='
611 { "plugin", no_argument, NULL, OPTION_SPU_PLUGIN },
612 { "soft-icache", no_argument, NULL, OPTION_SPU_SOFT_ICACHE },
613 { "lrlive-analysis", no_argument, NULL, OPTION_SPU_LRLIVE },
614 { "num-lines", required_argument, NULL, OPTION_SPU_NUM_LINES },
615 { "line-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
616 { "non-ia-text", no_argument, NULL, OPTION_SPU_NON_IA_TEXT },
617 { "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
618 { "compact-stubs", no_argument, NULL, OPTION_SPU_COMPACT_STUBS },
619 { "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
620 { "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
621 { "local-store", required_argument, NULL, OPTION_SPU_LOCAL_STORE },
622 { "stack-analysis", no_argument, NULL, OPTION_SPU_STACK_ANALYSIS },
623 { "emit-stack-syms", no_argument, NULL, OPTION_SPU_STACK_SYMS },
624 { "auto-overlay", optional_argument, NULL, OPTION_SPU_AUTO_OVERLAY },
625 { "auto-relink", no_argument, NULL, OPTION_SPU_AUTO_RELINK },
626 { "overlay-rodata", no_argument, NULL, OPTION_SPU_OVERLAY_RODATA },
627 { "num-regions", required_argument, NULL, OPTION_SPU_NUM_LINES },
628 { "region-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
629 { "fixed-space", required_argument, NULL, OPTION_SPU_FIXED_SPACE },
630 { "reserved-space", required_argument, NULL, OPTION_SPU_RESERVED_SPACE },
631 { "extra-stack-space", required_argument, NULL, OPTION_SPU_EXTRA_STACK },
632 { "no-auto-overlay", optional_argument, NULL, OPTION_SPU_NO_AUTO_OVERLAY },
633 { "emit-fixups", optional_argument, NULL, OPTION_SPU_EMIT_FIXUPS },
634 '
635
636 PARSE_AND_LIST_OPTIONS='
637 fprintf (file, _("\
638 --plugin Make SPU plugin.\n\
639 --no-overlays No overlay handling.\n\
640 --compact-stubs Use smaller and possibly slower call stubs.\n\
641 --emit-stub-syms Add symbols on overlay call stubs.\n\
642 --extra-overlay-stubs Add stubs on all calls out of overlay regions.\n\
643 --local-store=lo:hi Valid address range.\n\
644 --stack-analysis Estimate maximum stack requirement.\n\
645 --emit-stack-syms Add sym giving stack needed for each func.\n\
646 --auto-overlay [=filename] Create an overlay script in filename if\n\
647 executable does not fit in local store.\n\
648 --auto-relink Rerun linker using auto-overlay script.\n\
649 --overlay-rodata Place read-only data with associated function\n\
650 code in overlays.\n\
651 --num-regions Number of overlay buffers (default 1).\n\
652 --region-size Size of overlay buffers (default 0, auto).\n\
653 --fixed-space=bytes Local store for non-overlay code and data.\n\
654 --reserved-space=bytes Local store for stack and heap. If not specified\n\
655 ld will estimate stack size and assume no heap.\n\
656 --extra-stack-space=bytes Space for negative sp access (default 2000) if\n\
657 --reserved-space not given.\n\
658 --soft-icache Generate software icache overlays.\n\
659 --num-lines Number of soft-icache lines (default 32).\n\
660 --line-size Size of soft-icache lines (default 1k).\n\
661 --non-ia-text Allow non-icache code in icache lines.\n\
662 --lrlive-analysis Scan function prologue for lr liveness.\n"
663 ));
664 '
665
666 PARSE_AND_LIST_ARGS_CASES='
667 case OPTION_SPU_PLUGIN:
668 spu_elf_plugin (1);
669 break;
670
671 case OPTION_SPU_NO_OVERLAYS:
672 no_overlays = 1;
673 break;
674
675 case OPTION_SPU_COMPACT_STUBS:
676 params.compact_stub = 1;
677 break;
678
679 case OPTION_SPU_STUB_SYMS:
680 params.emit_stub_syms = 1;
681 break;
682
683 case OPTION_SPU_NON_OVERLAY_STUBS:
684 params.non_overlay_stubs = 1;
685 break;
686
687 case OPTION_SPU_LOCAL_STORE:
688 {
689 char *end;
690 params.local_store_lo = strtoul (optarg, &end, 0);
691 if (*end == '\'':'\'')
692 {
693 params.local_store_hi = strtoul (end + 1, &end, 0);
694 if (*end == 0)
695 break;
696 }
697 einfo (_("%P%F: invalid --local-store address range `%s'\''\n"), optarg);
698 }
699 break;
700
701 case OPTION_SPU_STACK_ANALYSIS:
702 params.stack_analysis = 1;
703 break;
704
705 case OPTION_SPU_STACK_SYMS:
706 params.emit_stack_syms = 1;
707 break;
708
709 case OPTION_SPU_AUTO_OVERLAY:
710 params.auto_overlay |= 1;
711 if (optarg != NULL)
712 {
713 auto_overlay_file = optarg;
714 break;
715 }
716 /* Fall thru */
717
718 case OPTION_SPU_AUTO_RELINK:
719 params.auto_overlay |= 2;
720 break;
721
722 case OPTION_SPU_OVERLAY_RODATA:
723 params.auto_overlay |= 4;
724 break;
725
726 case OPTION_SPU_SOFT_ICACHE:
727 params.ovly_flavour = ovly_soft_icache;
728 /* Software i-cache stubs are always "compact". */
729 params.compact_stub = 1;
730 if (!num_lines_set)
731 params.num_lines = 32;
732 else if ((params.num_lines & -params.num_lines) != params.num_lines)
733 einfo (_("%P%F: invalid --num-lines/--num-regions `%u'\''\n"),
734 params.num_lines);
735 if (!line_size_set)
736 params.line_size = 1024;
737 else if ((params.line_size & -params.line_size) != params.line_size)
738 einfo (_("%P%F: invalid --line-size/--region-size `%u'\''\n"),
739 params.line_size);
740 break;
741
742 case OPTION_SPU_LRLIVE:
743 params.lrlive_analysis = 1;
744 break;
745
746 case OPTION_SPU_NON_IA_TEXT:
747 params.non_ia_text = 1;
748 break;
749
750 case OPTION_SPU_NUM_LINES:
751 {
752 char *end;
753 params.num_lines = strtoul (optarg, &end, 0);
754 num_lines_set = 1;
755 if (*end == 0
756 && (params.ovly_flavour != ovly_soft_icache
757 || (params.num_lines & -params.num_lines) == params.num_lines))
758 break;
759 einfo (_("%P%F: invalid --num-lines/--num-regions `%s'\''\n"), optarg);
760 }
761 break;
762
763 case OPTION_SPU_LINE_SIZE:
764 {
765 char *end;
766 params.line_size = strtoul (optarg, &end, 0);
767 line_size_set = 1;
768 if (*end == 0
769 && (params.ovly_flavour != ovly_soft_icache
770 || (params.line_size & -params.line_size) == params.line_size))
771 break;
772 einfo (_("%P%F: invalid --line-size/--region-size `%s'\''\n"), optarg);
773 }
774 break;
775
776 case OPTION_SPU_FIXED_SPACE:
777 {
778 char *end;
779 params.auto_overlay_fixed = strtoul (optarg, &end, 0);
780 if (*end != 0)
781 einfo (_("%P%F: invalid --fixed-space value `%s'\''\n"), optarg);
782 }
783 break;
784
785 case OPTION_SPU_RESERVED_SPACE:
786 {
787 char *end;
788 params.auto_overlay_reserved = strtoul (optarg, &end, 0);
789 if (*end != 0)
790 einfo (_("%P%F: invalid --reserved-space value `%s'\''\n"), optarg);
791 }
792 break;
793
794 case OPTION_SPU_EXTRA_STACK:
795 {
796 char *end;
797 params.extra_stack_space = strtol (optarg, &end, 0);
798 if (*end != 0)
799 einfo (_("%P%F: invalid --extra-stack-space value `%s'\''\n"), optarg);
800 }
801 break;
802
803 case OPTION_SPU_NO_AUTO_OVERLAY:
804 params.auto_overlay = 0;
805 if (optarg != NULL)
806 {
807 struct tflist *tf;
808 size_t len;
809
810 if (tmp_file_list == NULL)
811 atexit (clean_tmp);
812
813 len = strlen (optarg) + 1;
814 tf = xmalloc (sizeof (*tf) - sizeof (tf->name) + len);
815 memcpy (tf->name, optarg, len);
816 tf->next = tmp_file_list;
817 tmp_file_list = tf;
818 break;
819 }
820 break;
821
822 case OPTION_SPU_EMIT_FIXUPS:
823 params.emit_fixups = 1;
824 break;
825 '
826
827 LDEMUL_AFTER_OPEN=spu_after_open
828 LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
829 LDEMUL_FINISH=gld${EMULATION_NAME}_finish
830 LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
This page took 0.046429 seconds and 5 git commands to generate.