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__"},
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;
599 /* Is this the .idata section? */
600 if (s->wild_statement.section_name != NULL
601 && strncmp (s->wild_statement.section_name, ".idata", 6) == 0)
603 /* Sort the children. We want to sort any objects in
604 the same archive. In order to handle the case of
605 including a single archive multiple times, we sort
606 all the children by archive name and then by object
607 name. After sorting them, we re-thread the pointer
612 lang_statement_union_type *start = *p;
613 if (start->header.type != lang_input_section_enum
614 || !start->input_section.ifile->the_bfd->my_archive)
615 p = &(start->header.next);
618 lang_statement_union_type *end;
621 for (end = start, count = 0;
622 end && end->header.type == lang_input_section_enum;
626 p = sort_sections_1 (p, end, count, sort_by_file_name);
632 /* If this is a collection of grouped sections, sort them.
633 The linker script must explicitly mention "*(.foo\$)" or
634 "*(.foo\$*)". Don't sort them if \$ is not the last
635 character (not sure if this is really useful, but it
636 allows explicitly mentioning some \$ sections and letting
637 the linker handle the rest). */
638 if (s->wild_statement.section_name != NULL)
640 char *q = strchr (s->wild_statement.section_name, '\$');
644 || (q[1] == '*' && q[2] == '\0')))
646 lang_statement_union_type *end;
649 for (end = *p, count = 0; end; end = end->next)
651 if (end->header.type != lang_input_section_enum)
655 (void) sort_sections_1 (p, end, count, sort_by_section_name);
667 gld_${EMULATION_NAME}_before_allocation()
669 extern lang_statement_list_type *stat_ptr;
671 #ifdef TARGET_IS_ppcpe
672 /* Here we rummage through the found bfds to collect toc information */
674 LANG_FOR_EACH_INPUT_STATEMENT (is)
676 if (!ppc_process_before_allocation(is->the_bfd, &link_info))
678 einfo("Errors encountered processing file %s\n", is->filename);
683 /* We have seen it all. Allocate it, and carry on */
684 ppc_allocate_toc_section (&link_info);
686 #ifdef TARGET_IS_armpe
687 /* FIXME: we should be able to set the size of the interworking stub
690 Here we rummage through the found bfds to collect glue
691 information. FIXME: should this be based on a command line
694 LANG_FOR_EACH_INPUT_STATEMENT (is)
696 if (!arm_process_before_allocation (is->the_bfd, & link_info))
698 einfo ("Errors encountered processing file %s", is->filename);
703 /* We have seen it all. Allocate it, and carry on */
704 arm_allocate_interworking_sections (& link_info);
705 #endif /* TARGET_IS_armpe */
706 #endif /* TARGET_IS_ppcpe */
708 sort_sections (stat_ptr->head);
711 /* Place an orphan section. We use this to put sections with a '\$' in them
712 into the right place. Any section with a '\$' in them (e.g. .text\$foo)
713 gets mapped to the output section with everything from the '\$' on stripped
715 See the Microsoft Portable Executable and Common Object File Format
716 Specification 4.1, section 4.2, Grouped Sections.
718 FIXME: This is now handled by the linker script using wildcards,
719 but I'm leaving this here in case we want to enable it for sections
720 which are not mentioned in the linker script. */
724 gld${EMULATION_NAME}_place_orphan (file, s)
725 lang_input_statement_type *file;
729 char *output_secname, *ps;
730 lang_output_section_statement_type *os;
731 lang_statement_union_type *l;
733 if ((s->flags & SEC_ALLOC) == 0)
736 /* Don't process grouped sections unless doing a final link.
737 If they're marked as COMDAT sections, we don't want .text\$foo to
738 end up in .text and then have .text disappear because it's marked
739 link-once-discard. */
740 if (link_info.relocateable)
743 secname = bfd_get_section_name (s->owner, s);
745 /* Everything from the '\$' on gets deleted so don't allow '\$' as the
747 if (*secname == '\$')
748 einfo ("%P%F: section %s has '\$' as first character\n", secname);
749 if (strchr (secname + 1, '\$') == NULL)
752 /* Look up the output section. The Microsoft specs say sections names in
753 image files never contain a '\$'. Fortunately, lang_..._lookup creates
754 the section if it doesn't exist. */
755 output_secname = xstrdup (secname);
756 ps = strchr (output_secname + 1, '\$');
758 os = lang_output_section_statement_lookup (output_secname);
760 /* Find the '\$' wild statement for this section. We currently require the
761 linker script to explicitly mention "*(.foo\$)".
762 FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the
763 Microsoft docs this isn't correct so it's not (currently) handled. */
767 for (l = os->children.head; l; l = l->next)
769 if (l->header.type == lang_wild_statement_enum
770 && strcmp (l->wild_statement.section_name, output_secname) == 0)
776 einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
777 #else /* FIXME: This block is untried. It exists to convey the intent,
778 should one decide to not require *(.foo\$) to appear in the linker
781 lang_wild_statement_type *new = new_stat (lang_wild_statement,
783 new->section_name = xmalloc (strlen (output_secname) + 2);
784 sprintf (new->section_name, "%s\$", output_secname);
785 new->filename = NULL;
786 lang_list_init (&new->children);
791 /* Link the input section in and we're done for now.
792 The sections still have to be sorted, but that has to wait until
793 all such sections have been processed by us. The sorting is done by
795 wild_doit (&l->wild_statement.children, s, os, file);
801 gld_${EMULATION_NAME}_get_script(isfile)
804 # Scripts compiled in.
805 # sed commands to quote an ld script as a C string.
806 sc="-f stringify.sed"
808 cat >>e${EMULATION_NAME}.c <<EOF
812 if (link_info.relocateable == true && config.build_constructors == true)
815 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
816 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
817 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
818 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
819 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
820 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
821 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
822 echo ' ; else return' >> e${EMULATION_NAME}.c
823 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
824 echo '; }' >> e${EMULATION_NAME}.c
826 cat >>e${EMULATION_NAME}.c <<EOF
829 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
831 gld_${EMULATION_NAME}_before_parse,
835 gld_${EMULATION_NAME}_after_open,
836 after_allocation_default,
837 set_output_arch_default,
838 ldemul_default_target,
839 gld_${EMULATION_NAME}_before_allocation,
840 gld_${EMULATION_NAME}_get_script,
844 NULL, /* create output section statements */
845 NULL, /* open dynamic archive */
846 gld${EMULATION_NAME}_place_orphan,
847 gld_${EMULATION_NAME}_set_symbols,
848 gld_${EMULATION_NAME}_parse_args,
849 NULL, /* unrecognized file */
850 NULL, /* list options */
851 NULL, /* recognized file */
852 NULL /* find_potential_libraries */