1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 if [ -z "$MACHINE" ]; then
6 OUTPUT_ARCH=${ARCH}:${MACHINE}
8 cat >e${EMULATION_NAME}.c <<EOF
9 /* This file is part of GLD, the Gnu Linker.
10 Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002
11 Free Software Foundation, Inc.
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.
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.
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. */
28 /* The original file generated returned different default scripts depending
29 on whether certain switches were set, but these switches pertain to the
30 Linux system and that particular version of coff. In the NT case, we
31 only determine if the subsystem is console or windows in order to select
32 the correct entry point by default. */
38 #include "libiberty.h"
49 #include "coff/internal.h"
50 #include "../bfd/libcoff.h"
52 #define TARGET_IS_${EMULATION_NAME}
54 static void gld_${EMULATION_NAME}_set_symbols PARAMS ((void));
55 static void gld_${EMULATION_NAME}_after_open PARAMS ((void));
56 static void gld_${EMULATION_NAME}_before_parse PARAMS ((void));
57 static void gld_${EMULATION_NAME}_before_allocation PARAMS ((void));
58 static boolean gld${EMULATION_NAME}_place_orphan
59 PARAMS ((lang_input_statement_type *, asection *));
60 static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
61 static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
63 static int sort_by_file_name PARAMS ((const PTR, const PTR));
64 static int sort_by_section_name PARAMS ((const PTR, const PTR));
65 static lang_statement_union_type **sort_sections_1
66 PARAMS ((lang_statement_union_type **, lang_statement_union_type *, int,
67 int (*) PARAMS((const PTR, const PTR))));
68 static void sort_sections PARAMS ((lang_statement_union_type *));
70 static void set_pe_name PARAMS ((char *, long int));
71 static void set_pe_subsystem PARAMS ((void));
72 static void set_pe_value PARAMS ((char *));
73 static void set_pe_stack_heap PARAMS ((char *, char *));
75 static struct internal_extra_pe_aouthdr pe;
78 extern const char *output_filename;
81 gld_${EMULATION_NAME}_before_parse()
83 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
86 ldfile_output_architecture = arch->arch;
87 ldfile_output_machine = arch->mach;
88 ldfile_output_machine_name = arch->printable_name;
91 ldfile_output_architecture = bfd_arch_${ARCH};
92 output_filename = "a.exe";
95 /* PE format extra command line options. */
97 /* Used for setting flags in the PE header. */
98 #define OPTION_BASE_FILE (300 + 1)
99 #define OPTION_DLL (OPTION_BASE_FILE + 1)
100 #define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1)
101 #define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1)
102 #define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1)
103 #define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1)
104 #define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1)
105 #define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
106 #define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1)
107 #define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1)
108 #define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
109 #define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1)
110 #define OPTION_SUBSYSTEM (OPTION_STACK + 1)
111 #define OPTION_HEAP (OPTION_SUBSYSTEM + 1)
113 static struct option longopts[] = {
115 {"base-file", required_argument, NULL, OPTION_BASE_FILE},
116 {"dll", no_argument, NULL, OPTION_DLL},
117 {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
118 {"heap", required_argument, NULL, OPTION_HEAP},
119 {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
120 {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
121 {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
122 {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
123 {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
124 {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
125 {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
126 {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
127 {"stack", required_argument, NULL, OPTION_STACK},
128 {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
129 {NULL, no_argument, NULL, 0}
133 /* PE/WIN32; added routines to get the subsystem type, heap and/or stack
134 parameters which may be input from the command line */
144 #define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0}
146 static definfo init[] =
148 /* imagebase must be first */
149 #define IMAGEBASEOFF 0
150 D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
152 {&dll, sizeof(dll), 0, "__dll__", 0},
153 D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
154 D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
155 D(MajorOperatingSystemVersion,"__major_os_version__", 4),
156 D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
157 D(MajorImageVersion,"__major_image_version__", 1),
158 D(MinorImageVersion,"__minor_image_version__", 0),
159 D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
160 D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
161 D(Subsystem,"__subsystem__", 3),
162 D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
163 D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
164 D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
165 D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
166 D(LoaderFlags,"__loader_flags__", 0x0),
167 { NULL, 0, 0, NULL, 0 }
172 set_pe_name (name, val)
177 /* Find the name and set it. */
178 for (i = 0; init[i].ptr; i++)
180 if (strcmp (name, init[i].symbol) == 0)
205 { "native", 1, "_NtProcessStartup" },
206 { "windows", 2, "_WinMainCRTStartup" },
207 { "wwindows", 2, "_wWinMainCRTStartup" },
208 { "console", 3, "_mainCRTStartup" },
209 { "wconsole", 3, "_wmainCRTStartup" },
211 /* The Microsoft linker does not recognize this. */
214 { "posix", 7, "___PosixProcessStartup"},
218 sver = strchr (optarg, ':');
220 len = strlen (optarg);
226 set_pe_name ("__major_subsystem_version__",
227 strtoul (sver + 1, &end, 0));
229 set_pe_name ("__minor_subsystem_version__",
230 strtoul (end + 1, &end, 0));
232 einfo ("%P: warning: bad version number in -subsystem option\n");
235 for (i = 0; v[i].name; i++)
237 if (strncmp (optarg, v[i].name, len) == 0
238 && v[i].name[len] == '\0')
240 set_pe_name ("__subsystem__", v[i].value);
242 /* If the subsystem is windows, we use a different entry
243 point. We also register the entry point as an undefined
244 symbol. from lang_add_entry() The reason we do
245 this is so that the user
246 doesn't have to because they would have to use the -u
247 switch if they were specifying an entry point other than
248 _mainCRTStartup. Specifically, if creating a windows
249 application, entry point _WinMainCRTStartup must be
250 specified. What I have found for non console
251 applications (entry not _mainCRTStartup) is that the .obj
252 that contains mainCRTStartup is brought in since it is
253 the first encountered in libc.lib and it has other
254 symbols in it which will be pulled in by the link
255 process. To avoid this, adding -u with the entry point
256 name specified forces the correct .obj to be used. We
257 can avoid making the user do this by always adding the
258 entry point name as an undefined symbol. */
259 lang_add_entry (v[i].entry, 1);
264 einfo ("%P%F: invalid subsystem type %s\n", optarg);
275 set_pe_name (name, strtoul (optarg, &end, 0));
278 einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
285 set_pe_stack_heap (resname, comname)
289 set_pe_value (resname);
293 set_pe_value (comname);
297 einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
304 gld_${EMULATION_NAME}_parse_args(argc, argv)
310 int prevoptind = optind;
311 int prevopterr = opterr;
313 static int lastoptind = -1;
315 if (lastoptind != optind)
321 optc = getopt_long_only (argc, argv, "-", longopts, &longind);
332 case OPTION_BASE_FILE:
333 link_info.base_file = (PTR) fopen (optarg, FOPEN_WB);
334 if (link_info.base_file == NULL)
336 fprintf (stderr, "%s: Can't open base file %s\n",
337 program_name, optarg);
344 set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
347 set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
349 case OPTION_SUBSYSTEM:
352 case OPTION_MAJOR_OS_VERSION:
353 set_pe_value ("__major_os_version__");
355 case OPTION_MINOR_OS_VERSION:
356 set_pe_value ("__minor_os_version__");
358 case OPTION_MAJOR_SUBSYSTEM_VERSION:
359 set_pe_value ("__major_subsystem_version__");
361 case OPTION_MINOR_SUBSYSTEM_VERSION:
362 set_pe_value ("__minor_subsystem_version__");
364 case OPTION_MAJOR_IMAGE_VERSION:
365 set_pe_value ("__major_image_version__");
367 case OPTION_MINOR_IMAGE_VERSION:
368 set_pe_value ("__minor_image_version__");
370 case OPTION_FILE_ALIGNMENT:
371 set_pe_value ("__file_alignment__");
373 case OPTION_SECTION_ALIGNMENT:
374 set_pe_value ("__section_alignment__");
377 set_pe_name ("__dll__", 1);
379 case OPTION_IMAGE_BASE:
380 set_pe_value ("__image_base__");
386 /* Assign values to the special symbols before the linker script is
390 gld_${EMULATION_NAME}_set_symbols()
392 /* Run through and invent symbols for all the
393 names and insert the defaults. */
395 lang_statement_list_type *save;
397 if (!init[IMAGEBASEOFF].inited)
399 if (link_info.relocateable)
400 init[IMAGEBASEOFF].value = 0;
401 else if (init[DLLOFF].value)
402 init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
404 init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
407 /* Don't do any symbol assignments if this is a relocateable link. */
408 if (link_info.relocateable)
411 /* Glue the assignments into the abs section */
414 stat_ptr = &(abs_output_section->children);
416 for (j = 0; init[j].ptr; j++)
418 long val = init[j].value;
419 lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
420 if (init[j].size == sizeof(short))
421 *(short *)init[j].ptr = val;
422 else if (init[j].size == sizeof(int))
423 *(int *)init[j].ptr = val;
424 else if (init[j].size == sizeof(long))
425 *(long *)init[j].ptr = val;
426 /* This might be a long long or other special type. */
427 else if (init[j].size == sizeof(bfd_vma))
428 *(bfd_vma *)init[j].ptr = val;
431 /* Restore the pointer. */
434 if (pe.FileAlignment >
437 einfo ("%P: warning, file alignment > section alignment.\n");
442 gld_${EMULATION_NAME}_after_open()
444 /* Pass the wacky PE command line options into the output bfd.
445 FIXME: This should be done via a function, rather than by
446 including an internal BFD header. */
447 if (!coff_data(output_bfd)->pe)
449 einfo ("%F%P: PE operations on non PE file.\n");
452 pe_data(output_bfd)->pe_opthdr = pe;
453 pe_data(output_bfd)->dll = init[DLLOFF].value;
457 /* Callback functions for qsort in sort_sections. */
460 sort_by_file_name (a, b)
464 const lang_statement_union_type *const *ra = a;
465 const lang_statement_union_type *const *rb = b;
468 i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename,
469 (*rb)->input_section.ifile->the_bfd->my_archive->filename);
473 i = strcmp ((*ra)->input_section.ifile->filename,
474 (*rb)->input_section.ifile->filename);
477 /* the tail idata4/5 are the only ones without relocs to an
478 idata$6 section unless we are importing by ordinal,
479 so sort them to last to terminate the IAT
480 and HNT properly. if no reloc this one is import by ordinal
481 so we have to sort by section contents */
483 if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
485 i = (((*ra)->input_section.section->reloc_count >
486 (*rb)->input_section.section->reloc_count) ? -1 : 0);
490 return (((*ra)->input_section.section->reloc_count >
491 (*rb)->input_section.section->reloc_count) ? 0 : 1);
495 if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
496 return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
498 if (! bfd_get_section_contents ((*ra)->input_section.ifile->the_bfd,
499 (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
500 einfo ("%F%B: Can't read contents of section .idata: %E\n",
501 (*ra)->input_section.ifile->the_bfd);
503 if (! bfd_get_section_contents ((*rb)->input_section.ifile->the_bfd,
504 (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
505 einfo ("%F%B: Can't read contents of section .idata: %E\n",
506 (*rb)->input_section.ifile->the_bfd);
508 i = ((a_sec < b_sec) ? -1 : 0);
511 return ((a_sec < b_sec) ? 0 : 1);
517 sort_by_section_name (a, b)
521 const lang_statement_union_type *const *ra = a;
522 const lang_statement_union_type *const *rb = b;
524 i = strcmp ((*ra)->input_section.section->name,
525 (*rb)->input_section.section->name);
526 /* this is a hack to make .stab and .stabstr last, so we don't have
527 to fix strip/objcopy for .reloc sections.
528 FIXME stripping images with a .rsrc section still needs to be fixed */
531 if ((strncmp ((*ra)->input_section.section->name, ".stab", 5) == 0)
532 && (strncmp ((*rb)->input_section.section->name, ".stab", 5) != 0))
539 /* Subroutine of sort_sections to a contiguous subset of a list of sections.
540 NEXT_AFTER is the element after the last one to sort.
541 The result is a pointer to the last element's "next" pointer. */
543 static lang_statement_union_type **
544 sort_sections_1 (startptr, next_after, count, sort_func)
545 lang_statement_union_type **startptr,*next_after;
547 int (*sort_func) PARAMS ((const PTR, const PTR));
549 lang_statement_union_type **vec;
550 lang_statement_union_type *p;
552 lang_statement_union_type **ret;
557 vec = ((lang_statement_union_type **)
558 xmalloc (count * sizeof (lang_statement_union_type *)));
560 for (p = *startptr, i = 0; i < count; i++, p = p->header.next)
563 qsort (vec, count, sizeof (vec[0]), sort_func);
565 /* Fill in the next pointers again. */
567 for (i = 0; i < count - 1; i++)
568 vec[i]->header.next = vec[i + 1];
569 vec[i]->header.next = next_after;
570 ret = &vec[i]->header.next;
575 /* Sort the .idata\$foo input sections of archives into filename order.
576 The reason is so dlltool can arrange to have the pe dll import information
577 generated correctly - the head of the list goes into dh.o, the tail into
578 dt.o, and the guts into ds[nnnn].o. Note that this is only needed for the
580 FIXME: This may no longer be necessary with grouped sections. Instead of
581 sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
582 .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
583 This would have to be elaborated upon to handle multiple dll's
584 [assuming such an eloboration is possible of course].
586 We also sort sections in '\$' wild statements. These are created by the
587 place_orphans routine to implement grouped sections. */
591 lang_statement_union_type *s;
593 for (; s ; s = s->header.next)
594 switch (s->header.type)
596 case lang_output_section_statement_enum:
597 sort_sections (s->output_section_statement.children.head);
599 case lang_wild_statement_enum:
601 lang_statement_union_type **p = &s->wild_statement.children.head;
602 struct wildcard_list *sec;
604 for (sec = s->wild_statement.section_list; sec; sec = sec->next)
606 /* Is this the .idata section? */
607 if (sec->spec.name != NULL
608 && strncmp (sec->spec.name, ".idata", 6) == 0)
610 /* Sort the children. We want to sort any objects in
611 the same archive. In order to handle the case of
612 including a single archive multiple times, we sort
613 all the children by archive name and then by object
614 name. After sorting them, we re-thread the pointer
619 lang_statement_union_type *start = *p;
620 if (start->header.type != lang_input_section_enum
621 || !start->input_section.ifile->the_bfd->my_archive)
622 p = &(start->header.next);
625 lang_statement_union_type *end;
628 for (end = start, count = 0;
629 end && (end->header.type
630 == lang_input_section_enum);
631 end = end->header.next)
634 p = sort_sections_1 (p, end, count,
641 /* If this is a collection of grouped sections, sort them.
642 The linker script must explicitly mention "*(.foo\$)" or
643 "*(.foo\$*)". Don't sort them if \$ is not the last
644 character (not sure if this is really useful, but it
645 allows explicitly mentioning some \$ sections and letting
646 the linker handle the rest). */
647 if (sec->spec.name != NULL)
649 char *q = strchr (sec->spec.name, '\$');
653 || (q[1] == '*' && q[2] == '\0')))
655 lang_statement_union_type *end;
658 for (end = *p, count = 0; end; end = end->header.next)
660 if (end->header.type != lang_input_section_enum)
664 (void) sort_sections_1 (p, end, count,
665 sort_by_section_name);
678 gld_${EMULATION_NAME}_before_allocation()
680 extern lang_statement_list_type *stat_ptr;
682 #ifdef TARGET_IS_ppcpe
683 /* Here we rummage through the found bfds to collect toc information */
685 LANG_FOR_EACH_INPUT_STATEMENT (is)
687 if (!ppc_process_before_allocation(is->the_bfd, &link_info))
689 einfo("Errors encountered processing file %s\n", is->filename);
694 /* We have seen it all. Allocate it, and carry on */
695 ppc_allocate_toc_section (&link_info);
697 #ifdef TARGET_IS_armpe
698 /* FIXME: we should be able to set the size of the interworking stub
701 Here we rummage through the found bfds to collect glue
702 information. FIXME: should this be based on a command line
703 option? krk@cygnus.com */
705 LANG_FOR_EACH_INPUT_STATEMENT (is)
707 if (!arm_process_before_allocation (is->the_bfd, & link_info))
709 einfo ("Errors encountered processing file %s", is->filename);
714 /* We have seen it all. Allocate it, and carry on */
715 arm_allocate_interworking_sections (& link_info);
716 #endif /* TARGET_IS_armpe */
717 #endif /* TARGET_IS_ppcpe */
719 sort_sections (stat_ptr->head);
722 /* Place an orphan section. We use this to put sections with a '\$' in them
723 into the right place. Any section with a '\$' in them (e.g. .text\$foo)
724 gets mapped to the output section with everything from the '\$' on stripped
726 See the Microsoft Portable Executable and Common Object File Format
727 Specification 4.1, section 4.2, Grouped Sections.
729 FIXME: This is now handled by the linker script using wildcards,
730 but I'm leaving this here in case we want to enable it for sections
731 which are not mentioned in the linker script. */
735 gld${EMULATION_NAME}_place_orphan (file, s)
736 lang_input_statement_type *file;
740 char *output_secname, *ps;
741 lang_output_section_statement_type *os;
742 lang_statement_union_type *l;
744 if ((s->flags & SEC_ALLOC) == 0)
747 /* Don't process grouped sections unless doing a final link.
748 If they're marked as COMDAT sections, we don't want .text\$foo to
749 end up in .text and then have .text disappear because it's marked
750 link-once-discard. */
751 if (link_info.relocateable)
754 secname = bfd_get_section_name (s->owner, s);
756 /* Everything from the '\$' on gets deleted so don't allow '\$' as the
758 if (*secname == '\$')
759 einfo ("%P%F: section %s has '\$' as first character\n", secname);
760 if (strchr (secname + 1, '\$') == NULL)
763 /* Look up the output section. The Microsoft specs say sections names in
764 image files never contain a '\$'. Fortunately, lang_..._lookup creates
765 the section if it doesn't exist. */
766 output_secname = xstrdup (secname);
767 ps = strchr (output_secname + 1, '\$');
769 os = lang_output_section_statement_lookup (output_secname);
771 /* Find the '\$' wild statement for this section. We currently require the
772 linker script to explicitly mention "*(.foo\$)".
773 FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the
774 Microsoft docs this isn't correct so it's not (currently) handled. */
778 for (l = os->children.head; l; l = l->header.next)
779 if (l->header.type == lang_wild_statement_enum)
781 struct wildcard_list *sec;
783 for (sec = l->wild_statement.section_list; sec; sec = sec->next)
784 if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
792 einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
793 #else /* FIXME: This block is untried. It exists to convey the intent,
794 should one decide to not require *(.foo\$) to appear in the linker
797 lang_wild_statement_type *new;
798 struct wildcard_list *tmp;
800 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
802 tmp->spec.name = xmalloc (strlen (output_secname) + 2);
803 sprintf (tmp->spec.name, "%s\$", output_secname);
804 tmp->spec.exclude_name_list = NULL;
806 new = new_stat (lang_wild_statement, &os->children);
807 new->filename = NULL;
808 new->filenames_sorted = false;
809 new->section_list = tmp;
810 new->keep_sections = false;
811 lang_list_init (&new->children);
816 /* Link the input section in and we're done for now.
817 The sections still have to be sorted, but that has to wait until
818 all such sections have been processed by us. The sorting is done by
820 lang_add_section (&l->wild_statement.children, s, os, file);
826 gld_${EMULATION_NAME}_get_script(isfile)
829 # Scripts compiled in.
830 # sed commands to quote an ld script as a C string.
831 sc="-f stringify.sed"
833 cat >>e${EMULATION_NAME}.c <<EOF
837 if (link_info.relocateable == true && config.build_constructors == true)
840 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
841 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
842 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
843 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
844 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
845 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
846 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
847 echo ' ; else return' >> e${EMULATION_NAME}.c
848 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
849 echo '; }' >> e${EMULATION_NAME}.c
851 cat >>e${EMULATION_NAME}.c <<EOF
854 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
856 gld_${EMULATION_NAME}_before_parse,
860 gld_${EMULATION_NAME}_after_open,
861 after_allocation_default,
862 set_output_arch_default,
863 ldemul_default_target,
864 gld_${EMULATION_NAME}_before_allocation,
865 gld_${EMULATION_NAME}_get_script,
869 NULL, /* create output section statements */
870 NULL, /* open dynamic archive */
871 gld${EMULATION_NAME}_place_orphan,
872 gld_${EMULATION_NAME}_set_symbols,
873 gld_${EMULATION_NAME}_parse_args,
874 NULL, /* unrecognized file */
875 NULL, /* list options */
876 NULL, /* recognized file */
877 NULL /* find_potential_libraries */