]>
Commit | Line | Data |
---|---|---|
08f20f66 ILT |
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! */ | |
5 | ||
6 | /* Linux a.out emulation code for ${EMULATION_NAME} | |
7 | Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. | |
8 | Written by Steve Chamberlain <[email protected]> | |
9 | Linux support by Eric Youngdale <[email protected]> | |
10 | ||
11 | This file is part of GLD, the Gnu Linker. | |
12 | ||
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. | |
17 | ||
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. | |
22 | ||
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., 675 Mass Ave, Cambridge, MA 02139, 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 "config.h" | |
35 | #include "ldmain.h" | |
36 | #include "ldemul.h" | |
37 | #include "ldfile.h" | |
38 | #include "ldmisc.h" | |
39 | #include "ldexp.h" | |
40 | #include "ldlang.h" | |
41 | ||
42 | static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); | |
43 | static boolean gld${EMULATION_NAME}_open_dynamic_archive | |
44 | PARAMS ((const char *, lang_input_statement_type *)); | |
45 | static void gld${EMULATION_NAME}_before_allocation PARAMS ((void)); | |
46 | static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); | |
47 | ||
48 | static void | |
49 | gld${EMULATION_NAME}_before_parse() | |
50 | { | |
51 | ldfile_output_architecture = bfd_arch_${ARCH}; | |
52 | config.dynamic_link = true; | |
53 | } | |
54 | ||
55 | /* Try to open a dynamic archive. This is where we know that Linux | |
56 | dynamic libraries have an extension of .sa. */ | |
57 | ||
58 | static boolean | |
59 | gld${EMULATION_NAME}_open_dynamic_archive (arch, entry) | |
60 | const char *arch; | |
61 | lang_input_statement_type *entry; | |
62 | { | |
63 | return ldfile_open_file_search (arch, entry, "lib", ".sa"); | |
64 | } | |
65 | ||
66 | /* This is called after the sections have been attached to output | |
67 | sections, but before any sizes or addresses have been set. */ | |
68 | ||
69 | static void | |
70 | gld${EMULATION_NAME}_before_allocation () | |
71 | { | |
72 | if (link_info.relocateable) | |
73 | return; | |
74 | ||
75 | /* Let the backend work out the sizes of any sections required by | |
76 | dynamic linking. */ | |
77 | if (! bfd_linux_size_dynamic_sections (output_bfd, &link_info)) | |
78 | einfo ("%P%F: failed to set dynamic section sizes: %E\n"); | |
79 | } | |
80 | ||
81 | static char * | |
82 | gld${EMULATION_NAME}_get_script(isfile) | |
83 | int *isfile; | |
84 | EOF | |
85 | ||
86 | if test -n "$COMPILE_IN" | |
87 | then | |
88 | # Scripts compiled in. | |
89 | ||
90 | # sed commands to quote an ld script as a C string. | |
91 | sc='s/["\\]/\\&/g | |
92 | s/$/\\n\\/ | |
93 | 1s/^/"/ | |
94 | $s/$/n"/ | |
95 | ' | |
96 | ||
97 | cat >>e${EMULATION_NAME}.c <<EOF | |
98 | { | |
99 | *isfile = 0; | |
100 | ||
101 | if (link_info.relocateable == true && config.build_constructors == true) | |
102 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`; | |
103 | else if (link_info.relocateable == true) | |
104 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`; | |
105 | else if (!config.text_read_only) | |
106 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`; | |
107 | else if (!config.magic_demand_paged) | |
108 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`; | |
109 | else | |
110 | return `sed "$sc" ldscripts/${EMULATION_NAME}.x`; | |
111 | } | |
112 | EOF | |
113 | ||
114 | else | |
115 | # Scripts read from the filesystem. | |
116 | ||
117 | cat >>e${EMULATION_NAME}.c <<EOF | |
118 | { | |
119 | *isfile = 1; | |
120 | ||
121 | if (link_info.relocateable == true && config.build_constructors == true) | |
122 | return "ldscripts/${EMULATION_NAME}.xu"; | |
123 | else if (link_info.relocateable == true) | |
124 | return "ldscripts/${EMULATION_NAME}.xr"; | |
125 | else if (!config.text_read_only) | |
126 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
127 | else if (!config.magic_demand_paged) | |
128 | return "ldscripts/${EMULATION_NAME}.xn"; | |
129 | else | |
130 | return "ldscripts/${EMULATION_NAME}.x"; | |
131 | } | |
132 | EOF | |
133 | ||
134 | fi | |
135 | ||
136 | cat >>e${EMULATION_NAME}.c <<EOF | |
137 | ||
138 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = | |
139 | { | |
140 | gld${EMULATION_NAME}_before_parse, | |
141 | syslib_default, | |
142 | hll_default, | |
143 | after_parse_default, | |
144 | after_allocation_default, | |
145 | set_output_arch_default, | |
146 | ldemul_default_target, | |
147 | gld${EMULATION_NAME}_before_allocation, | |
148 | gld${EMULATION_NAME}_get_script, | |
149 | "${EMULATION_NAME}", | |
150 | "${OUTPUT_FORMAT}", | |
151 | NULL, | |
152 | NULL, | |
153 | gld${EMULATION_NAME}_open_dynamic_archive | |
154 | }; | |
155 | EOF |