OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [emultempl/] [spuelf.em] - Blame information for rev 205

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
# 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 <
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 <
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 <
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, ¶ms);
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
  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 <
438
#include 
439
#include "filenames.h"
440
#include "libiberty.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 *pex_return;
474
  const char *sym;
475
  char *handle, *p;
476
  char *oname;
477
  int fd;
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
  cmd[0] = EMBEDSPU;
521
  cmd[1] = flags;
522
  cmd[2] = handle;
523
  cmd[3] = entry->the_bfd->filename;
524
  cmd[4] = oname;
525
  cmd[5] = NULL;
526
  if (trace_file_tries)
527
    {
528
      info_msg (_("running: %s \"%s\" \"%s\" \"%s\" \"%s\"\n"),
529
                cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]);
530
      fflush (stdout);
531
    }
532
 
533
  pex_return = pex_one (PEX_SEARCH | PEX_LAST, cmd[0], (char *const *) cmd,
534
                        cmd[0], NULL, NULL, &status, &errno);
535
  if (NULL != pex_return) {
536
      if (strcmp ("embedspu", EMBEDSPU) != 0)
537
        {
538
          cmd[0] = "embedspu";
539
          pex_return = pex_one (PEX_SEARCH | PEX_LAST, cmd[0], (char *const *) cmd,
540
                                cmd[0], NULL, NULL, &status, &errno);
541
        }
542
      if (NULL != pex_return) {
543
        perror (pex_return);
544
        _exit (127);
545
      }
546
  }
547
  if (status)
548
    return FALSE;
549
 
550
 
551
  old_stat_tail = stat_ptr->tail;
552
  old_file_tail = input_file_chain.tail;
553
  if (lang_add_input_file (oname, lang_input_file_is_file_enum, NULL) == NULL)
554
    return FALSE;
555
 
556
  /* lang_add_input_file puts the new list entry at the end of the statement
557
     and input file lists.  Move it to just after the current entry.  */
558
  new_ent = *old_stat_tail;
559
  *old_stat_tail = NULL;
560
  stat_ptr->tail = old_stat_tail;
561
  *old_file_tail = NULL;
562
  input_file_chain.tail = old_file_tail;
563
  new_ent->header.next = entry->header.next;
564
  entry->header.next = new_ent;
565
  new_ent->input_statement.next_real_file = entry->next_real_file;
566
  entry->next_real_file = new_ent;
567
 
568
  /* Ensure bfd sections are excluded from the output.  */
569
  bfd_section_list_clear (entry->the_bfd);
570
  entry->loaded = TRUE;
571
  return TRUE;
572
}
573
 
574
EOF
575
fi
576
 
577
# Define some shell vars to insert bits of code into the standard elf
578
# parse_args and list_options functions.
579
#
580
PARSE_AND_LIST_PROLOGUE='
581
#define OPTION_SPU_PLUGIN               301
582
#define OPTION_SPU_NO_OVERLAYS          (OPTION_SPU_PLUGIN + 1)
583
#define OPTION_SPU_COMPACT_STUBS        (OPTION_SPU_NO_OVERLAYS + 1)
584
#define OPTION_SPU_STUB_SYMS            (OPTION_SPU_COMPACT_STUBS + 1)
585
#define OPTION_SPU_NON_OVERLAY_STUBS    (OPTION_SPU_STUB_SYMS + 1)
586
#define OPTION_SPU_LOCAL_STORE          (OPTION_SPU_NON_OVERLAY_STUBS + 1)
587
#define OPTION_SPU_STACK_ANALYSIS       (OPTION_SPU_LOCAL_STORE + 1)
588
#define OPTION_SPU_STACK_SYMS           (OPTION_SPU_STACK_ANALYSIS + 1)
589
#define OPTION_SPU_AUTO_OVERLAY         (OPTION_SPU_STACK_SYMS + 1)
590
#define OPTION_SPU_AUTO_RELINK          (OPTION_SPU_AUTO_OVERLAY + 1)
591
#define OPTION_SPU_OVERLAY_RODATA       (OPTION_SPU_AUTO_RELINK + 1)
592
#define OPTION_SPU_SOFT_ICACHE          (OPTION_SPU_OVERLAY_RODATA + 1)
593
#define OPTION_SPU_LINE_SIZE            (OPTION_SPU_SOFT_ICACHE + 1)
594
#define OPTION_SPU_NUM_LINES            (OPTION_SPU_LINE_SIZE + 1)
595
#define OPTION_SPU_LRLIVE               (OPTION_SPU_NUM_LINES + 1)
596
#define OPTION_SPU_NON_IA_TEXT          (OPTION_SPU_LRLIVE + 1)
597
#define OPTION_SPU_FIXED_SPACE          (OPTION_SPU_NON_IA_TEXT + 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
#define OPTION_SPU_EMIT_FIXUPS          (OPTION_SPU_NO_AUTO_OVERLAY + 1)
602
'
603
 
604
PARSE_AND_LIST_LONGOPTS='
605
  { "plugin", no_argument, NULL, OPTION_SPU_PLUGIN },
606
  { "soft-icache", no_argument, NULL, OPTION_SPU_SOFT_ICACHE },
607
  { "lrlive-analysis", no_argument, NULL, OPTION_SPU_LRLIVE },
608
  { "num-lines", required_argument, NULL, OPTION_SPU_NUM_LINES },
609
  { "line-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
610
  { "non-ia-text", no_argument, NULL, OPTION_SPU_NON_IA_TEXT },
611
  { "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
612
  { "compact-stubs", no_argument, NULL, OPTION_SPU_COMPACT_STUBS },
613
  { "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
614
  { "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
615
  { "local-store", required_argument, NULL, OPTION_SPU_LOCAL_STORE },
616
  { "stack-analysis", no_argument, NULL, OPTION_SPU_STACK_ANALYSIS },
617
  { "emit-stack-syms", no_argument, NULL, OPTION_SPU_STACK_SYMS },
618
  { "auto-overlay", optional_argument, NULL, OPTION_SPU_AUTO_OVERLAY },
619
  { "auto-relink", no_argument, NULL, OPTION_SPU_AUTO_RELINK },
620
  { "overlay-rodata", no_argument, NULL, OPTION_SPU_OVERLAY_RODATA },
621
  { "num-regions", required_argument, NULL, OPTION_SPU_NUM_LINES },
622
  { "region-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
623
  { "fixed-space", required_argument, NULL, OPTION_SPU_FIXED_SPACE },
624
  { "reserved-space", required_argument, NULL, OPTION_SPU_RESERVED_SPACE },
625
  { "extra-stack-space", required_argument, NULL, OPTION_SPU_EXTRA_STACK },
626
  { "no-auto-overlay", optional_argument, NULL, OPTION_SPU_NO_AUTO_OVERLAY },
627
  { "emit-fixups", optional_argument, NULL, OPTION_SPU_EMIT_FIXUPS },
628
'
629
 
630
PARSE_AND_LIST_OPTIONS='
631
  fprintf (file, _("\
632
  --plugin                    Make SPU plugin.\n\
633
  --no-overlays               No overlay handling.\n\
634
  --compact-stubs             Use smaller and possibly slower call stubs.\n\
635
  --emit-stub-syms            Add symbols on overlay call stubs.\n\
636
  --extra-overlay-stubs       Add stubs on all calls out of overlay regions.\n\
637
  --local-store=lo:hi         Valid address range.\n\
638
  --stack-analysis            Estimate maximum stack requirement.\n\
639
  --emit-stack-syms           Add sym giving stack needed for each func.\n\
640
  --auto-overlay [=filename]  Create an overlay script in filename if\n\
641
                              executable does not fit in local store.\n\
642
  --auto-relink               Rerun linker using auto-overlay script.\n\
643
  --overlay-rodata            Place read-only data with associated function\n\
644
                              code in overlays.\n\
645
  --num-regions               Number of overlay buffers (default 1).\n\
646
  --region-size               Size of overlay buffers (default 0, auto).\n\
647
  --fixed-space=bytes         Local store for non-overlay code and data.\n\
648
  --reserved-space=bytes      Local store for stack and heap.  If not specified\n\
649
                              ld will estimate stack size and assume no heap.\n\
650
  --extra-stack-space=bytes   Space for negative sp access (default 2000) if\n\
651
                              --reserved-space not given.\n\
652
  --soft-icache               Generate software icache overlays.\n\
653
  --num-lines                 Number of soft-icache lines (default 32).\n\
654
  --line-size                 Size of soft-icache lines (default 1k).\n\
655
  --non-ia-text               Allow non-icache code in icache lines.\n\
656
  --lrlive-analysis           Scan function prologue for lr liveness.\n"
657
                   ));
658
'
659
 
660
PARSE_AND_LIST_ARGS_CASES='
661
    case OPTION_SPU_PLUGIN:
662
      spu_elf_plugin (1);
663
      break;
664
 
665
    case OPTION_SPU_NO_OVERLAYS:
666
      no_overlays = 1;
667
      break;
668
 
669
    case OPTION_SPU_COMPACT_STUBS:
670
      params.compact_stub = 1;
671
      break;
672
 
673
    case OPTION_SPU_STUB_SYMS:
674
      params.emit_stub_syms = 1;
675
      break;
676
 
677
    case OPTION_SPU_NON_OVERLAY_STUBS:
678
      params.non_overlay_stubs = 1;
679
      break;
680
 
681
    case OPTION_SPU_LOCAL_STORE:
682
      {
683
        char *end;
684
        params.local_store_lo = strtoul (optarg, &end, 0);
685
        if (*end == '\'':'\'')
686
          {
687
            params.local_store_hi = strtoul (end + 1, &end, 0);
688
            if (*end == 0)
689
              break;
690
          }
691
        einfo (_("%P%F: invalid --local-store address range `%s'\''\n"), optarg);
692
      }
693
      break;
694
 
695
    case OPTION_SPU_STACK_ANALYSIS:
696
      params.stack_analysis = 1;
697
      break;
698
 
699
    case OPTION_SPU_STACK_SYMS:
700
      params.emit_stack_syms = 1;
701
      break;
702
 
703
    case OPTION_SPU_AUTO_OVERLAY:
704
      params.auto_overlay |= 1;
705
      if (optarg != NULL)
706
        {
707
          auto_overlay_file = optarg;
708
          break;
709
        }
710
      /* Fall thru */
711
 
712
    case OPTION_SPU_AUTO_RELINK:
713
      params.auto_overlay |= 2;
714
      break;
715
 
716
    case OPTION_SPU_OVERLAY_RODATA:
717
      params.auto_overlay |= 4;
718
      break;
719
 
720
    case OPTION_SPU_SOFT_ICACHE:
721
      params.ovly_flavour = ovly_soft_icache;
722
      /* Software i-cache stubs are always "compact".  */
723
      params.compact_stub = 1;
724
      if (!num_lines_set)
725
        params.num_lines = 32;
726
      else if ((params.num_lines & -params.num_lines) != params.num_lines)
727
        einfo (_("%P%F: invalid --num-lines/--num-regions `%u'\''\n"),
728
               params.num_lines);
729
      if (!line_size_set)
730
        params.line_size = 1024;
731
      else if ((params.line_size & -params.line_size) != params.line_size)
732
        einfo (_("%P%F: invalid --line-size/--region-size `%u'\''\n"),
733
               params.line_size);
734
      break;
735
 
736
    case OPTION_SPU_LRLIVE:
737
      params.lrlive_analysis = 1;
738
      break;
739
 
740
    case OPTION_SPU_NON_IA_TEXT:
741
      params.non_ia_text = 1;
742
      break;
743
 
744
    case OPTION_SPU_NUM_LINES:
745
      {
746
        char *end;
747
        params.num_lines = strtoul (optarg, &end, 0);
748
        num_lines_set = 1;
749
        if (*end == 0
750
            && (params.ovly_flavour != ovly_soft_icache
751
                || (params.num_lines & -params.num_lines) == params.num_lines))
752
          break;
753
        einfo (_("%P%F: invalid --num-lines/--num-regions `%s'\''\n"), optarg);
754
      }
755
      break;
756
 
757
    case OPTION_SPU_LINE_SIZE:
758
      {
759
        char *end;
760
        params.line_size = strtoul (optarg, &end, 0);
761
        line_size_set = 1;
762
        if (*end == 0
763
            && (params.ovly_flavour != ovly_soft_icache
764
                || (params.line_size & -params.line_size) == params.line_size))
765
          break;
766
        einfo (_("%P%F: invalid --line-size/--region-size `%s'\''\n"), optarg);
767
      }
768
      break;
769
 
770
    case OPTION_SPU_FIXED_SPACE:
771
      {
772
        char *end;
773
        params.auto_overlay_fixed = strtoul (optarg, &end, 0);
774
        if (*end != 0)
775
          einfo (_("%P%F: invalid --fixed-space value `%s'\''\n"), optarg);
776
      }
777
      break;
778
 
779
    case OPTION_SPU_RESERVED_SPACE:
780
      {
781
        char *end;
782
        params.auto_overlay_reserved = strtoul (optarg, &end, 0);
783
        if (*end != 0)
784
          einfo (_("%P%F: invalid --reserved-space value `%s'\''\n"), optarg);
785
      }
786
      break;
787
 
788
    case OPTION_SPU_EXTRA_STACK:
789
      {
790
        char *end;
791
        params.extra_stack_space = strtol (optarg, &end, 0);
792
        if (*end != 0)
793
          einfo (_("%P%F: invalid --extra-stack-space value `%s'\''\n"), optarg);
794
      }
795
      break;
796
 
797
    case OPTION_SPU_NO_AUTO_OVERLAY:
798
      params.auto_overlay = 0;
799
      if (optarg != NULL)
800
        {
801
          struct tflist *tf;
802
          size_t len;
803
 
804
          if (tmp_file_list == NULL)
805
            atexit (clean_tmp);
806
 
807
          len = strlen (optarg) + 1;
808
          tf = xmalloc (sizeof (*tf) - sizeof (tf->name) + len);
809
          memcpy (tf->name, optarg, len);
810
          tf->next = tmp_file_list;
811
          tmp_file_list = tf;
812
          break;
813
        }
814
      break;
815
 
816
    case OPTION_SPU_EMIT_FIXUPS:
817
      params.emit_fixups = 1;
818
      break;
819
'
820
 
821
LDEMUL_AFTER_OPEN=spu_after_open
822
LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
823
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
824
LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.