1214571Sdim# This shell script emits a C file. -*- C -*-
2214571Sdim# Copyright 2007 Free Software Foundation, Inc.
3214571Sdim# Contributed by M R Swami Reddy <MR.Swami.Reddy@nsc.com>
4214571Sdim#
5214571Sdim# This file is part of GLD, the Gnu Linker.
6214571Sdim#
7214571Sdim# This program is free software; you can redistribute it and/or modify
8214571Sdim# it under the terms of the GNU General Public License as published by
9214571Sdim# the Free Software Foundation; either version 2 of the License, or
10214571Sdim# (at your option) any later version.
11214571Sdim#
12214571Sdim# This program is distributed in the hope that it will be useful,
13214571Sdim# but WITHOUT ANY WARRANTY; without even the implied warranty of
14214571Sdim# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15214571Sdim# GNU General Public License for more details.
16214571Sdim#
17214571Sdim# You should have received a copy of the GNU General Public License
18214571Sdim# along with this program; if not, write to the Free Software
19214571Sdim# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
20214571Sdim#
21214571Sdim
22214571Sdim# This file is sourced from elf32.em, and defines extra cr16-elf
23214571Sdim# specific routines.
24214571Sdim#
25214571Sdimcat >>e${EMULATION_NAME}.c <<EOF
26214571Sdim
27214571Sdim#include "ldctor.h"
28214571Sdim
29214571Sdim/* Flag for the emulation-specific "--no-relax" option.  */
30214571Sdimstatic bfd_boolean disable_relaxation = FALSE;
31214571Sdim
32214571Sdimstatic void
33214571Sdimcr16elf_after_parse (void)
34214571Sdim{
35214571Sdim  /* Always behave as if called with --sort-common command line
36214571Sdim     option.
37214571Sdim     This is to emulate the CRTools' method of keeping variables
38214571Sdim     of different alignment in separate sections.  */
39214571Sdim  config.sort_common = TRUE;
40214571Sdim
41214571Sdim  /* Don't create a demand-paged executable, since this feature isn't
42214571Sdim     meaninful in CR16 embedded systems. Moreover, when magic_demand_paged
43214571Sdim     is true the link sometimes fails.  */
44214571Sdim  config.magic_demand_paged = FALSE;
45214571Sdim}
46214571Sdim
47214571Sdim/* This is called after the sections have been attached to output
48214571Sdim   sections, but before any sizes or addresses have been set.  */
49214571Sdim
50214571Sdimstatic void
51214571Sdimcr16elf_before_allocation (void)
52214571Sdim{
53214571Sdim  /* Call the default first.  */
54214571Sdim  gld${EMULATION_NAME}_before_allocation ();
55214571Sdim
56214571Sdim  /* Enable relaxation by default if the "--no-relax" option was not
57214571Sdim     specified.  This is done here instead of in the before_parse hook
58214571Sdim     because there is a check in main() to prohibit use of --relax and
59214571Sdim     -r together.  */
60214571Sdim
61214571Sdim  if (!disable_relaxation)
62214571Sdim    command_line.relax = TRUE;
63214571Sdim}
64214571Sdim
65214571SdimEOF
66214571Sdim
67214571Sdim# Define some shell vars to insert bits of code into the standard elf
68214571Sdim# parse_args and list_options functions.
69214571Sdim#
70214571SdimPARSE_AND_LIST_PROLOGUE='
71214571Sdim#define OPTION_NO_RELAX			301
72214571Sdim'
73214571Sdim
74214571SdimPARSE_AND_LIST_LONGOPTS='
75214571Sdim  { "no-relax", no_argument, NULL, OPTION_NO_RELAX},
76214571Sdim'
77214571Sdim
78214571SdimPARSE_AND_LIST_OPTIONS='
79214571Sdim  fprintf (file, _("  --no-relax                  Do not relax branches\n"));
80214571Sdim'
81214571Sdim
82214571SdimPARSE_AND_LIST_ARGS_CASES='
83214571Sdim    case OPTION_NO_RELAX:
84214571Sdim      disable_relaxation = TRUE;
85214571Sdim      break;
86214571Sdim'
87214571Sdim
88214571Sdim# Put these extra cr16-elf routines in ld_${EMULATION_NAME}_emulation
89214571Sdim#
90214571SdimLDEMUL_AFTER_PARSE=cr16elf_after_parse
91214571SdimLDEMUL_BEFORE_ALLOCATION=cr16elf_before_allocation
92214571Sdim
93