* emultempl/elf32.em (global_stat): New file static variable.
[deliverable/binutils-gdb.git] / ld / emultempl / elf32.em
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 /* 32 bit ELF emulation code for ${EMULATION_NAME}
7 Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc.
8 Written by Steve Chamberlain <sac@cygnus.com>
9 ELF support by Ian Lance Taylor <ian@cygnus.com>
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., 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
32 #include <ctype.h>
33
34 #include "bfdlink.h"
35
36 #include "ld.h"
37 #include "ldmain.h"
38 #include "ldemul.h"
39 #include "ldfile.h"
40 #include "ldmisc.h"
41 #include "ldexp.h"
42 #include "ldlang.h"
43 #include "ldgram.h"
44
45 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
46 static boolean gld${EMULATION_NAME}_open_dynamic_archive
47 PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *));
48 static void gld${EMULATION_NAME}_after_open PARAMS ((void));
49 static void gld${EMULATION_NAME}_check_needed
50 PARAMS ((lang_input_statement_type *));
51 static void gld${EMULATION_NAME}_stat_needed
52 PARAMS ((lang_input_statement_type *));
53 static boolean gld${EMULATION_NAME}_search_needed
54 PARAMS ((const char *, const char *));
55 static boolean gld${EMULATION_NAME}_try_needed PARAMS ((const char *));
56 static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
57 static void gld${EMULATION_NAME}_find_statement_assignment
58 PARAMS ((lang_statement_union_type *));
59 static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
60 static boolean gld${EMULATION_NAME}_place_orphan
61 PARAMS ((lang_input_statement_type *, asection *));
62 static void gld${EMULATION_NAME}_place_section
63 PARAMS ((lang_statement_union_type *));
64 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
65
66 static void
67 gld${EMULATION_NAME}_before_parse()
68 {
69 ldfile_output_architecture = bfd_arch_${ARCH};
70 config.dynamic_link = ${DYNAMIC_LINK-true};
71 }
72
73 /* Try to open a dynamic archive. This is where we know that ELF
74 dynamic libraries have an extension of .so. */
75
76 static boolean
77 gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
78 const char *arch;
79 search_dirs_type *search;
80 lang_input_statement_type *entry;
81 {
82 const char *filename;
83 char *string;
84
85 if (! entry->is_archive)
86 return false;
87
88 filename = entry->filename;
89
90 string = (char *) xmalloc (strlen (search->name)
91 + strlen (filename)
92 + strlen (arch)
93 + sizeof "/lib.so");
94
95 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
96
97 if (! ldfile_try_open_bfd (string, entry))
98 {
99 free (string);
100 return false;
101 }
102
103 entry->filename = string;
104
105 /* We have found a dynamic object to include in the link. The ELF
106 backend linker will create a DT_NEEDED entry in the .dynamic
107 section naming this file. If this file includes a DT_SONAME
108 entry, it will be used. Otherwise, the ELF linker will just use
109 the name of the file. For an archive found by searching, like
110 this one, the DT_NEEDED entry should consist of just the name of
111 the file, without the path information used to find it. Note
112 that we only need to do this if we have a dynamic object; an
113 archive will never be referenced by a DT_NEEDED entry.
114
115 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
116 very pretty. I haven't been able to think of anything that is
117 pretty, though. */
118 if (bfd_check_format (entry->the_bfd, bfd_object)
119 && (entry->the_bfd->flags & DYNAMIC) != 0)
120 {
121 char *needed_name;
122
123 ASSERT (entry->is_archive && entry->search_dirs_flag);
124 needed_name = (char *) xmalloc (strlen (filename)
125 + strlen (arch)
126 + sizeof "lib.so");
127 sprintf (needed_name, "lib%s%s.so", filename, arch);
128 bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
129 }
130
131 return true;
132 }
133
134 /* These variables are required to pass information back and forth
135 between after_open and check_needed and stat_needed. */
136
137 static struct bfd_elf_link_needed_list *global_needed;
138 static struct stat global_stat;
139 static boolean global_found;
140
141 /* This is called after all the input files have been opened. */
142
143 static void
144 gld${EMULATION_NAME}_after_open ()
145 {
146 struct bfd_elf_link_needed_list *needed, *l;
147
148 /* Get the list of files which appear in DT_NEEDED entries in
149 dynamic objects included in the link (often there will be none).
150 For each such file, we want to track down the corresponding
151 library, and include the symbol table in the link. This is what
152 the runtime dynamic linker will do. Tracking the files down here
153 permits one dynamic object to include another without requiring
154 special action by the person doing the link. Note that the
155 needed list can actually grow while we are stepping through this
156 loop. */
157 needed = bfd_elf_get_needed_list (output_bfd, &link_info);
158 for (l = needed; l != NULL; l = l->next)
159 {
160 struct bfd_elf_link_needed_list *ll;
161 const char *lib_path;
162 size_t len;
163 search_dirs_type *search;
164
165 /* If we've already seen this file, skip it. */
166 for (ll = needed; ll != l; ll = ll->next)
167 if (strcmp (ll->name, l->name) == 0)
168 break;
169 if (ll != l)
170 continue;
171
172 /* See if this file was included in the link explicitly. */
173 global_needed = l;
174 global_found = false;
175 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
176 if (global_found)
177 continue;
178
179 /* We need to find this file and include the symbol table. We
180 want to search for the file in the same way that the dynamic
181 linker will search. That means that we want to use rpath,
182 then the environment variable LD_LIBRARY_PATH, then the
183 linker script LIB_SEARCH_DIRS. We do not search using the -L
184 arguments. */
185 if (gld${EMULATION_NAME}_search_needed (command_line.rpath, l->name))
186 continue;
187 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
188 if (gld${EMULATION_NAME}_search_needed (lib_path, l->name))
189 continue;
190 len = strlen (l->name);
191 for (search = search_head; search != NULL; search = search->next)
192 {
193 char *filename;
194
195 if (search->cmdline)
196 continue;
197 filename = (char *) xmalloc (strlen (search->name) + len + 2);
198 sprintf (filename, "%s/%s", search->name, l->name);
199 if (gld${EMULATION_NAME}_try_needed (filename))
200 break;
201 free (filename);
202 }
203 if (search != NULL)
204 continue;
205
206 einfo ("%P: warning: %s, needed by %B, not found\n",
207 l->name, l->by);
208 }
209 }
210
211 /* Search for a needed file in a path. */
212
213 static boolean
214 gld${EMULATION_NAME}_search_needed (path, name)
215 const char *path;
216 const char *name;
217 {
218 const char *s;
219 size_t len;
220
221 if (path == NULL || *path == '\0')
222 return false;
223 len = strlen (name);
224 while (1)
225 {
226 char *filename, *sset;
227
228 s = strchr (path, ':');
229 if (s == NULL)
230 s = path + strlen (path);
231
232 filename = (char *) xmalloc (s - path + len + 2);
233 if (s == path)
234 sset = filename;
235 else
236 {
237 memcpy (filename, path, s - path);
238 filename[s - path] = '/';
239 sset = filename + (s - path) + 1;
240 }
241 strcpy (sset, name);
242
243 if (gld${EMULATION_NAME}_try_needed (filename))
244 return true;
245
246 free (filename);
247
248 if (*s == '\0')
249 break;
250 path = s + 1;
251 }
252
253 return false;
254 }
255
256 /* This function is called for each possible name for a dynamic object
257 named by a DT_NEEDED entry. */
258
259 static boolean
260 gld${EMULATION_NAME}_try_needed (name)
261 const char *name;
262 {
263 bfd *abfd;
264
265 abfd = bfd_openr (name, bfd_get_target (output_bfd));
266 if (abfd == NULL)
267 return false;
268 if (! bfd_check_format (abfd, bfd_object))
269 {
270 (void) bfd_close (abfd);
271 return false;
272 }
273 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
274 {
275 (void) bfd_close (abfd);
276 return false;
277 }
278
279 /* We've found a dynamic object matching the DT_NEEDED entry. */
280
281 /* We have already checked that there is no other input file of the
282 same name. We must now check again that we are not including the
283 same file twice. We need to do this because on many systems
284 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
285 reference libc.so.1. If we have already included libc.so, we
286 don't want to include libc.so.1 if they are the same file, and we
287 can only check that using stat. */
288
289 if (bfd_stat (abfd, &global_stat) != 0)
290 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
291 global_found = false;
292 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
293 if (global_found)
294 {
295 /* Return true to indicate that we found the file, even though
296 we aren't going to do anything with it. */
297 return true;
298 }
299
300 /* Tell the ELF backend that don't want the output file to have a
301 DT_NEEDED entry for this file. */
302 bfd_elf_set_dt_needed_name (abfd, "");
303
304 /* Add this file into the symbol table. */
305 if (! bfd_link_add_symbols (abfd, &link_info))
306 einfo ("%F%B: could not read symbols: %E\n", abfd);
307
308 return true;
309 }
310
311 /* See if an input file matches a DT_NEEDED entry by name. */
312
313 static void
314 gld${EMULATION_NAME}_check_needed (s)
315 lang_input_statement_type *s;
316 {
317 if (s->filename != NULL
318 && strcmp (s->filename, global_needed->name) == 0)
319 global_found = true;
320 else if (s->search_dirs_flag
321 && s->filename != NULL
322 && strchr (global_needed->name, '/') == NULL)
323 {
324 const char *f;
325
326 f = strrchr (s->filename, '/');
327 if (f != NULL
328 && strcmp (f + 1, global_needed->name) == 0)
329 global_found = true;
330 }
331 }
332
333 /* See if an input file matches a DT_NEEDED entry by running stat on
334 the file. */
335
336 static void
337 gld${EMULATION_NAME}_stat_needed (s)
338 lang_input_statement_type *s;
339 {
340 if (global_found)
341 return;
342 if (s->the_bfd != NULL)
343 {
344 struct stat st;
345
346 if (bfd_stat (s->the_bfd, &st) != 0)
347 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
348 else
349 {
350 if (st.st_dev == global_stat.st_dev
351 && st.st_ino == global_stat.st_ino)
352 global_found = true;
353 }
354 }
355 }
356
357 /* This is called after the sections have been attached to output
358 sections, but before any sizes or addresses have been set. */
359
360 static void
361 gld${EMULATION_NAME}_before_allocation ()
362 {
363 asection *sinterp;
364
365 /* If we are going to make any variable assignments, we need to let
366 the ELF backend know about them in case the variables are
367 referred to by dynamic objects. */
368 lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
369
370 /* Let the ELF backend work out the sizes of any sections required
371 by dynamic linking. */
372 if (! bfd_elf32_size_dynamic_sections (output_bfd,
373 command_line.soname,
374 command_line.rpath,
375 command_line.export_dynamic,
376 &link_info,
377 &sinterp))
378 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
379
380 /* Let the user override the dynamic linker we are using. */
381 if (command_line.interpreter != NULL
382 && sinterp != NULL)
383 {
384 sinterp->contents = (bfd_byte *) command_line.interpreter;
385 sinterp->_raw_size = strlen (command_line.interpreter) + 1;
386 }
387
388 /* Look for any sections named .gnu.warning. As a GNU extensions,
389 we treat such sections as containing warning messages. We print
390 out the warning message, and then zero out the section size so
391 that it does not get copied into the output file. */
392
393 {
394 LANG_FOR_EACH_INPUT_STATEMENT (is)
395 {
396 asection *s;
397 bfd_size_type sz;
398 char *msg;
399 boolean ret;
400
401 if (is->just_syms_flag)
402 continue;
403
404 s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
405 if (s == NULL)
406 continue;
407
408 sz = bfd_section_size (is->the_bfd, s);
409 msg = xmalloc ((size_t) sz + 1);
410 if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz))
411 einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
412 is->the_bfd);
413 msg[sz] = '\0';
414 ret = link_info.callbacks->warning (&link_info, msg,
415 (const char *) NULL,
416 is->the_bfd, (asection *) NULL,
417 (bfd_vma) 0);
418 ASSERT (ret);
419 free (msg);
420
421 /* Clobber the section size, so that we don't waste copying the
422 warning into the output file. */
423 s->_raw_size = 0;
424 }
425 }
426
427 #if defined (TARGET_IS_elf32bmip) || defined (TARGET_IS_elf32lmip)
428 /* For MIPS ELF the .reginfo section requires special handling.
429 Each input section is 24 bytes, and the final output section must
430 also be 24 bytes. We handle this by clobbering all but the first
431 input section size to 0. The .reginfo section is handled
432 specially by the backend code anyhow. */
433 {
434 boolean found = false;
435 LANG_FOR_EACH_INPUT_STATEMENT (is)
436 {
437 asection *s;
438
439 if (is->just_syms_flag)
440 continue;
441
442 s = bfd_get_section_by_name (is->the_bfd, ".reginfo");
443 if (s == NULL)
444 continue;
445
446 if (! found)
447 {
448 found = true;
449 continue;
450 }
451
452 s->_raw_size = 0;
453 s->_cooked_size = 0;
454 }
455 }
456 #endif
457 }
458
459 /* This is called by the before_allocation routine via
460 lang_for_each_statement. It locates any assignment statements, and
461 tells the ELF backend about them, in case they are assignments to
462 symbols which are referred to by dynamic objects. */
463
464 static void
465 gld${EMULATION_NAME}_find_statement_assignment (s)
466 lang_statement_union_type *s;
467 {
468 if (s->header.type == lang_assignment_statement_enum)
469 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
470 }
471
472 /* Look through an expression for an assignment statement. */
473
474 static void
475 gld${EMULATION_NAME}_find_exp_assignment (exp)
476 etree_type *exp;
477 {
478 struct bfd_link_hash_entry *h;
479
480 switch (exp->type.node_class)
481 {
482 case etree_provide:
483 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
484 false, false, false);
485 if (h == NULL)
486 break;
487
488 /* We call record_link_assignment even if the symbol is defined.
489 This is because if it is defined by a dynamic object, we
490 actually want to use the value defined by the linker script,
491 not the value from the dynamic object (because we are setting
492 symbols like etext). If the symbol is defined by a regular
493 object, then, as it happens, calling record_link_assignment
494 will do no harm. */
495
496 /* Fall through. */
497 case etree_assign:
498 if (strcmp (exp->assign.dst, ".") != 0)
499 {
500 if (! (bfd_elf32_record_link_assignment
501 (output_bfd, &link_info, exp->assign.dst,
502 exp->type.node_class == etree_provide ? true : false)))
503 einfo ("%P%F: failed to record assignment to %s: %E\n",
504 exp->assign.dst);
505 }
506 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
507 break;
508
509 case etree_binary:
510 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
511 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
512 break;
513
514 case etree_trinary:
515 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
516 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
517 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
518 break;
519
520 case etree_unary:
521 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
522 break;
523
524 default:
525 break;
526 }
527 }
528
529 /* Place an orphan section. We use this to put random SHF_ALLOC
530 sections in the right segment. */
531
532 static asection *hold_section;
533 static lang_output_section_statement_type *hold_use;
534 static lang_output_section_statement_type *hold_text;
535 static lang_output_section_statement_type *hold_data;
536 static lang_output_section_statement_type *hold_bss;
537 static lang_output_section_statement_type *hold_rel;
538
539 /*ARGSUSED*/
540 static boolean
541 gld${EMULATION_NAME}_place_orphan (file, s)
542 lang_input_statement_type *file;
543 asection *s;
544 {
545 lang_output_section_statement_type *place;
546 asection *snew, **pps;
547 lang_statement_list_type *old;
548 lang_statement_list_type add;
549 etree_type *address;
550 const char *secname, *ps;
551 lang_output_section_statement_type *os;
552
553 if ((s->flags & SEC_ALLOC) == 0)
554 return false;
555
556 /* Look through the script to see where to place this section. */
557 hold_section = s;
558 hold_use = NULL;
559 lang_for_each_statement (gld${EMULATION_NAME}_place_section);
560
561 if (hold_use != NULL)
562 {
563 /* We have already placed a section with this name. */
564 wild_doit (&hold_use->children, s, hold_use, file);
565 return true;
566 }
567
568 secname = bfd_get_section_name (s->owner, s);
569
570 /* If this is a final link, then always put .gnu.warning.SYMBOL
571 sections into the .text section to get them out of the way. */
572 if (! link_info.shared
573 && ! link_info.relocateable
574 && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0
575 && hold_text != NULL)
576 {
577 wild_doit (&hold_text->children, s, hold_text, file);
578 return true;
579 }
580
581 /* Decide which segment the section should go in based on the
582 section name and section flags. */
583 place = NULL;
584 if ((s->flags & SEC_HAS_CONTENTS) == 0
585 && hold_bss != NULL)
586 place = hold_bss;
587 else if ((s->flags & SEC_READONLY) == 0
588 && hold_data != NULL)
589 place = hold_data;
590 else if (strncmp (secname, ".rel", 4) == 0
591 && hold_rel != NULL)
592 place = hold_rel;
593 else if ((s->flags & SEC_READONLY) != 0
594 && hold_text != NULL)
595 place = hold_text;
596 if (place == NULL)
597 return false;
598
599 /* Create the section in the output file, and put it in the right
600 place. This shuffling is to make the output file look neater. */
601 snew = bfd_make_section (output_bfd, secname);
602 if (snew == NULL)
603 einfo ("%P%F: output format %s cannot represent section called %s\n",
604 output_bfd->xvec->name, secname);
605 if (place->bfd_section != NULL)
606 {
607 for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next)
608 ;
609 *pps = snew->next;
610 snew->next = place->bfd_section->next;
611 place->bfd_section->next = snew;
612 }
613
614 /* Start building a list of statements for this section. */
615 old = stat_ptr;
616 stat_ptr = &add;
617 lang_list_init (stat_ptr);
618
619 /* If the name of the section is representable in C, then create
620 symbols to mark the start and the end of the section. */
621 for (ps = secname; *ps != '\0'; ps++)
622 if (! isalnum (*ps) && *ps != '_')
623 break;
624 if (*ps == '\0' && config.build_constructors)
625 {
626 char *symname;
627
628 symname = (char *) xmalloc (ps - secname + sizeof "__start_");
629 sprintf (symname, "__start_%s", secname);
630 lang_add_assignment (exp_assop ('=', symname,
631 exp_nameop (NAME, ".")));
632 }
633
634 if (! link_info.relocateable)
635 address = NULL;
636 else
637 address = exp_intop ((bfd_vma) 0);
638
639 lang_enter_output_section_statement (secname, address, 0,
640 (bfd_vma) 0,
641 (etree_type *) NULL,
642 (etree_type *) NULL,
643 (etree_type *) NULL);
644
645 os = lang_output_section_statement_lookup (secname);
646 wild_doit (&os->children, s, os, file);
647
648 lang_leave_output_section_statement ((bfd_vma) 0, "*default*");
649 stat_ptr = &add;
650
651 if (*ps == '\0' && config.build_constructors)
652 {
653 char *symname;
654
655 symname = (char *) xmalloc (ps - secname + sizeof "__stop_");
656 sprintf (symname, "__stop_%s", secname);
657 lang_add_assignment (exp_assop ('=', symname,
658 exp_nameop (NAME, ".")));
659 }
660
661 /* Now stick the new statement list right after PLACE. */
662 *add.tail = place->header.next;
663 place->header.next = add.head;
664
665 stat_ptr = old;
666
667 return true;
668 }
669
670 static void
671 gld${EMULATION_NAME}_place_section (s)
672 lang_statement_union_type *s;
673 {
674 lang_output_section_statement_type *os;
675
676 if (s->header.type != lang_output_section_statement_enum)
677 return;
678
679 os = &s->output_section_statement;
680
681 if (strcmp (os->name, hold_section->name) == 0)
682 hold_use = os;
683
684 if (strcmp (os->name, ".text") == 0)
685 hold_text = os;
686 else if (strcmp (os->name, ".data") == 0)
687 hold_data = os;
688 else if (strcmp (os->name, ".bss") == 0)
689 hold_bss = os;
690 else if (hold_rel == NULL
691 && strncmp (os->name, ".rel", 4) == 0)
692 hold_rel = os;
693 }
694
695 static char *
696 gld${EMULATION_NAME}_get_script(isfile)
697 int *isfile;
698 EOF
699
700 if test -n "$COMPILE_IN"
701 then
702 # Scripts compiled in.
703
704 # sed commands to quote an ld script as a C string.
705 sc='s/["\\]/\\&/g
706 s/$/\\n\\/
707 1s/^/"/
708 $s/$/n"/
709 '
710
711 cat >>e${EMULATION_NAME}.c <<EOF
712 {
713 *isfile = 0;
714
715 if (link_info.relocateable == true && config.build_constructors == true)
716 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
717 else if (link_info.relocateable == true)
718 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
719 else if (!config.text_read_only)
720 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
721 else if (!config.magic_demand_paged)
722 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
723 else if (link_info.shared)
724 return `sed "$sc" ldscripts/${EMULATION_NAME}.xs`;
725 else
726 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
727 }
728 EOF
729
730 else
731 # Scripts read from the filesystem.
732
733 cat >>e${EMULATION_NAME}.c <<EOF
734 {
735 *isfile = 1;
736
737 if (link_info.relocateable == true && config.build_constructors == true)
738 return "ldscripts/${EMULATION_NAME}.xu";
739 else if (link_info.relocateable == true)
740 return "ldscripts/${EMULATION_NAME}.xr";
741 else if (!config.text_read_only)
742 return "ldscripts/${EMULATION_NAME}.xbn";
743 else if (!config.magic_demand_paged)
744 return "ldscripts/${EMULATION_NAME}.xn";
745 else if (link_info.shared)
746 return "ldscripts/${EMULATION_NAME}.xs";
747 else
748 return "ldscripts/${EMULATION_NAME}.x";
749 }
750 EOF
751
752 fi
753
754 cat >>e${EMULATION_NAME}.c <<EOF
755
756 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
757 {
758 gld${EMULATION_NAME}_before_parse,
759 syslib_default,
760 hll_default,
761 after_parse_default,
762 gld${EMULATION_NAME}_after_open,
763 after_allocation_default,
764 set_output_arch_default,
765 ldemul_default_target,
766 gld${EMULATION_NAME}_before_allocation,
767 gld${EMULATION_NAME}_get_script,
768 "${EMULATION_NAME}",
769 "${OUTPUT_FORMAT}",
770 NULL,
771 NULL,
772 gld${EMULATION_NAME}_open_dynamic_archive,
773 gld${EMULATION_NAME}_place_orphan
774 };
775 EOF
This page took 0.116803 seconds and 5 git commands to generate.