]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # This shell script emits a C file. -*- C -*- |
2 | # It does some substitutions. | |
92b93329 | 3 | fragment <<EOF |
252b5132 RH |
4 | /* This file is is generated by a shell script. DO NOT EDIT! */ |
5 | ||
6 | /* emulate the original gld for the given ${EMULATION_NAME} | |
82704155 | 7 | Copyright (C) 1991-2019 Free Software Foundation, Inc. |
252b5132 RH |
8 | Written by Steve Chamberlain [email protected] |
9 | ||
f96b4a7b NC |
10 | This file is part of the GNU Binutils. |
11 | ||
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. | |
16 | ||
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. | |
21 | ||
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. */ | |
252b5132 RH |
26 | |
27 | #define TARGET_IS_${EMULATION_NAME} | |
28 | ||
252b5132 | 29 | #include "sysdep.h" |
3db64b00 | 30 | #include "bfd.h" |
252b5132 | 31 | #include "bfdlink.h" |
1ff6de03 | 32 | #include "ctf-api.h" |
252b5132 RH |
33 | |
34 | #include "ld.h" | |
35 | #include "ldmain.h" | |
252b5132 RH |
36 | #include "ldmisc.h" |
37 | ||
b71e2778 AM |
38 | #include "ldexp.h" |
39 | #include "ldlang.h" | |
40 | #include "ldfile.h" | |
41 | #include "ldemul.h" | |
42 | ||
55ab6103 HPN |
43 | EOF |
44 | ||
45 | # Import any needed special functions and/or overrides. | |
46 | # | |
47 | if test -n "$EXTRA_EM_FILE" ; then | |
92b93329 | 48 | source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em |
55ab6103 HPN |
49 | fi |
50 | ||
51 | if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then | |
92b93329 | 52 | fragment <<EOF |
55ab6103 | 53 | |
252b5132 | 54 | static void |
0c7a8e5a | 55 | gld${EMULATION_NAME}_before_parse (void) |
252b5132 RH |
56 | { |
57 | #ifndef TARGET_ /* I.e., if not generic. */ | |
5e2f1575 | 58 | ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); |
252b5132 | 59 | #endif /* not TARGET_ */ |
13761a11 NC |
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 | |
0e1862bb | 66 | if (!bfd_link_relocatable (&link_info)) |
13761a11 NC |
67 | TARGET_ENABLE_RELAXATION; |
68 | EOF | |
69 | ;; | |
70 | esac | |
71 | fragment <<EOF | |
252b5132 RH |
72 | } |
73 | ||
55ab6103 HPN |
74 | EOF |
75 | fi | |
76 | ||
77 | if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then | |
92b93329 | 78 | fragment <<EOF |
55ab6103 | 79 | |
252b5132 | 80 | static char * |
0c7a8e5a | 81 | gld${EMULATION_NAME}_get_script (int *isfile) |
252b5132 RH |
82 | EOF |
83 | ||
7225345d | 84 | if test x"$COMPILE_IN" = xyes |
252b5132 RH |
85 | then |
86 | # Scripts compiled in. | |
87 | ||
88 | # sed commands to quote an ld script as a C string. | |
597e2591 | 89 | sc="-f stringify.sed" |
252b5132 | 90 | |
92b93329 | 91 | fragment <<EOF |
0c7a8e5a | 92 | { |
252b5132 RH |
93 | *isfile = 0; |
94 | ||
0e1862bb | 95 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
252b5132 RH |
96 | return |
97 | EOF | |
b34976b6 | 98 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
0e1862bb | 99 | echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c |
b34976b6 AM |
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 | |
252b5132 RH |
108 | |
109 | else | |
110 | # Scripts read from the filesystem. | |
111 | ||
92b93329 | 112 | fragment <<EOF |
0c7a8e5a | 113 | { |
252b5132 RH |
114 | *isfile = 1; |
115 | ||
0e1862bb | 116 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
252b5132 | 117 | return "ldscripts/${EMULATION_NAME}.xu"; |
0e1862bb | 118 | else if (bfd_link_relocatable (&link_info)) |
252b5132 RH |
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"; | |
126 | } | |
127 | EOF | |
55ab6103 | 128 | fi |
252b5132 RH |
129 | fi |
130 | ||
92b93329 | 131 | fragment <<EOF |
252b5132 | 132 | |
0c7a8e5a | 133 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = |
252b5132 | 134 | { |
55ab6103 HPN |
135 | ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse}, |
136 | ${LDEMUL_SYSLIB-syslib_default}, | |
137 | ${LDEMUL_HLL-hll_default}, | |
138 | ${LDEMUL_AFTER_PARSE-after_parse_default}, | |
139 | ${LDEMUL_AFTER_OPEN-after_open_default}, | |
5c3261b0 | 140 | ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default}, |
55ab6103 HPN |
141 | ${LDEMUL_AFTER_ALLOCATION-after_allocation_default}, |
142 | ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default}, | |
143 | ${LDEMUL_CHOOSE_TARGET-ldemul_default_target}, | |
144 | ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default}, | |
145 | ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script}, | |
252b5132 | 146 | "${EMULATION_NAME}", |
e1c47aa4 | 147 | "${OUTPUT_FORMAT}", |
1e035701 | 148 | ${LDEMUL_FINISH-finish_default}, |
55ab6103 HPN |
149 | ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL}, |
150 | ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL}, | |
151 | ${LDEMUL_PLACE_ORPHAN-NULL}, | |
152 | ${LDEMUL_SET_SYMBOLS-NULL}, | |
153 | ${LDEMUL_PARSE_ARGS-NULL}, | |
45cfb56c TG |
154 | ${LDEMUL_ADD_OPTIONS-NULL}, |
155 | ${LDEMUL_HANDLE_OPTION-NULL}, | |
55ab6103 HPN |
156 | ${LDEMUL_UNRECOGNIZED_FILE-NULL}, |
157 | ${LDEMUL_LIST_OPTIONS-NULL}, | |
158 | ${LDEMUL_RECOGNIZED_FILE-NULL}, | |
fac1652d | 159 | ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, |
b26dbe27 | 160 | ${LDEMUL_NEW_VERS_PATTERN-NULL}, |
1ff6de03 NA |
161 | ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}, |
162 | ${LDEMUL_EMIT_CTF_EARLY-NULL}, | |
163 | ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL} | |
252b5132 RH |
164 | }; |
165 | EOF |