Upload Tizen:Base source
[external/binutils.git] / ld / emultempl / tic6xdsbt.em
1 # This shell script emits a C file. -*- C -*-
2 #   Copyright 2011 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 C6X DSBT specific
23 # features.
24 #
25 fragment <<EOF
26 #include "ldctor.h"
27 #include "elf32-tic6x.h"
28
29 static struct elf32_tic6x_params params =
30 {
31   0, 64
32 };
33
34 static int
35 is_tic6x_target (void)
36 {
37   extern const bfd_target bfd_elf32_tic6x_le_vec;
38   extern const bfd_target bfd_elf32_tic6x_be_vec;
39
40   return (link_info.output_bfd->xvec == &bfd_elf32_tic6x_le_vec
41           || link_info.output_bfd->xvec == &bfd_elf32_tic6x_be_vec);
42 }
43
44 /* Pass params to backend.  */
45
46 static void
47 tic6x_after_open (void)
48 {
49   if (is_tic6x_target ())
50     {
51       if (params.dsbt_index >= params.dsbt_size)
52         {
53           einfo (_("%P%F: invalid --dsbt-index %d, outside DSBT size.\n"),
54                  params.dsbt_index);
55         }
56       elf32_tic6x_setup (&link_info, &params);
57     }
58
59   gld${EMULATION_NAME}_after_open ();
60 }
61 EOF
62
63 # This code gets inserted into the generic elf32.sc linker script
64 # and allows us to define our own command line switches.
65 PARSE_AND_LIST_PROLOGUE='
66 #define OPTION_DSBT_INDEX               300
67 #define OPTION_DSBT_SIZE                301
68 '
69
70 PARSE_AND_LIST_LONGOPTS='
71   {"dsbt-index", required_argument, NULL, OPTION_DSBT_INDEX},
72   {"dsbt-size", required_argument, NULL, OPTION_DSBT_SIZE},
73 '
74
75 PARSE_AND_LIST_OPTIONS='
76   fprintf (file, _("  --dsbt-index <index>\n"));
77   fprintf (file, _("\t\t\tUse this as the DSBT index for the output object\n"));
78   fprintf (file, _("  --dsbt-size <index>\n"));
79   fprintf (file, _("\t\t\tUse this as the number of entries in the DSBT table\n"));
80 '
81
82 PARSE_AND_LIST_ARGS_CASES='
83     case OPTION_DSBT_INDEX:
84       {
85         char *end;
86         params.dsbt_index = strtol (optarg, &end, 0);
87         if (*end == 0
88             && params.dsbt_index >= 0 && params.dsbt_index < 0x7fff)
89           break;
90         einfo (_("%P%F: invalid --dsbt-index %s\n"), optarg);
91       }
92       break;
93     case OPTION_DSBT_SIZE:
94       {
95         char *end;
96         params.dsbt_size = strtol (optarg, &end, 0);
97         if (*end == 0
98             && params.dsbt_size >= 0 && params.dsbt_size < 0x7fff)
99           break;
100         einfo (_("%P%F: invalid --dsbt-size %s\n"), optarg);
101       }
102       break;
103 '
104
105 LDEMUL_AFTER_OPEN=tic6x_after_open