]> Git Repo - binutils.git/blob - ld/emultempl/generic.em
Add embedded PowerPC ELF support.
[binutils.git] / ld / emultempl / generic.em
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >em_${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}
7    Copyright (C) 1991 Free Software Foundation, Inc.
8    Written by Steve Chamberlain [email protected]
9
10 This file is part of GLD, the Gnu Linker.
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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
25
26 #define TARGET_IS_${EMULATION_NAME}
27
28 #include "bfd.h"
29 #include "sysdep.h"
30 #include "ld.h"
31 #include "config.h"
32 #include "ldemul.h"
33 #include "ldfile.h"
34 #include "ldmisc.h"
35
36 extern boolean lang_float_flag;
37
38 extern enum bfd_architecture ldfile_output_architecture;
39 extern unsigned long ldfile_output_machine;
40 extern char *ldfile_output_machine_name;
41
42 static void
43 gld${EMULATION_NAME}_before_parse()
44 {
45 #ifndef TARGET_                 /* I.e., if not generic.  */
46   ldfile_output_architecture = bfd_arch_${ARCH};
47 #endif /* not TARGET_ */
48 }
49
50 static char *
51 gld${EMULATION_NAME}_get_script(isfile)
52      int *isfile;
53 EOF
54
55 if test "$DEFAULT_EMULATION" = "$EMULATION_NAME"
56 then
57 # Scripts compiled in.
58
59 # sed commands to quote an ld script as a C string.
60 sc='s/["\\]/\\&/g
61 s/$/\\n\\/
62 1s/^/"{/
63 $s/$/n}"/
64 '
65
66 cat >>em_${EMULATION_NAME}.c <<EOF
67 {                            
68   extern ld_config_type config;
69
70   *isfile = 0;
71
72   if (config.relocateable_output == true && config.build_constructors == true)
73     return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
74   else if (config.relocateable_output == true)
75     return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
76   else if (!config.text_read_only)
77     return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
78   else if (!config.magic_demand_paged)
79     return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
80   else
81     return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
82 }
83 EOF
84
85 else
86 # Scripts read from the filesystem.
87
88 cat >>em_${EMULATION_NAME}.c <<EOF
89 {                            
90   extern ld_config_type config;
91
92   *isfile = 1;
93
94   if (config.relocateable_output == true && config.build_constructors == true)
95     return "ldscripts/${EMULATION_NAME}.xu";
96   else if (config.relocateable_output == true)
97     return "ldscripts/${EMULATION_NAME}.xr";
98   else if (!config.text_read_only)
99     return "ldscripts/${EMULATION_NAME}.xbn";
100   else if (!config.magic_demand_paged)
101     return "ldscripts/${EMULATION_NAME}.xn";
102   else
103     return "ldscripts/${EMULATION_NAME}.x";
104 }
105 EOF
106
107 fi
108
109 cat >>em_${EMULATION_NAME}.c <<EOF
110
111 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
112 {
113   gld${EMULATION_NAME}_before_parse,
114   syslib_default,
115   hll_default,
116   after_parse_default,
117   after_allocation_default,
118   set_output_arch_default,
119   ldemul_default_target,
120   before_allocation_default,
121   gld${EMULATION_NAME}_get_script,
122   "${EMULATION_NAME}",
123   "${OUTPUT_FORMAT}"
124 };
125 EOF
This page took 0.030361 seconds and 4 git commands to generate.