Update year range in copyright notice of binutils files
[binutils-gdb.git] / ld / emultempl / generic.em
blobccb2d50c5c4cf1a304b096b28e18b62790c52bef
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 fragment <<EOF
4 /* This file is is generated by a shell script.  DO NOT EDIT! */
6 /* emulate the original gld for the given ${EMULATION_NAME}
7    Copyright (C) 1991-2024 Free Software Foundation, Inc.
8    Written by Steve Chamberlain steve@cygnus.com
10    This file is part of the GNU Binutils.
12    This program is free software; you can redistribute it and/or modify
13    it under the terms of the GNU General Public License as published by
14    the Free Software Foundation; either version 3 of the License, or
15    (at your option) any later version.
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
25    MA 02110-1301, USA.  */
27 #define TARGET_IS_${EMULATION_NAME}
29 #include "sysdep.h"
30 #include "bfd.h"
31 #include "bfdlink.h"
32 #include "ctf-api.h"
34 #include "ld.h"
35 #include "ldmain.h"
36 #include "ldmisc.h"
38 #include "ldexp.h"
39 #include "ldlang.h"
40 #include "ldfile.h"
41 #include "ldemul.h"
43 EOF
45 # Import any needed special functions and/or overrides.
47 if test -n "$EXTRA_EM_FILE" ; then
48   source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
51 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
52 fragment <<EOF
54 static void
55 gld${EMULATION_NAME}_before_parse (void)
57 #ifndef TARGET_                 /* I.e., if not generic.  */
58   ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
59 #endif /* not TARGET_ */
60 EOF
61   # The MSP430 port *needs* linker relaxtion in order to cope with large
62   # functions where conditional branches do not fit into a +/- 1024 byte range.
63   case ${target} in
64     msp430-*-* )
65 fragment <<EOF
66   if (!bfd_link_relocatable (&link_info))
67     TARGET_ENABLE_RELAXATION;
68 EOF
69     ;;
70   esac
71 fragment <<EOF
74 EOF
77 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
78 fragment <<EOF
80 static char *
81 gld${EMULATION_NAME}_get_script (int *isfile)
82 EOF
84 if test x"$COMPILE_IN" = xyes
85 then
86 # Scripts compiled in.
88 # sed commands to quote an ld script as a C string.
89 sc="-f ${srcdir}/emultempl/stringify.sed"
91 fragment <<EOF
93   *isfile = 0;
95   if (bfd_link_relocatable (&link_info) && config.build_constructors)
96     return
97 EOF
98 sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
99 echo '  ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
100 sed $sc ldscripts/${EMULATION_NAME}.xr                 >> e${EMULATION_NAME}.c
101 echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
102 sed $sc ldscripts/${EMULATION_NAME}.xbn                >> e${EMULATION_NAME}.c
103 echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
104 sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
105 echo '  ; else return'                                 >> e${EMULATION_NAME}.c
106 sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
107 echo '; }'                                             >> e${EMULATION_NAME}.c
109 else
110 # Scripts read from the filesystem.
112 fragment <<EOF
114   *isfile = 1;
116   if (bfd_link_relocatable (&link_info) && config.build_constructors)
117     return "ldscripts/${EMULATION_NAME}.xu";
118   else if (bfd_link_relocatable (&link_info))
119     return "ldscripts/${EMULATION_NAME}.xr";
120   else if (!config.text_read_only)
121     return "ldscripts/${EMULATION_NAME}.xbn";
122   else if (!config.magic_demand_paged)
123     return "ldscripts/${EMULATION_NAME}.xn";
124   else
125     return "ldscripts/${EMULATION_NAME}.x";
131 source_em ${srcdir}/emultempl/emulation.em