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 is generated by a shell script. DO NOT EDIT! */
11 /* AIX emulation code for ${EMULATION_NAME}
12 Copyright (C) 1991, 93, 95, 96, 97, 1998 Free Software Foundation, Inc.
13 Written by Steve Chamberlain <sac@cygnus.com>
14 AIX support by Ian Lance Taylor <ian@cygnus.com>
15 AIX 64 bit support by Tom Rix <trix@redhat.com>
17 This file is part of GLD, the Gnu Linker.
19 This program is free software; you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation; either version 2 of the License, or
22 (at your option) any later version.
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
29 You should have received a copy of the GNU General Public License
30 along with this program; if not, write to the Free Software
31 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33 #define TARGET_IS_${EMULATION_NAME}
37 #include "libiberty.h"
54 #include "coff/internal.h"
55 #include "coff/xcoff.h"
57 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
58 static int gld${EMULATION_NAME}_parse_args PARAMS ((int, char **));
59 static void gld${EMULATION_NAME}_after_open PARAMS ((void));
60 static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
61 static void gld${EMULATION_NAME}_read_file PARAMS ((const char *, boolean));
62 static void gld${EMULATION_NAME}_free PARAMS ((PTR));
63 static void gld${EMULATION_NAME}_find_relocs
64 PARAMS ((lang_statement_union_type *));
65 static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
66 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
68 /* The file alignment required for each section. */
69 static unsigned long file_align;
71 /* The maximum size the stack is permitted to grow. This is stored in
73 static unsigned long maxstack;
75 /* The maximum data size. This is stored in the a.out header. */
76 static unsigned long maxdata;
78 /* Whether to perform garbage collection. */
81 /* The module type to use. */
82 static unsigned short modtype = ('1' << 8) | 'L';
84 /* Whether the .text section must be read-only (i.e., no relocs
88 /* Whether to implement Unix like linker semantics. */
91 /* Structure used to hold import file list. */
95 struct filelist *next;
99 /* List of import files. */
100 static struct filelist *import_files;
102 /* List of export symbols read from the export files. */
104 struct export_symbol_list
106 struct export_symbol_list *next;
111 static struct export_symbol_list *export_symbols;
113 /* Maintains the 32 or 64 bit mode state of import file */
114 static unsigned int symbol_mode = 0x04;
116 /* This routine is called before anything else is done. */
119 gld${EMULATION_NAME}_before_parse()
121 #ifndef TARGET_ /* I.e., if not generic. */
122 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
125 ldfile_output_architecture = arch->arch;
126 ldfile_output_machine = arch->mach;
127 ldfile_output_machine_name = arch->printable_name;
130 ldfile_output_architecture = bfd_arch_${ARCH};
131 #endif /* not TARGET_ */
132 config.has_shared = true;
135 * The link_info.[init|fini]_functions are initialized in ld/lexsup.c.
136 * Override them here so we can use the link_info.init_function as a
137 * state flag that lets the backend know that -binitfini has been done.
139 link_info.init_function = NULL;
140 link_info.fini_function = NULL;
144 /* Handle AIX specific options. */
147 gld${EMULATION_NAME}_parse_args (argc, argv)
151 int prevoptind = optind;
152 int prevopterr = opterr;
180 b64 is an empty option. The native linker uses -b64 for xcoff64 support
181 Our linker uses -m aixppc64 for xcoff64 support. The choice for the
182 correct emulation is done in collect2.c via the environmental varible
185 binitfini has special handling in the linker backend. The native linker
186 uses the arguemnts to generate a table of init and fini functions for
187 the executable. The important use for this option is to support aix 4.2+
188 c++ constructors and destructors. This is tied into gcc via collect2.c.
189 The function table is accessed by the runtime linker/loader by checking if
190 the first symbol in the loader symbol table is "__rtinit". The native
191 linker generates this table and the loader symbol. The gnu linker looks
192 for the symbol "__rtinit" and makes it the first loader symbol. It is the
193 responsiblity of the user to define the __rtinit symbol. The format for
194 __rtinit is given by the aix system file /usr/include/rtinit.h. You can
195 look at collect2.c to see an example of how this is done for 32 and 64 bit.
196 Below is an exmaple of a 32 bit assembly file that defines __rtinit.
202 .extern init_function
203 .extern fini_function
211 f1i: .long init_function
217 f1f: .long fini_function
224 s1i: .string "init_function"
226 s1f: .string "fini_function"
230 static const struct option longopts[] = {
231 {"basis", no_argument, NULL, OPTION_IGNORE},
232 {"bautoimp", no_argument, NULL, OPTION_AUTOIMP},
233 {"bcomprld", no_argument, NULL, OPTION_IGNORE},
234 {"bcrld", no_argument, NULL, OPTION_IGNORE},
235 {"bcror31", no_argument, NULL, OPTION_IGNORE},
236 {"bD", required_argument, NULL, OPTION_MAXDATA},
237 {"bE", required_argument, NULL, OPTION_EXPORT},
238 {"bernotok", no_argument, NULL, OPTION_ERNOTOK},
239 {"berok", no_argument, NULL, OPTION_EROK},
240 {"berrmsg", no_argument, NULL, OPTION_IGNORE},
241 {"bexport", required_argument, NULL, OPTION_EXPORT},
242 {"bf", no_argument, NULL, OPTION_ERNOTOK},
243 {"bgc", no_argument, &gc, 1},
244 {"bh", required_argument, NULL, OPTION_IGNORE},
245 {"bhalt", required_argument, NULL, OPTION_IGNORE},
246 {"bI", required_argument, NULL, OPTION_IMPORT},
247 {"bimport", required_argument, NULL, OPTION_IMPORT},
248 {"binitfini", required_argument, NULL, OPTION_INITFINI},
249 {"bl", required_argument, NULL, OPTION_LOADMAP},
250 {"bloadmap", required_argument, NULL, OPTION_LOADMAP},
251 {"bmaxdata", required_argument, NULL, OPTION_MAXDATA},
252 {"bmaxstack", required_argument, NULL, OPTION_MAXSTACK},
253 {"bM", required_argument, NULL, OPTION_MODTYPE},
254 {"bmodtype", required_argument, NULL, OPTION_MODTYPE},
255 {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP},
256 {"bnodelcsect", no_argument, NULL, OPTION_IGNORE},
257 {"bnoentry", no_argument, NULL, OPTION_IGNORE},
258 {"bnogc", no_argument, &gc, 0},
259 {"bnso", no_argument, NULL, OPTION_NOAUTOIMP},
260 {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT},
261 {"bnotextro", no_argument, &textro, 0},
262 {"bnro", no_argument, &textro, 0},
263 {"bpD", required_argument, NULL, OPTION_PD},
264 {"bpT", required_argument, NULL, OPTION_PT},
265 {"bro", no_argument, &textro, 1},
266 {"bS", required_argument, NULL, OPTION_MAXSTACK},
267 {"bso", no_argument, NULL, OPTION_AUTOIMP},
268 {"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT},
269 {"btextro", no_argument, &textro, 1},
270 {"b64", no_argument, NULL, 0},
271 {"static", no_argument, NULL, OPTION_NOAUTOIMP},
272 {"unix", no_argument, NULL, OPTION_UNIX},
273 {NULL, no_argument, NULL, 0}
276 /* Options supported by the AIX linker which we do not support: -f,
277 -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps,
278 -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl,
279 -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl,
280 -bnobind, -bnocomprld, -bnocrld, -bnoerrmsg, -bnoglink,
281 -bnoloadmap, -bnl, -bnoobjreorder, -bnoquiet, -bnoreorder,
282 -bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk,
285 /* If the current option starts with -b, change the first : to an =.
286 The AIX linker uses : to separate the option from the argument;
287 changing it to = lets us treat it as a getopt option. */
293 if (indx < argc && strncmp (argv[indx], "-b", 2) == 0) {
296 for (s = argv[indx]; *s != '\0'; s++) {
305 /* We add s and u so to the short options list so that -s and -u on
306 the command line do not match -static and -unix. */
309 optc = getopt_long_only (argc, argv, "-D:H:KT:zsu", longopts, &longind);
321 /* Long option which just sets a flag. */
325 val = strtoll (optarg, &end, 0);
327 einfo ("%P: warning: ignoring invalid -D number %s\n", optarg);
329 lang_section_start (".data", exp_intop (val));
333 val = strtoul (optarg, &end, 0);
335 || (val & (val - 1)) != 0)
336 einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
343 /* FIXME: This should use the page size for the target system. */
348 /* On AIX this is the same as GNU ld -Ttext. When we see -T
349 number, we assume the AIX option is intended. Otherwise, we
350 assume the usual GNU ld -T option is intended. We can't just
351 ignore the AIX option, because gcc passes it to the linker. */
352 val = strtoull (optarg, &end, 0);
358 lang_section_start (".text", exp_intop (val));
364 case OPTION_INITFINI: {
366 * The aix linker init fini has the format :
368 * -binitfini:[ Initial][:Termination][:Priority]
370 * it allows the Termination and Priority to be optional.
372 * Since we support only one init/fini pair, we ignore the Priority.
374 * Define the special symbol __rtinit.
376 * strtok does not correctly handle the case of -binitfini::fini: so
382 while (*t && ':' != *t) t++;
385 if (0 != strlen(i)) {
386 link_info.init_function = i;
390 while (*t && ':' != *t) t++;
393 if (0 != strlen(f)) {
394 link_info.fini_function = f;
400 link_info.static_link = false;
404 force_make_executable = false;
408 force_make_executable = true;
412 gld${EMULATION_NAME}_read_file (optarg, false);
418 struct filelist **flpp;
420 n = (struct filelist *) xmalloc (sizeof (struct filelist));
423 flpp = &import_files;
424 while (*flpp != NULL)
425 flpp = &(*flpp)->next;
431 config.map_filename = optarg;
435 val = strtoull (optarg, &end, 0);
437 einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n",
443 case OPTION_MAXSTACK:
444 val = strtoull (optarg, &end, 0);
446 einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n",
455 link_info.shared = true;
458 if (*optarg == '\0' || optarg[1] == '\0')
459 einfo ("%P: warning: ignoring invalid module type %s\n", optarg);
461 modtype = (*optarg << 8) | optarg[1];
464 case OPTION_NOAUTOIMP:
465 link_info.static_link = true;
468 case OPTION_NOSTRCMPCT:
469 link_info.traditional_format = true;
473 /* This sets the page that the .data section is supposed to
474 start on. The offset within the page should still be the
475 offset within the file, so we need to build an appropriate
477 val = strtoull (optarg, &end, 0);
479 einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg);
487 exp_nameop (NAME, "."),
490 exp_binop ('+', t, exp_intop (31)),
491 exp_intop (~ (bfd_vma) 31));
492 lang_section_start (".data", t);
497 /* This set the page that the .text section is supposed to start
498 on. The offset within the page should still be the offset
500 val = strtoull (optarg, &end, 0);
502 einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg);
509 exp_nameop (SIZEOF_HEADERS, NULL));
511 exp_binop ('+', t, exp_intop (31)),
512 exp_intop (~ (bfd_vma) 31));
513 lang_section_start (".text", t);
517 case OPTION_STRCMPCT:
518 link_info.traditional_format = false;
529 /* This is called when an input file can not be recognized as a BFD
530 object or an archive. If the file starts with #!, we must treat it
531 as an import file. This is for AIX compatibility. */
534 gld${EMULATION_NAME}_unrecognized_file (entry)
535 lang_input_statement_type *entry;
540 e = fopen (entry->filename, FOPEN_RT);
546 if (getc (e) == '#' && getc (e) == '!')
549 struct filelist **flpp;
551 n = (struct filelist *) xmalloc (sizeof (struct filelist));
553 n->name = entry->filename;
554 flpp = &import_files;
555 while (*flpp != NULL)
556 flpp = &(*flpp)->next;
560 entry->loaded = true;
568 /* This is called after the input files have been opened. */
571 gld${EMULATION_NAME}_after_open ()
576 /* Call ldctor_build_sets, after pretending that this is a
577 relocateable link. We do this because AIX requires relocation
578 entries for all references to symbols, even in a final
579 executable. Of course, we only want to do this if we are
580 producing an XCOFF output file. */
581 r = link_info.relocateable;
582 if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL)
583 link_info.relocateable = true;
584 ldctor_build_sets ();
585 link_info.relocateable = r;
587 /* For each set, record the size, so that the XCOFF backend can
588 output the correct csect length. */
589 for (p = sets; p != (struct set_info *) NULL; p = p->next)
593 /* If the symbol is defined, we may have been invoked from
594 collect, and the sets may already have been built, so we do
596 if (p->h->type == bfd_link_hash_defined
597 || p->h->type == bfd_link_hash_defweak)
600 if (p->reloc != BFD_RELOC_CTOR)
602 /* Handle this if we need to. */
606 size = (p->count + 2) * 4;
607 if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
608 einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
612 /* This is called after the sections have been attached to output
613 sections, but before any sizes or addresses have been set. */
616 gld${EMULATION_NAME}_before_allocation ()
619 struct export_symbol_list *el;
621 asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS];
624 /* Handle the import and export files, if any. */
625 for (fl = import_files; fl != NULL; fl = fl->next)
626 gld${EMULATION_NAME}_read_file (fl->name, true);
627 for (el = export_symbols; el != NULL; el = el->next) {
628 struct bfd_link_hash_entry *h;
630 h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
632 einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
633 if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall))
634 einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
637 /* Track down all relocations called for by the linker script (these
638 are typically constructor/destructor entries created by
639 CONSTRUCTORS) and let the backend know it will need to create
640 .loader relocs for them. */
641 lang_for_each_statement (gld${EMULATION_NAME}_find_relocs);
643 /* We need to build LIBPATH from the -L arguments. If any -rpath
644 arguments were used, though, we use -rpath instead, as a GNU
646 if (command_line.rpath != NULL)
647 libpath = command_line.rpath;
648 else if (search_head == NULL)
649 libpath = (char *) "";
653 search_dirs_type *search;
655 len = strlen (search_head->name);
656 libpath = xmalloc (len + 1);
657 strcpy (libpath, search_head->name);
658 for (search = search_head->next; search != NULL; search = search->next)
662 nlen = strlen (search->name);
663 libpath = xrealloc (libpath, len + nlen + 2);
665 strcpy (libpath + len + 1, search->name);
670 /* Let the XCOFF backend set up the .loader section. */
671 if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
672 entry_symbol, file_align,
674 gc && ! unix_ld ? true : false,
676 textro ? true : false,
679 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
681 /* Look through the special sections, and put them in the right
682 place in the link ordering. This is especially magic. */
683 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) {
685 lang_output_section_statement_type *os;
686 lang_statement_union_type **pls;
687 lang_input_section_type *is;
691 sec = special_sections[i];
695 /* Remove this section from the list of the output section.
696 This assumes we know what the script looks like. */
698 os = lang_output_section_find (sec->output_section->name);
700 einfo ("%P%F: can't find output section %s\n",
701 sec->output_section->name);
704 for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->next) {
706 if ((*pls)->header.type == lang_input_section_enum &&
707 (*pls)->input_section.section == sec) {
708 is = (lang_input_section_type *) *pls;
713 if ((*pls)->header.type == lang_wild_statement_enum) {
714 lang_statement_union_type **pwls;
716 for (pwls = &(*pls)->wild_statement.children.head;
718 pwls = &(*pwls)->next) {
720 if ((*pwls)->header.type == lang_input_section_enum &&
721 (*pwls)->input_section.section == sec) {
723 is = (lang_input_section_type *) *pwls;
724 *pwls = (*pwls)->next;
735 einfo ("%P%F: can't find %s in output section\n",
736 bfd_get_section_name (sec->owner, sec));
739 /* Now figure out where the section should go. */
742 default: /* to avoid warnings */
743 case XCOFF_SPECIAL_SECTION_TEXT:
749 case XCOFF_SPECIAL_SECTION_ETEXT:
755 case XCOFF_SPECIAL_SECTION_DATA:
761 case XCOFF_SPECIAL_SECTION_EDATA:
767 case XCOFF_SPECIAL_SECTION_END:
768 case XCOFF_SPECIAL_SECTION_END2:
775 os = lang_output_section_find (oname);
778 is->header.next = os->children.head;
779 os->children.head = (lang_statement_union_type *) is;
781 is->header.next = NULL;
782 lang_statement_append (&os->children,
783 (lang_statement_union_type *) is,
789 static int change_symbol_mode (char *input)
796 char *symbol_mode_string[] = {
806 for (bit = 0; ; bit++) {
807 string = symbol_mode_string[bit];
811 if (0 == strcmp(input, string)) {
812 symbol_mode = (1 << bit);
816 /* should not be here */
821 static int is_syscall(char *input)
826 * -1 : error, try something else
831 char *syscall_string[] = {
834 "svc3264", /* 0x04 */
836 "syscall", /* 0x10 */
837 "syscall32", /* 0x20 */
838 "syscall3264", /* 0x40 */
839 "syscall64", /* 0x80 */
843 for (bit = 0; ;bit++) {
845 string = syscall_string[bit];
846 if (NULL == string) {
850 if (0 == strcmp(input, string)) {
851 if (1 << bit & ${SYSCALL_MASK}) {
858 /* should not be here */
863 /* Read an import or export file. For an import file, this is called
864 by the before_allocation emulation routine. For an export file,
865 this is called by the parse_args emulation routine. */
868 gld${EMULATION_NAME}_read_file (filename, import)
869 const char *filename;
879 const char *impmember;
881 o = (struct obstack *) xmalloc (sizeof (struct obstack));
882 obstack_specify_allocation (o, 0, 0, xmalloc, gld${EMULATION_NAME}_free);
884 f = fopen (filename, FOPEN_RT);
887 bfd_set_error (bfd_error_system_call);
888 einfo ("%F%s: %E\n", filename);
900 * default to 32 and 64 bit mode
901 * symbols at top of /lib/syscalls.exp do not have a mode modifier and they
902 * are not repeated, assume 64 bit routines also want to use them.
903 * See the routine change_symbol_mode for more information.
907 while ((c = getc (f)) != EOF)
913 struct bfd_link_hash_entry *h;
917 obstack_1grow (o, c);
921 obstack_1grow (o, '\0');
924 s = (char *) obstack_base (o);
925 while (isspace ((unsigned char) *s))
929 change_symbol_mode (s) ||
930 (*s == '#' && s[1] == ' ') ||
931 (! import && *s == '#' && s[1] == '!'))
933 obstack_free (o, obstack_base (o));
937 if (*s == '#' && s[1] == '!')
940 while (isspace ((unsigned char) *s))
947 obstack_free (o, obstack_base (o));
950 einfo ("%F%s%d: #! ([member]) is not supported in import files\n",
957 (void) obstack_finish (o);
961 while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0')
971 if (imppath == file - 1)
981 while (isspace ((unsigned char) cs))
990 einfo ("%s:%d: warning: syntax error in import file\n",
997 while (*s != ')' && *s != '\0')
1002 einfo ("%s:%d: warning: syntax error in import file\n",
1010 if (symbol_mode & ${SYMBOL_MODE_MASK}) {
1012 /* This is a symbol to be imported or exported. */
1015 address = (bfd_vma) -1;
1017 while (! isspace ((unsigned char) *s) && *s != '\0')
1025 while (isspace ((unsigned char) *s))
1029 while (! isspace ((unsigned char) *se) && *se != '\0')
1034 while (isspace ((unsigned char) *se))
1037 einfo ("%s%d: warning: syntax error in import/export file\n",
1045 status = is_syscall(s);
1049 /* this is a system call */
1054 /* ignore this system call */
1058 /* not a system call, check for address */
1059 address = strtoul (s, &end, 0);
1061 einfo ("%s:%d: warning: syntax error in import/export file\n", filename, lineno);
1070 struct export_symbol_list *n;
1072 ldlang_add_undef (symname);
1073 n = ((struct export_symbol_list *)
1074 xmalloc (sizeof (struct export_symbol_list)));
1075 n->next = export_symbols;
1076 n->name = xstrdup (symname);
1077 n->syscall = syscall;
1082 h = bfd_link_hash_lookup (link_info.hash, symname, false, false,
1084 if (h == NULL || h->type == bfd_link_hash_new)
1086 /* We can just ignore attempts to import an unreferenced
1091 if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
1092 address, imppath, impfile,
1094 einfo ("%X%s:%d: failed to import symbol %s: %E\n",
1095 filename, lineno, symname);
1099 obstack_free (o, obstack_base (o));
1102 if (obstack_object_size (o) > 0)
1104 einfo ("%s:%d: warning: ignoring unterminated last line\n",
1106 obstack_free (o, obstack_base (o));
1111 obstack_free (o, NULL);
1116 /* This routine saves us from worrying about declaring free. */
1119 gld${EMULATION_NAME}_free (p)
1125 /* This is called by the before_allocation routine via
1126 lang_for_each_statement. It looks for relocations and assignments
1130 gld${EMULATION_NAME}_find_relocs (s)
1131 lang_statement_union_type *s;
1133 if (s->header.type == lang_reloc_statement_enum)
1135 lang_reloc_statement_type *rs;
1137 rs = &s->reloc_statement;
1138 if (rs->name == NULL)
1139 einfo ("%F%P: only relocations against symbols are permitted\n");
1140 if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
1141 einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
1144 if (s->header.type == lang_assignment_statement_enum)
1145 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1148 /* Look through an expression for an assignment statement. */
1151 gld${EMULATION_NAME}_find_exp_assignment (exp)
1154 struct bfd_link_hash_entry *h;
1156 switch (exp->type.node_class)
1159 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
1160 false, false, false);
1165 if (strcmp (exp->assign.dst, ".") != 0)
1167 if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info,
1169 einfo ("%P%F: failed to record assignment to %s: %E\n",
1172 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1176 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1177 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1181 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1182 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1183 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1187 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1196 gld${EMULATION_NAME}_get_script(isfile)
1200 if test -n "$COMPILE_IN"
1202 # Scripts compiled in.
1204 # sed commands to quote an ld script as a C string.
1205 sc="-f ${srcdir}/emultempl/stringify.sed"
1207 cat >>e${EMULATION_NAME}.c <<EOF
1211 if (link_info.relocateable == true && config.build_constructors == true)
1214 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1215 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1216 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
1217 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
1218 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
1219 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
1220 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
1221 echo ' ; else return' >> e${EMULATION_NAME}.c
1222 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1223 echo '; }' >> e${EMULATION_NAME}.c
1226 # Scripts read from the filesystem.
1228 cat >>e${EMULATION_NAME}.c <<EOF
1232 if (link_info.relocateable == true && config.build_constructors == true)
1233 return "ldscripts/${EMULATION_NAME}.xu";
1234 else if (link_info.relocateable == true)
1235 return "ldscripts/${EMULATION_NAME}.xr";
1236 else if (!config.text_read_only)
1237 return "ldscripts/${EMULATION_NAME}.xbn";
1238 else if (!config.magic_demand_paged)
1239 return "ldscripts/${EMULATION_NAME}.xn";
1241 return "ldscripts/${EMULATION_NAME}.x";
1247 cat >>e${EMULATION_NAME}.c <<EOF
1249 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1251 gld${EMULATION_NAME}_before_parse,
1254 after_parse_default,
1255 gld${EMULATION_NAME}_after_open,
1256 after_allocation_default,
1257 set_output_arch_default,
1258 ldemul_default_target,
1259 gld${EMULATION_NAME}_before_allocation,
1260 gld${EMULATION_NAME}_get_script,
1261 "${EMULATION_NAME}",
1264 0, /* create_output_section_statements */
1265 0, /* open_dynamic_archive */
1266 0, /* place_orphan */
1267 0, /* set_symbols */
1268 gld${EMULATION_NAME}_parse_args,
1269 gld${EMULATION_NAME}_unrecognized_file,
1270 NULL, /* list_options */
1271 NULL, /* recognized_file */
1272 NULL, /* find potential_libraries */