Don't try to read past end of info buffer, and correct test results.
[deliverable/binutils-gdb.git] / ld / emultempl / generic.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
4/* This file is is generated by a shell script. DO NOT EDIT! */
5
6/* emulate the original gld for the given ${EMULATION_NAME}
a2b64bed 7 Copyright 1991, 1992, 1994, 1996, 2000
b71e2778 8 Free Software Foundation, Inc.
252b5132
RH
9 Written by Steve Chamberlain steve@cygnus.com
10
11This file is part of GLD, the Gnu Linker.
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 2 of the License, or
16(at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26
27#define TARGET_IS_${EMULATION_NAME}
28
29#include "bfd.h"
30#include "sysdep.h"
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
252b5132
RH
42static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
43static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
44
45static void
46gld${EMULATION_NAME}_before_parse()
47{
48#ifndef TARGET_ /* I.e., if not generic. */
49 ldfile_set_output_arch ("`echo ${ARCH}`");
50#endif /* not TARGET_ */
51}
52
53static char *
54gld${EMULATION_NAME}_get_script(isfile)
55 int *isfile;
56EOF
57
58if test -n "$COMPILE_IN"
59then
60# Scripts compiled in.
61
62# sed commands to quote an ld script as a C string.
597e2591 63sc="-f stringify.sed"
252b5132
RH
64
65cat >>e${EMULATION_NAME}.c <<EOF
66{
67 *isfile = 0;
68
69 if (link_info.relocateable == true && config.build_constructors == true)
70 return
71EOF
72sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
73echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
74sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
75echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
76sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
77echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
78sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
79echo ' ; else return' >> e${EMULATION_NAME}.c
80sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
81echo '; }' >> e${EMULATION_NAME}.c
82
83else
84# Scripts read from the filesystem.
85
86cat >>e${EMULATION_NAME}.c <<EOF
87{
88 *isfile = 1;
89
90 if (link_info.relocateable == true && config.build_constructors == true)
91 return "ldscripts/${EMULATION_NAME}.xu";
92 else if (link_info.relocateable == true)
93 return "ldscripts/${EMULATION_NAME}.xr";
94 else if (!config.text_read_only)
95 return "ldscripts/${EMULATION_NAME}.xbn";
96 else if (!config.magic_demand_paged)
97 return "ldscripts/${EMULATION_NAME}.xn";
98 else
99 return "ldscripts/${EMULATION_NAME}.x";
100}
101EOF
102
103fi
104
105cat >>e${EMULATION_NAME}.c <<EOF
106
107struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
108{
109 gld${EMULATION_NAME}_before_parse,
110 syslib_default,
111 hll_default,
112 after_parse_default,
113 after_open_default,
114 after_allocation_default,
115 set_output_arch_default,
116 ldemul_default_target,
117 before_allocation_default,
118 gld${EMULATION_NAME}_get_script,
119 "${EMULATION_NAME}",
e1c47aa4
AM
120 "${OUTPUT_FORMAT}",
121 NULL, /* finish */
122 NULL, /* create output section statements */
123 NULL, /* open dynamic archive */
124 NULL, /* place orphan */
125 NULL, /* set symbols */
126 NULL, /* parse args */
127 NULL, /* unrecognized file */
128 NULL, /* list options */
40d109bf
AM
129 NULL, /* recognized file */
130 NULL /* find_potential_libraries */
252b5132
RH
131};
132EOF
This page took 0.072209 seconds and 4 git commands to generate.