]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/generic.em
Add new link-map-text hook and RX auto-vector support.
[thirdparty/binutils-gdb.git] / ld / emultempl / generic.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
92b93329 3fragment <<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}
4b95cf5c 7 Copyright (C) 1991-2014 Free Software Foundation, Inc.
252b5132
RH
8 Written by Steve Chamberlain steve@cygnus.com
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
RH
31#include "bfdlink.h"
32
33#include "ld.h"
34#include "ldmain.h"
252b5132
RH
35#include "ldmisc.h"
36
b71e2778
AM
37#include "ldexp.h"
38#include "ldlang.h"
39#include "ldfile.h"
40#include "ldemul.h"
41
55ab6103
HPN
42EOF
43
44# Import any needed special functions and/or overrides.
45#
46if test -n "$EXTRA_EM_FILE" ; then
92b93329 47 source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
55ab6103
HPN
48fi
49
50if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
92b93329 51fragment <<EOF
55ab6103 52
252b5132 53static void
0c7a8e5a 54gld${EMULATION_NAME}_before_parse (void)
252b5132
RH
55{
56#ifndef TARGET_ /* I.e., if not generic. */
5e2f1575 57 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
252b5132 58#endif /* not TARGET_ */
13761a11
NC
59EOF
60 # The MSP430 port *needs* linker relaxtion in order to cope with large
61 # functions where conditional branches do not fit into a +/- 1024 byte range.
62 case ${target} in
63 msp430-*-* )
64fragment <<EOF
65 if (! link_info.relocatable)
66 TARGET_ENABLE_RELAXATION;
67EOF
68 ;;
69 esac
70fragment <<EOF
252b5132
RH
71}
72
55ab6103
HPN
73EOF
74fi
75
76if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
92b93329 77fragment <<EOF
55ab6103 78
252b5132 79static char *
0c7a8e5a 80gld${EMULATION_NAME}_get_script (int *isfile)
252b5132
RH
81EOF
82
7225345d 83if test x"$COMPILE_IN" = xyes
252b5132
RH
84then
85# Scripts compiled in.
86
87# sed commands to quote an ld script as a C string.
597e2591 88sc="-f stringify.sed"
252b5132 89
92b93329 90fragment <<EOF
0c7a8e5a 91{
252b5132
RH
92 *isfile = 0;
93
1049f94e 94 if (link_info.relocatable && config.build_constructors)
252b5132
RH
95 return
96EOF
b34976b6 97sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1049f94e 98echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
b34976b6
AM
99sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
100echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
101sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
102echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
103sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
104echo ' ; else return' >> e${EMULATION_NAME}.c
105sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
106echo '; }' >> e${EMULATION_NAME}.c
252b5132
RH
107
108else
109# Scripts read from the filesystem.
110
92b93329 111fragment <<EOF
0c7a8e5a 112{
252b5132
RH
113 *isfile = 1;
114
1049f94e 115 if (link_info.relocatable && config.build_constructors)
252b5132 116 return "ldscripts/${EMULATION_NAME}.xu";
1049f94e 117 else if (link_info.relocatable)
252b5132
RH
118 return "ldscripts/${EMULATION_NAME}.xr";
119 else if (!config.text_read_only)
120 return "ldscripts/${EMULATION_NAME}.xbn";
121 else if (!config.magic_demand_paged)
122 return "ldscripts/${EMULATION_NAME}.xn";
123 else
124 return "ldscripts/${EMULATION_NAME}.x";
125}
126EOF
55ab6103 127fi
252b5132
RH
128fi
129
92b93329 130fragment <<EOF
252b5132 131
0c7a8e5a 132struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
252b5132 133{
55ab6103
HPN
134 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
135 ${LDEMUL_SYSLIB-syslib_default},
136 ${LDEMUL_HLL-hll_default},
137 ${LDEMUL_AFTER_PARSE-after_parse_default},
138 ${LDEMUL_AFTER_OPEN-after_open_default},
139 ${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
140 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
141 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
142 ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default},
143 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
252b5132 144 "${EMULATION_NAME}",
e1c47aa4 145 "${OUTPUT_FORMAT}",
1e035701 146 ${LDEMUL_FINISH-finish_default},
55ab6103
HPN
147 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
148 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL},
149 ${LDEMUL_PLACE_ORPHAN-NULL},
150 ${LDEMUL_SET_SYMBOLS-NULL},
151 ${LDEMUL_PARSE_ARGS-NULL},
45cfb56c
TG
152 ${LDEMUL_ADD_OPTIONS-NULL},
153 ${LDEMUL_HANDLE_OPTION-NULL},
55ab6103
HPN
154 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
155 ${LDEMUL_LIST_OPTIONS-NULL},
156 ${LDEMUL_RECOGNIZED_FILE-NULL},
fac1652d
AM
157 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
158 ${LDEMUL_NEW_VERS_PATTERN-NULL}
7a2f2d82 159 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}
252b5132
RH
160};
161EOF