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, 2003
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 bfd_boolean gld${EMULATION_NAME}_place_orphan
59 PARAMS ((lang_input_statement_type *, asection *));
60 static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
62 static int sort_by_file_name PARAMS ((const PTR, const PTR));
63 static int sort_by_section_name PARAMS ((const PTR, const PTR));
64 static lang_statement_union_type **sort_sections_1
65 PARAMS ((lang_statement_union_type **, lang_statement_union_type *, int,
66 int (*) PARAMS((const PTR, const PTR))));
67 static void sort_sections PARAMS ((lang_statement_union_type *));
69 static void set_pe_name PARAMS ((char *, long int));
70 static void set_pe_subsystem PARAMS ((void));
71 static void set_pe_value PARAMS ((char *));
72 static void set_pe_stack_heap PARAMS ((char *, char *));
74 static struct internal_extra_pe_aouthdr pe;
77 extern const char *output_filename;
80 gld_${EMULATION_NAME}_before_parse()
82 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
85 ldfile_output_architecture = arch->arch;
86 ldfile_output_machine = arch->mach;
87 ldfile_output_machine_name = arch->printable_name;
90 ldfile_output_architecture = bfd_arch_${ARCH};
91 output_filename = "a.exe";
94 /* PE format extra command line options. */
96 /* Used for setting flags in the PE header. */
97 #define OPTION_BASE_FILE (300 + 1)
98 #define OPTION_DLL (OPTION_BASE_FILE + 1)
99 #define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1)
100 #define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1)
101 #define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1)
102 #define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1)
103 #define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1)
104 #define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
105 #define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1)
106 #define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1)
107 #define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
108 #define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1)
109 #define OPTION_SUBSYSTEM (OPTION_STACK + 1)
110 #define OPTION_HEAP (OPTION_SUBSYSTEM + 1)
112 static void gld${EMULATION_NAME}_add_options
113 PARAMS ((int, char **, int, struct option **, int, struct option **));
116 gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts)
117 int ns ATTRIBUTE_UNUSED;
118 char **shortopts ATTRIBUTE_UNUSED;
120 struct option **longopts;
121 int nrl ATTRIBUTE_UNUSED;
122 struct option **really_longopts ATTRIBUTE_UNUSED;
124 static const struct option xtra_long[] = {
126 {"base-file", required_argument, NULL, OPTION_BASE_FILE},
127 {"dll", no_argument, NULL, OPTION_DLL},
128 {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
129 {"heap", required_argument, NULL, OPTION_HEAP},
130 {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
131 {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
132 {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
133 {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
134 {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
135 {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
136 {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
137 {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
138 {"stack", required_argument, NULL, OPTION_STACK},
139 {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
140 {NULL, no_argument, NULL, 0}
143 *longopts = (struct option *)
144 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
145 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
149 /* PE/WIN32; added routines to get the subsystem type, heap and/or stack
150 parameters which may be input from the command line */
160 #define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0}
162 static definfo init[] =
164 /* imagebase must be first */
165 #define IMAGEBASEOFF 0
166 D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
168 {&dll, sizeof(dll), 0, "__dll__", 0},
169 D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
170 D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
171 D(MajorOperatingSystemVersion,"__major_os_version__", 4),
172 D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
173 D(MajorImageVersion,"__major_image_version__", 1),
174 D(MinorImageVersion,"__minor_image_version__", 0),
175 D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
176 D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
177 D(Subsystem,"__subsystem__", 3),
178 D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
179 D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
180 D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
181 D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
182 D(LoaderFlags,"__loader_flags__", 0x0),
183 { NULL, 0, 0, NULL, 0 }
188 set_pe_name (name, val)
193 /* Find the name and set it. */
194 for (i = 0; init[i].ptr; i++)
196 if (strcmp (name, init[i].symbol) == 0)
221 { "native", 1, "_NtProcessStartup" },
222 { "windows", 2, "_WinMainCRTStartup" },
223 { "wwindows", 2, "_wWinMainCRTStartup" },
224 { "console", 3, "_mainCRTStartup" },
225 { "wconsole", 3, "_wmainCRTStartup" },
227 /* The Microsoft linker does not recognize this. */
230 { "posix", 7, "___PosixProcessStartup"},
234 sver = strchr (optarg, ':');
236 len = strlen (optarg);
242 set_pe_name ("__major_subsystem_version__",
243 strtoul (sver + 1, &end, 0));
245 set_pe_name ("__minor_subsystem_version__",
246 strtoul (end + 1, &end, 0));
248 einfo ("%P: warning: bad version number in -subsystem option\n");
251 for (i = 0; v[i].name; i++)
253 if (strncmp (optarg, v[i].name, len) == 0
254 && v[i].name[len] == '\0')
256 set_pe_name ("__subsystem__", v[i].value);
258 /* If the subsystem is windows, we use a different entry
259 point. We also register the entry point as an undefined
260 symbol. from lang_add_entry() The reason we do
261 this is so that the user
262 doesn't have to because they would have to use the -u
263 switch if they were specifying an entry point other than
264 _mainCRTStartup. Specifically, if creating a windows
265 application, entry point _WinMainCRTStartup must be
266 specified. What I have found for non console
267 applications (entry not _mainCRTStartup) is that the .obj
268 that contains mainCRTStartup is brought in since it is
269 the first encountered in libc.lib and it has other
270 symbols in it which will be pulled in by the link
271 process. To avoid this, adding -u with the entry point
272 name specified forces the correct .obj to be used. We
273 can avoid making the user do this by always adding the
274 entry point name as an undefined symbol. */
275 lang_add_entry (v[i].entry, 1);
280 einfo ("%P%F: invalid subsystem type %s\n", optarg);
291 set_pe_name (name, strtoul (optarg, &end, 0));
294 einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
301 set_pe_stack_heap (resname, comname)
305 set_pe_value (resname);
309 set_pe_value (comname);
313 einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
318 static bfd_boolean gld${EMULATION_NAME}_handle_option
322 gld${EMULATION_NAME}_handle_option (optc)
330 case OPTION_BASE_FILE:
331 link_info.base_file = (PTR) fopen (optarg, FOPEN_WB);
332 if (link_info.base_file == NULL)
334 fprintf (stderr, "%s: Can't open base file %s\n",
335 program_name, optarg);
342 set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
345 set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
347 case OPTION_SUBSYSTEM:
350 case OPTION_MAJOR_OS_VERSION:
351 set_pe_value ("__major_os_version__");
353 case OPTION_MINOR_OS_VERSION:
354 set_pe_value ("__minor_os_version__");
356 case OPTION_MAJOR_SUBSYSTEM_VERSION:
357 set_pe_value ("__major_subsystem_version__");
359 case OPTION_MINOR_SUBSYSTEM_VERSION:
360 set_pe_value ("__minor_subsystem_version__");
362 case OPTION_MAJOR_IMAGE_VERSION:
363 set_pe_value ("__major_image_version__");
365 case OPTION_MINOR_IMAGE_VERSION:
366 set_pe_value ("__minor_image_version__");
368 case OPTION_FILE_ALIGNMENT:
369 set_pe_value ("__file_alignment__");
371 case OPTION_SECTION_ALIGNMENT:
372 set_pe_value ("__section_alignment__");
375 set_pe_name ("__dll__", 1);
377 case OPTION_IMAGE_BASE:
378 set_pe_value ("__image_base__");
384 /* Assign values to the special symbols before the linker script is
388 gld_${EMULATION_NAME}_set_symbols()
390 /* Run through and invent symbols for all the
391 names and insert the defaults. */
393 lang_statement_list_type *save;
395 if (!init[IMAGEBASEOFF].inited)
397 if (link_info.relocatable)
398 init[IMAGEBASEOFF].value = 0;
399 else if (init[DLLOFF].value)
400 init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
402 init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
405 /* Don't do any symbol assignments if this is a relocatable link. */
406 if (link_info.relocatable)
409 /* Glue the assignments into the abs section */
412 stat_ptr = &(abs_output_section->children);
414 for (j = 0; init[j].ptr; j++)
416 long val = init[j].value;
417 lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
418 if (init[j].size == sizeof(short))
419 *(short *)init[j].ptr = val;
420 else if (init[j].size == sizeof(int))
421 *(int *)init[j].ptr = val;
422 else if (init[j].size == sizeof(long))
423 *(long *)init[j].ptr = val;
424 /* This might be a long long or other special type. */
425 else if (init[j].size == sizeof(bfd_vma))
426 *(bfd_vma *)init[j].ptr = val;
429 /* Restore the pointer. */
432 if (pe.FileAlignment >
435 einfo ("%P: warning, file alignment > section alignment.\n");
440 gld_${EMULATION_NAME}_after_open()
442 /* Pass the wacky PE command line options into the output bfd.
443 FIXME: This should be done via a function, rather than by
444 including an internal BFD header. */
445 if (!coff_data(output_bfd)->pe)
447 einfo ("%F%P: PE operations on non PE file.\n");
450 pe_data(output_bfd)->pe_opthdr = pe;
451 pe_data(output_bfd)->dll = init[DLLOFF].value;
455 /* Callback functions for qsort in sort_sections. */
458 sort_by_file_name (a, b)
462 const lang_statement_union_type *const *ra = a;
463 const lang_statement_union_type *const *rb = b;
466 i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename,
467 (*rb)->input_section.ifile->the_bfd->my_archive->filename);
471 i = strcmp ((*ra)->input_section.ifile->filename,
472 (*rb)->input_section.ifile->filename);
475 /* the tail idata4/5 are the only ones without relocs to an
476 idata$6 section unless we are importing by ordinal,
477 so sort them to last to terminate the IAT
478 and HNT properly. if no reloc this one is import by ordinal
479 so we have to sort by section contents */
481 if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
483 i = (((*ra)->input_section.section->reloc_count >
484 (*rb)->input_section.section->reloc_count) ? -1 : 0);
488 return (((*ra)->input_section.section->reloc_count >
489 (*rb)->input_section.section->reloc_count) ? 0 : 1);
493 if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
494 return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
496 if (! bfd_get_section_contents ((*ra)->input_section.ifile->the_bfd,
497 (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
498 einfo ("%F%B: Can't read contents of section .idata: %E\n",
499 (*ra)->input_section.ifile->the_bfd);
501 if (! bfd_get_section_contents ((*rb)->input_section.ifile->the_bfd,
502 (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
503 einfo ("%F%B: Can't read contents of section .idata: %E\n",
504 (*rb)->input_section.ifile->the_bfd);
506 i = ((a_sec < b_sec) ? -1 : 0);
509 return ((a_sec < b_sec) ? 0 : 1);
515 sort_by_section_name (a, b)
519 const lang_statement_union_type *const *ra = a;
520 const lang_statement_union_type *const *rb = b;
522 i = strcmp ((*ra)->input_section.section->name,
523 (*rb)->input_section.section->name);
524 /* this is a hack to make .stab and .stabstr last, so we don't have
525 to fix strip/objcopy for .reloc sections.
526 FIXME stripping images with a .rsrc section still needs to be fixed */
529 if ((strncmp ((*ra)->input_section.section->name, ".stab", 5) == 0)
530 && (strncmp ((*rb)->input_section.section->name, ".stab", 5) != 0))
537 /* Subroutine of sort_sections to a contiguous subset of a list of sections.
538 NEXT_AFTER is the element after the last one to sort.
539 The result is a pointer to the last element's "next" pointer. */
541 static lang_statement_union_type **
542 sort_sections_1 (startptr, next_after, count, sort_func)
543 lang_statement_union_type **startptr,*next_after;
545 int (*sort_func) PARAMS ((const PTR, const PTR));
547 lang_statement_union_type **vec;
548 lang_statement_union_type *p;
550 lang_statement_union_type **ret;
555 vec = ((lang_statement_union_type **)
556 xmalloc (count * sizeof (lang_statement_union_type *)));
558 for (p = *startptr, i = 0; i < count; i++, p = p->header.next)
561 qsort (vec, count, sizeof (vec[0]), sort_func);
563 /* Fill in the next pointers again. */
565 for (i = 0; i < count - 1; i++)
566 vec[i]->header.next = vec[i + 1];
567 vec[i]->header.next = next_after;
568 ret = &vec[i]->header.next;
573 /* Sort the .idata\$foo input sections of archives into filename order.
574 The reason is so dlltool can arrange to have the pe dll import information
575 generated correctly - the head of the list goes into dh.o, the tail into
576 dt.o, and the guts into ds[nnnn].o. Note that this is only needed for the
578 FIXME: This may no longer be necessary with grouped sections. Instead of
579 sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
580 .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
581 This would have to be elaborated upon to handle multiple dll's
582 [assuming such an eloboration is possible of course].
584 We also sort sections in '\$' wild statements. These are created by the
585 place_orphans routine to implement grouped sections. */
589 lang_statement_union_type *s;
591 for (; s ; s = s->header.next)
592 switch (s->header.type)
594 case lang_output_section_statement_enum:
595 sort_sections (s->output_section_statement.children.head);
597 case lang_wild_statement_enum:
599 lang_statement_union_type **p = &s->wild_statement.children.head;
600 struct wildcard_list *sec;
602 for (sec = s->wild_statement.section_list; sec; sec = sec->next)
604 /* Is this the .idata section? */
605 if (sec->spec.name != NULL
606 && strncmp (sec->spec.name, ".idata", 6) == 0)
608 /* Sort the children. We want to sort any objects in
609 the same archive. In order to handle the case of
610 including a single archive multiple times, we sort
611 all the children by archive name and then by object
612 name. After sorting them, we re-thread the pointer
617 lang_statement_union_type *start = *p;
618 if (start->header.type != lang_input_section_enum
619 || !start->input_section.ifile->the_bfd->my_archive)
620 p = &(start->header.next);
623 lang_statement_union_type *end;
626 for (end = start, count = 0;
627 end && (end->header.type
628 == lang_input_section_enum);
629 end = end->header.next)
632 p = sort_sections_1 (p, end, count,
639 /* If this is a collection of grouped sections, sort them.
640 The linker script must explicitly mention "*(.foo\$)" or
641 "*(.foo\$*)". Don't sort them if \$ is not the last
642 character (not sure if this is really useful, but it
643 allows explicitly mentioning some \$ sections and letting
644 the linker handle the rest). */
645 if (sec->spec.name != NULL)
647 char *q = strchr (sec->spec.name, '\$');
651 || (q[1] == '*' && q[2] == '\0')))
653 lang_statement_union_type *end;
656 for (end = *p, count = 0; end; end = end->header.next)
658 if (end->header.type != lang_input_section_enum)
662 (void) sort_sections_1 (p, end, count,
663 sort_by_section_name);
676 gld_${EMULATION_NAME}_before_allocation()
678 extern lang_statement_list_type *stat_ptr;
680 #ifdef TARGET_IS_ppcpe
681 /* Here we rummage through the found bfds to collect toc information */
683 LANG_FOR_EACH_INPUT_STATEMENT (is)
685 if (!ppc_process_before_allocation(is->the_bfd, &link_info))
687 einfo("Errors encountered processing file %s\n", is->filename);
692 /* We have seen it all. Allocate it, and carry on */
693 ppc_allocate_toc_section (&link_info);
695 #ifdef TARGET_IS_armpe
696 /* FIXME: we should be able to set the size of the interworking stub
699 Here we rummage through the found bfds to collect glue
700 information. FIXME: should this be based on a command line
701 option? krk@cygnus.com */
703 LANG_FOR_EACH_INPUT_STATEMENT (is)
705 if (!arm_process_before_allocation (is->the_bfd, & link_info))
707 einfo ("Errors encountered processing file %s", is->filename);
712 /* We have seen it all. Allocate it, and carry on */
713 arm_allocate_interworking_sections (& link_info);
714 #endif /* TARGET_IS_armpe */
715 #endif /* TARGET_IS_ppcpe */
717 sort_sections (stat_ptr->head);
720 /* Place an orphan section. We use this to put sections with a '\$' in them
721 into the right place. Any section with a '\$' in them (e.g. .text\$foo)
722 gets mapped to the output section with everything from the '\$' on stripped
724 See the Microsoft Portable Executable and Common Object File Format
725 Specification 4.1, section 4.2, Grouped Sections.
727 FIXME: This is now handled by the linker script using wildcards,
728 but I'm leaving this here in case we want to enable it for sections
729 which are not mentioned in the linker script. */
733 gld${EMULATION_NAME}_place_orphan (file, s)
734 lang_input_statement_type *file;
738 char *output_secname, *ps;
739 lang_output_section_statement_type *os;
740 lang_statement_union_type *l;
742 if ((s->flags & SEC_ALLOC) == 0)
745 /* Don't process grouped sections unless doing a final link.
746 If they're marked as COMDAT sections, we don't want .text\$foo to
747 end up in .text and then have .text disappear because it's marked
748 link-once-discard. */
749 if (link_info.relocatable)
752 secname = bfd_get_section_name (s->owner, s);
754 /* Everything from the '\$' on gets deleted so don't allow '\$' as the
756 if (*secname == '\$')
757 einfo ("%P%F: section %s has '\$' as first character\n", secname);
758 if (strchr (secname + 1, '\$') == NULL)
761 /* Look up the output section. The Microsoft specs say sections names in
762 image files never contain a '\$'. Fortunately, lang_..._lookup creates
763 the section if it doesn't exist. */
764 output_secname = xstrdup (secname);
765 ps = strchr (output_secname + 1, '\$');
767 os = lang_output_section_statement_lookup (output_secname);
769 /* Find the '\$' wild statement for this section. We currently require the
770 linker script to explicitly mention "*(.foo\$)".
771 FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the
772 Microsoft docs this isn't correct so it's not (currently) handled. */
776 for (l = os->children.head; l; l = l->header.next)
777 if (l->header.type == lang_wild_statement_enum)
779 struct wildcard_list *sec;
781 for (sec = l->wild_statement.section_list; sec; sec = sec->next)
782 if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
790 einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
791 #else /* FIXME: This block is untried. It exists to convey the intent,
792 should one decide to not require *(.foo\$) to appear in the linker
795 lang_wild_statement_type *new;
796 struct wildcard_list *tmp;
798 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
800 tmp->spec.name = xmalloc (strlen (output_secname) + 2);
801 sprintf (tmp->spec.name, "%s\$", output_secname);
802 tmp->spec.exclude_name_list = NULL;
804 new = new_stat (lang_wild_statement, &os->children);
805 new->filename = NULL;
806 new->filenames_sorted = FALSE;
807 new->section_list = tmp;
808 new->keep_sections = FALSE;
809 lang_list_init (&new->children);
814 /* Link the input section in and we're done for now.
815 The sections still have to be sorted, but that has to wait until
816 all such sections have been processed by us. The sorting is done by
818 lang_add_section (&l->wild_statement.children, s, os, file);
824 gld_${EMULATION_NAME}_get_script(isfile)
827 # Scripts compiled in.
828 # sed commands to quote an ld script as a C string.
829 sc="-f stringify.sed"
831 cat >>e${EMULATION_NAME}.c <<EOF
835 if (link_info.relocatable && config.build_constructors)
838 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
839 echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
840 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
841 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
842 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
843 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
844 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
845 echo ' ; else return' >> e${EMULATION_NAME}.c
846 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
847 echo '; }' >> e${EMULATION_NAME}.c
849 cat >>e${EMULATION_NAME}.c <<EOF
852 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
854 gld_${EMULATION_NAME}_before_parse,
858 gld_${EMULATION_NAME}_after_open,
859 after_allocation_default,
860 set_output_arch_default,
861 ldemul_default_target,
862 gld_${EMULATION_NAME}_before_allocation,
863 gld_${EMULATION_NAME}_get_script,
867 NULL, /* create output section statements */
868 NULL, /* open dynamic archive */
869 gld${EMULATION_NAME}_place_orphan,
870 gld_${EMULATION_NAME}_set_symbols,
871 NULL, /* parse_args */
872 gld${EMULATION_NAME}_add_options,
873 gld${EMULATION_NAME}_handle_option,
874 NULL, /* unrecognized file */
875 NULL, /* list options */
876 NULL, /* recognized file */
877 NULL, /* find_potential_libraries */
878 NULL /* new_vers_pattern */