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 Free Software Foundation, Inc.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 /* The original file generated returned different default scripts depending
28 on whether certain switches were set, but these switches pertain to the
29 Linux system and that particular version of coff. In the NT case, we
30 only determine if the subsystem is console or windows in order to select
31 the correct entry point by default. */
37 #include "libiberty.h"
48 #include "coff/internal.h"
49 #include "../bfd/libcoff.h"
51 #define TARGET_IS_${EMULATION_NAME}
53 static void gld_${EMULATION_NAME}_set_symbols PARAMS ((void));
54 static void gld_${EMULATION_NAME}_after_open PARAMS ((void));
55 static void gld_${EMULATION_NAME}_before_parse PARAMS ((void));
56 static void gld_${EMULATION_NAME}_before_allocation PARAMS ((void));
57 static boolean gld${EMULATION_NAME}_place_orphan
58 PARAMS ((lang_input_statement_type *, asection *));
59 static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
60 static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
62 #if 0 /* argument to qsort so don't prototype */
63 static int sort_by_file_name PARAMS ((void *, void *));
64 static int sort_by_section_name PARAMS ((void *, void *));
66 static lang_statement_union_type **sort_sections_1
67 PARAMS ((lang_statement_union_type **, lang_statement_union_type *, int,
69 static void sort_sections PARAMS ((lang_statement_union_type *));
71 static struct internal_extra_pe_aouthdr pe;
74 extern const char *output_filename;
77 gld_${EMULATION_NAME}_before_parse()
79 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
82 ldfile_output_architecture = arch->arch;
83 ldfile_output_machine = arch->mach;
84 ldfile_output_machine_name = arch->printable_name;
87 ldfile_output_architecture = bfd_arch_${ARCH};
88 output_filename = "a.exe";
91 /* PE format extra command line options. */
93 /* Used for setting flags in the PE header. */
94 #define OPTION_BASE_FILE (300 + 1)
95 #define OPTION_DLL (OPTION_BASE_FILE + 1)
96 #define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1)
97 #define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1)
98 #define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1)
99 #define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1)
100 #define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1)
101 #define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
102 #define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1)
103 #define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1)
104 #define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
105 #define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1)
106 #define OPTION_SUBSYSTEM (OPTION_STACK + 1)
107 #define OPTION_HEAP (OPTION_SUBSYSTEM + 1)
109 static struct option longopts[] = {
111 {"base-file", required_argument, NULL, OPTION_BASE_FILE},
112 {"dll", no_argument, NULL, OPTION_DLL},
113 {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
114 {"heap", required_argument, NULL, OPTION_HEAP},
115 {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
116 {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
117 {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
118 {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
119 {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
120 {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
121 {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
122 {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
123 {"stack", required_argument, NULL, OPTION_STACK},
124 {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
125 {NULL, no_argument, NULL, 0}
129 /* PE/WIN32; added routines to get the subsystem type, heap and/or stack
130 parameters which may be input from the command line */
140 #define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0}
142 static definfo init[] =
144 /* imagebase must be first */
145 #define IMAGEBASEOFF 0
146 D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
148 {&dll, sizeof(dll), 0, "__dll__", 0},
149 D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
150 D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
151 D(MajorOperatingSystemVersion,"__major_os_version__", 4),
152 D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
153 D(MajorImageVersion,"__major_image_version__", 1),
154 D(MinorImageVersion,"__minor_image_version__", 0),
155 D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
156 D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
157 D(Subsystem,"__subsystem__", 3),
158 D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
159 D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
160 D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
161 D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
162 D(LoaderFlags,"__loader_flags__", 0x0),
163 { NULL, 0, 0, NULL, 0 }
168 set_pe_name (name, val)
173 /* Find the name and set it. */
174 for (i = 0; init[i].ptr; i++)
176 if (strcmp (name, init[i].symbol) == 0)
201 { "native", 1, "_NtProcessStartup" },
202 { "windows", 2, "_WinMainCRTStartup" },
203 { "wwindows", 2, "_wWinMainCRTStartup" },
204 { "console", 3, "_mainCRTStartup" },
205 { "wconsole", 3, "_wmainCRTStartup" },
207 /* The Microsoft linker does not recognize this. */
210 { "posix", 7, "___PosixProcessStartup"},
214 sver = strchr (optarg, ':');
216 len = strlen (optarg);
222 set_pe_name ("__major_subsystem_version__",
223 strtoul (sver + 1, &end, 0));
225 set_pe_name ("__minor_subsystem_version__",
226 strtoul (end + 1, &end, 0));
228 einfo ("%P: warning: bad version number in -subsystem option\n");
231 for (i = 0; v[i].name; i++)
233 if (strncmp (optarg, v[i].name, len) == 0
234 && v[i].name[len] == '\0')
236 set_pe_name ("__subsystem__", v[i].value);
238 /* If the subsystem is windows, we use a different entry
239 point. We also register the entry point as an undefined
240 symbol. from lang_add_entry() The reason we do
241 this is so that the user
242 doesn't have to because they would have to use the -u
243 switch if they were specifying an entry point other than
244 _mainCRTStartup. Specifically, if creating a windows
245 application, entry point _WinMainCRTStartup must be
246 specified. What I have found for non console
247 applications (entry not _mainCRTStartup) is that the .obj
248 that contains mainCRTStartup is brought in since it is
249 the first encountered in libc.lib and it has other
250 symbols in it which will be pulled in by the link
251 process. To avoid this, adding -u with the entry point
252 name specified forces the correct .obj to be used. We
253 can avoid making the user do this by always adding the
254 entry point name as an undefined symbol. */
255 lang_add_entry (v[i].entry, 1);
260 einfo ("%P%F: invalid subsystem type %s\n", optarg);
271 set_pe_name (name, strtoul (optarg, &end, 0));
274 einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
281 set_pe_stack_heap (resname, comname)
285 set_pe_value (resname);
289 set_pe_value (comname);
293 einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
300 gld_${EMULATION_NAME}_parse_args(argc, argv)
306 int prevoptind = optind;
307 int prevopterr = opterr;
309 static int lastoptind = -1;
311 if (lastoptind != optind)
317 optc = getopt_long_only (argc, argv, "-", longopts, &longind);
328 case OPTION_BASE_FILE:
329 link_info.base_file = (PTR) fopen (optarg, FOPEN_WB);
330 if (link_info.base_file == NULL)
332 fprintf (stderr, "%s: Can't open base file %s\n",
333 program_name, optarg);
340 set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
343 set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
345 case OPTION_SUBSYSTEM:
348 case OPTION_MAJOR_OS_VERSION:
349 set_pe_value ("__major_os_version__");
351 case OPTION_MINOR_OS_VERSION:
352 set_pe_value ("__minor_os_version__");
354 case OPTION_MAJOR_SUBSYSTEM_VERSION:
355 set_pe_value ("__major_subsystem_version__");
357 case OPTION_MINOR_SUBSYSTEM_VERSION:
358 set_pe_value ("__minor_subsystem_version__");
360 case OPTION_MAJOR_IMAGE_VERSION:
361 set_pe_value ("__major_image_version__");
363 case OPTION_MINOR_IMAGE_VERSION:
364 set_pe_value ("__minor_image_version__");
366 case OPTION_FILE_ALIGNMENT:
367 set_pe_value ("__file_alignment__");
369 case OPTION_SECTION_ALIGNMENT:
370 set_pe_value ("__section_alignment__");
373 set_pe_name ("__dll__", 1);
375 case OPTION_IMAGE_BASE:
376 set_pe_value ("__image_base__");
382 /* Assign values to the special symbols before the linker script is
386 gld_${EMULATION_NAME}_set_symbols()
388 /* Run through and invent symbols for all the
389 names and insert the defaults. */
391 lang_statement_list_type *save;
393 if (!init[IMAGEBASEOFF].inited)
395 if (link_info.relocateable)
396 init[IMAGEBASEOFF].value = 0;
397 else if (init[DLLOFF].value)
398 init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
400 init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
403 /* Don't do any symbol assignments if this is a relocateable link. */
404 if (link_info.relocateable)
407 /* Glue the assignments into the abs section */
410 stat_ptr = &(abs_output_section->children);
412 for (j = 0; init[j].ptr; j++)
414 long val = init[j].value;
415 lang_add_assignment (exp_assop ('=' ,init[j].symbol, exp_intop (val)));
416 if (init[j].size == sizeof(short))
417 *(short *)init[j].ptr = val;
418 else if (init[j].size == sizeof(int))
419 *(int *)init[j].ptr = val;
420 else if (init[j].size == sizeof(long))
421 *(long *)init[j].ptr = val;
422 /* This might be a long long or other special type. */
423 else if (init[j].size == sizeof(bfd_vma))
424 *(bfd_vma *)init[j].ptr = val;
427 /* Restore the pointer. */
430 if (pe.FileAlignment >
433 einfo ("%P: warning, file alignment > section alignment.\n");
438 gld_${EMULATION_NAME}_after_open()
440 /* Pass the wacky PE command line options into the output bfd.
441 FIXME: This should be done via a function, rather than by
442 including an internal BFD header. */
443 if (!coff_data(output_bfd)->pe)
445 einfo ("%F%P: PE operations on non PE file.\n");
448 pe_data(output_bfd)->pe_opthdr = pe;
449 pe_data(output_bfd)->dll = init[DLLOFF].value;
453 /* Callback functions for qsort in sort_sections. */
456 sort_by_file_name (a, b)
460 lang_statement_union_type **ra = a;
461 lang_statement_union_type **rb = b;
464 i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename,
465 (*rb)->input_section.ifile->the_bfd->my_archive->filename);
469 i = strcmp ((*ra)->input_section.ifile->filename,
470 (*rb)->input_section.ifile->filename);
473 /* the tail idata4/5 are the only ones without relocs to an
474 idata$6 section unless we are importing by ordinal,
475 so sort them to last to terminate the IAT
476 and HNT properly. if no reloc this one is import by ordinal
477 so we have to sort by section contents */
479 if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
481 i = (((*ra)->input_section.section->reloc_count >
482 (*rb)->input_section.section->reloc_count) ? -1 : 0);
486 return (((*ra)->input_section.section->reloc_count >
487 (*rb)->input_section.section->reloc_count) ? 0 : 1);
491 if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
492 return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
494 if (! bfd_get_section_contents ((*ra)->input_section.ifile->the_bfd,
495 (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
496 einfo ("%F%B: Can't read contents of section .idata: %E\n",
497 (*ra)->input_section.ifile->the_bfd);
499 if (! bfd_get_section_contents ((*rb)->input_section.ifile->the_bfd,
500 (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
501 einfo ("%F%B: Can't read contents of section .idata: %E\n",
502 (*rb)->input_section.ifile->the_bfd);
504 i = ((a_sec < b_sec) ? -1 : 0);
507 return ((a_sec < b_sec) ? 0 : 1);
513 sort_by_section_name (a, b)
517 lang_statement_union_type **ra = a;
518 lang_statement_union_type **rb = b;
520 i = strcmp ((*ra)->input_section.section->name,
521 (*rb)->input_section.section->name);
522 /* this is a hack to make .stab and .stabstr last, so we don't have
523 to fix strip/objcopy for .reloc sections.
524 FIXME stripping images with a .rsrc section still needs to be fixed */
527 if ((strncmp ((*ra)->input_section.section->name, ".stab", 5) == 0)
528 && (strncmp ((*rb)->input_section.section->name, ".stab", 5) != 0))
535 /* Subroutine of sort_sections to a contiguous subset of a list of sections.
536 NEXT_AFTER is the element after the last one to sort.
537 The result is a pointer to the last element's "next" pointer. */
539 static lang_statement_union_type **
540 sort_sections_1 (startptr, next_after, count, sort_func)
541 lang_statement_union_type **startptr,*next_after;
545 lang_statement_union_type **vec;
546 lang_statement_union_type *p;
548 lang_statement_union_type **ret;
553 vec = ((lang_statement_union_type **)
554 xmalloc (count * sizeof (lang_statement_union_type *)));
556 for (p = *startptr, i = 0; i < count; i++, p = p->next)
559 qsort (vec, count, sizeof (vec[0]), sort_func);
561 /* Fill in the next pointers again. */
563 for (i = 0; i < count - 1; i++)
564 vec[i]->header.next = vec[i + 1];
565 vec[i]->header.next = next_after;
566 ret = &vec[i]->header.next;
571 /* Sort the .idata\$foo input sections of archives into filename order.
572 The reason is so dlltool can arrange to have the pe dll import information
573 generated correctly - the head of the list goes into dh.o, the tail into
574 dt.o, and the guts into ds[nnnn].o. Note that this is only needed for the
576 FIXME: This may no longer be necessary with grouped sections. Instead of
577 sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
578 .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
579 This would have to be elaborated upon to handle multiple dll's
580 [assuming such an eloboration is possible of course].
582 We also sort sections in '\$' wild statements. These are created by the
583 place_orphans routine to implement grouped sections. */
587 lang_statement_union_type *s;
589 for (; s ; s = s->next)
590 switch (s->header.type)
592 case lang_output_section_statement_enum:
593 sort_sections (s->output_section_statement.children.head);
595 case lang_wild_statement_enum:
597 lang_statement_union_type **p = &s->wild_statement.children.head;
598 struct wildcard_list *sec;
600 for (sec = s->wild_statement.section_list; sec; sec = sec->next)
602 /* Is this the .idata section? */
603 if (sec->spec.name != NULL
604 && strncmp (sec->spec.name, ".idata", 6) == 0)
606 /* Sort the children. We want to sort any objects in
607 the same archive. In order to handle the case of
608 including a single archive multiple times, we sort
609 all the children by archive name and then by object
610 name. After sorting them, we re-thread the pointer
615 lang_statement_union_type *start = *p;
616 if (start->header.type != lang_input_section_enum
617 || !start->input_section.ifile->the_bfd->my_archive)
618 p = &(start->header.next);
621 lang_statement_union_type *end;
624 for (end = start, count = 0;
625 end && (end->header.type
626 == lang_input_section_enum);
630 p = sort_sections_1 (p, end, count,
637 /* If this is a collection of grouped sections, sort them.
638 The linker script must explicitly mention "*(.foo\$)" or
639 "*(.foo\$*)". Don't sort them if \$ is not the last
640 character (not sure if this is really useful, but it
641 allows explicitly mentioning some \$ sections and letting
642 the linker handle the rest). */
643 if (sec->spec.name != NULL)
645 char *q = strchr (sec->spec.name, '\$');
649 || (q[1] == '*' && q[2] == '\0')))
651 lang_statement_union_type *end;
654 for (end = *p, count = 0; end; end = end->next)
656 if (end->header.type != lang_input_section_enum)
660 (void) sort_sections_1 (p, end, count,
661 sort_by_section_name);
674 gld_${EMULATION_NAME}_before_allocation()
676 extern lang_statement_list_type *stat_ptr;
678 #ifdef TARGET_IS_ppcpe
679 /* Here we rummage through the found bfds to collect toc information */
681 LANG_FOR_EACH_INPUT_STATEMENT (is)
683 if (!ppc_process_before_allocation(is->the_bfd, &link_info))
685 einfo("Errors encountered processing file %s\n", is->filename);
690 /* We have seen it all. Allocate it, and carry on */
691 ppc_allocate_toc_section (&link_info);
693 #ifdef TARGET_IS_armpe
694 /* FIXME: we should be able to set the size of the interworking stub
697 Here we rummage through the found bfds to collect glue
698 information. FIXME: should this be based on a command line
699 option? krk@cygnus.com */
701 LANG_FOR_EACH_INPUT_STATEMENT (is)
703 if (!arm_process_before_allocation (is->the_bfd, & link_info))
705 einfo ("Errors encountered processing file %s", is->filename);
710 /* We have seen it all. Allocate it, and carry on */
711 arm_allocate_interworking_sections (& link_info);
712 #endif /* TARGET_IS_armpe */
713 #endif /* TARGET_IS_ppcpe */
715 sort_sections (stat_ptr->head);
718 /* Place an orphan section. We use this to put sections with a '\$' in them
719 into the right place. Any section with a '\$' in them (e.g. .text\$foo)
720 gets mapped to the output section with everything from the '\$' on stripped
722 See the Microsoft Portable Executable and Common Object File Format
723 Specification 4.1, section 4.2, Grouped Sections.
725 FIXME: This is now handled by the linker script using wildcards,
726 but I'm leaving this here in case we want to enable it for sections
727 which are not mentioned in the linker script. */
731 gld${EMULATION_NAME}_place_orphan (file, s)
732 lang_input_statement_type *file;
736 char *output_secname, *ps;
737 lang_output_section_statement_type *os;
738 lang_statement_union_type *l;
740 if ((s->flags & SEC_ALLOC) == 0)
743 /* Don't process grouped sections unless doing a final link.
744 If they're marked as COMDAT sections, we don't want .text\$foo to
745 end up in .text and then have .text disappear because it's marked
746 link-once-discard. */
747 if (link_info.relocateable)
750 secname = bfd_get_section_name (s->owner, s);
752 /* Everything from the '\$' on gets deleted so don't allow '\$' as the
754 if (*secname == '\$')
755 einfo ("%P%F: section %s has '\$' as first character\n", secname);
756 if (strchr (secname + 1, '\$') == NULL)
759 /* Look up the output section. The Microsoft specs say sections names in
760 image files never contain a '\$'. Fortunately, lang_..._lookup creates
761 the section if it doesn't exist. */
762 output_secname = xstrdup (secname);
763 ps = strchr (output_secname + 1, '\$');
765 os = lang_output_section_statement_lookup (output_secname);
767 /* Find the '\$' wild statement for this section. We currently require the
768 linker script to explicitly mention "*(.foo\$)".
769 FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the
770 Microsoft docs this isn't correct so it's not (currently) handled. */
774 for (l = os->children.head; l; l = l->next)
775 if (l->header.type == lang_wild_statement_enum)
777 struct wildcard_list *sec;
779 for (sec = l->wild_statement.section_list; sec; sec = sec->next)
780 if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
788 einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
789 #else /* FIXME: This block is untried. It exists to convey the intent,
790 should one decide to not require *(.foo\$) to appear in the linker
793 lang_wild_statement_type *new;
794 struct wildcard_list *tmp;
796 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
798 tmp->spec.name = xmalloc (strlen (output_secname) + 2);
799 sprintf (tmp->spec.name, "%s\$", output_secname);
800 tmp->spec.exclude_name_list = NULL;
802 new = new_stat (lang_wild_statement, &os->children);
803 new->filename = NULL;
804 new->filenames_sorted = false;
805 new->section_list = tmp;
806 new->keep_sections = false;
807 lang_list_init (&new->children);
812 /* Link the input section in and we're done for now.
813 The sections still have to be sorted, but that has to wait until
814 all such sections have been processed by us. The sorting is done by
816 wild_doit (&l->wild_statement.children, s, os, file);
822 gld_${EMULATION_NAME}_get_script(isfile)
825 # Scripts compiled in.
826 # sed commands to quote an ld script as a C string.
827 sc="-f stringify.sed"
829 cat >>e${EMULATION_NAME}.c <<EOF
833 if (link_info.relocateable == true && config.build_constructors == true)
836 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
837 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
838 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
839 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
840 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
841 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
842 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
843 echo ' ; else return' >> e${EMULATION_NAME}.c
844 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
845 echo '; }' >> e${EMULATION_NAME}.c
847 cat >>e${EMULATION_NAME}.c <<EOF
850 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
852 gld_${EMULATION_NAME}_before_parse,
856 gld_${EMULATION_NAME}_after_open,
857 after_allocation_default,
858 set_output_arch_default,
859 ldemul_default_target,
860 gld_${EMULATION_NAME}_before_allocation,
861 gld_${EMULATION_NAME}_get_script,
865 NULL, /* create output section statements */
866 NULL, /* open dynamic archive */
867 gld${EMULATION_NAME}_place_orphan,
868 gld_${EMULATION_NAME}_set_symbols,
869 gld_${EMULATION_NAME}_parse_args,
870 NULL, /* unrecognized file */
871 NULL, /* list options */
872 NULL, /* recognized file */
873 NULL /* find_potential_libraries */