* elf.c (bfd_section_from_shdr): Remove extraneous breaks.
[binutils.git] / ld / emultempl / generic.em
blob985cdf8e24f4ac19903c17fad77ee2d1f16d9d91
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<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 1991, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2004
8    Free Software Foundation, Inc.
9    Written by Steve Chamberlain steve@cygnus.com
11 This file is part of GLD, the Gnu Linker.
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
27 #define TARGET_IS_${EMULATION_NAME}
29 #include "bfd.h"
30 #include "sysdep.h"
31 #include "bfdlink.h"
33 #include "ld.h"
34 #include "ldmain.h"
35 #include "ldmisc.h"
37 #include "ldexp.h"
38 #include "ldlang.h"
39 #include "ldfile.h"
40 #include "ldemul.h"
42 EOF
44 # Import any needed special functions and/or overrides.
46 if test -n "$EXTRA_EM_FILE" ; then
47 . ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
50 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
51 cat >>e${EMULATION_NAME}.c <<EOF
53 static void
54 gld${EMULATION_NAME}_before_parse (void)
56 #ifndef TARGET_                 /* I.e., if not generic.  */
57   ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
58 #endif /* not TARGET_ */
61 EOF
64 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
65 cat >>e${EMULATION_NAME}.c <<EOF
67 static char *
68 gld${EMULATION_NAME}_get_script (int *isfile)
69 EOF
71 if test -n "$COMPILE_IN"
72 then
73 # Scripts compiled in.
75 # sed commands to quote an ld script as a C string.
76 sc="-f stringify.sed"
78 cat >>e${EMULATION_NAME}.c <<EOF
80   *isfile = 0;
82   if (link_info.relocatable && config.build_constructors)
83     return
84 EOF
85 sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
86 echo '  ; else if (link_info.relocatable) return'     >> e${EMULATION_NAME}.c
87 sed $sc ldscripts/${EMULATION_NAME}.xr                 >> e${EMULATION_NAME}.c
88 echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
89 sed $sc ldscripts/${EMULATION_NAME}.xbn                >> e${EMULATION_NAME}.c
90 echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
91 sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
92 echo '  ; else return'                                 >> e${EMULATION_NAME}.c
93 sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
94 echo '; }'                                             >> e${EMULATION_NAME}.c
96 else
97 # Scripts read from the filesystem.
99 cat >>e${EMULATION_NAME}.c <<EOF
101   *isfile = 1;
103   if (link_info.relocatable && config.build_constructors)
104     return "ldscripts/${EMULATION_NAME}.xu";
105   else if (link_info.relocatable)
106     return "ldscripts/${EMULATION_NAME}.xr";
107   else if (!config.text_read_only)
108     return "ldscripts/${EMULATION_NAME}.xbn";
109   else if (!config.magic_demand_paged)
110     return "ldscripts/${EMULATION_NAME}.xn";
111   else
112     return "ldscripts/${EMULATION_NAME}.x";
118 cat >>e${EMULATION_NAME}.c <<EOF
120 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
122   ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
123   ${LDEMUL_SYSLIB-syslib_default},
124   ${LDEMUL_HLL-hll_default},
125   ${LDEMUL_AFTER_PARSE-after_parse_default},
126   ${LDEMUL_AFTER_OPEN-after_open_default},
127   ${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
128   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
129   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
130   ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default},
131   ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
132   "${EMULATION_NAME}",
133   "${OUTPUT_FORMAT}",
134   ${LDEMUL_FINISH-finish_default},
135   ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
136   ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL},
137   ${LDEMUL_PLACE_ORPHAN-NULL},
138   ${LDEMUL_SET_SYMBOLS-NULL},
139   ${LDEMUL_PARSE_ARGS-NULL},
140   NULL, /* add_options */
141   NULL, /* handle_option */
142   ${LDEMUL_UNRECOGNIZED_FILE-NULL},
143   ${LDEMUL_LIST_OPTIONS-NULL},
144   ${LDEMUL_RECOGNIZED_FILE-NULL},
145   ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
146   ${LDEMUL_NEW_VERS_PATTERN-NULL}