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 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001
13 Free Software Foundation, Inc.
14 Written by Steve Chamberlain <sac@cygnus.com>
15 AIX support by Ian Lance Taylor <ian@cygnus.com>
16 AIX 64 bit support by Tom Rix <trix@redhat.com>
18 This file is part of GLD, the Gnu Linker.
20 This program is free software; you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation; either version 2 of the License, or
23 (at your option) any later version.
25 This program is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
30 You should have received a copy of the GNU General Public License
31 along with this program; if not, write to the Free Software
32 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
34 #define TARGET_IS_${EMULATION_NAME}
38 #include "libiberty.h"
55 #include "coff/internal.h"
56 #include "coff/xcoff.h"
58 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
59 static int gld${EMULATION_NAME}_parse_args PARAMS ((int, char **));
60 static void gld${EMULATION_NAME}_after_open PARAMS ((void));
61 static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
62 static void gld${EMULATION_NAME}_read_file PARAMS ((const char *, boolean));
63 static void gld${EMULATION_NAME}_free PARAMS ((PTR));
64 static void gld${EMULATION_NAME}_find_relocs
65 PARAMS ((lang_statement_union_type *));
66 static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
67 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
69 /* The file alignment required for each section. */
70 static unsigned long file_align;
72 /* The maximum size the stack is permitted to grow. This is stored in
74 static unsigned long maxstack;
76 /* The maximum data size. This is stored in the a.out header. */
77 static unsigned long maxdata;
79 /* Whether to perform garbage collection. */
82 /* The module type to use. */
83 static unsigned short modtype = ('1' << 8) | 'L';
85 /* Whether the .text section must be read-only (i.e., no relocs
89 /* Whether to implement Unix like linker semantics. */
92 /* Structure used to hold import file list. */
96 struct filelist *next;
100 /* List of import files. */
101 static struct filelist *import_files;
103 /* List of export symbols read from the export files. */
105 struct export_symbol_list
107 struct export_symbol_list *next;
112 static struct export_symbol_list *export_symbols;
114 /* Maintains the 32 or 64 bit mode state of import file */
115 static unsigned int symbol_mode = 0x04;
117 /* This routine is called before anything else is done. */
120 gld${EMULATION_NAME}_before_parse ()
122 #ifndef TARGET_ /* I.e., if not generic. */
123 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
126 ldfile_output_architecture = arch->arch;
127 ldfile_output_machine = arch->mach;
128 ldfile_output_machine_name = arch->printable_name;
131 ldfile_output_architecture = bfd_arch_${ARCH};
132 #endif /* not TARGET_ */
133 config.has_shared = true;
136 * The link_info.[init|fini]_functions are initialized in ld/lexsup.c.
137 * Override them here so we can use the link_info.init_function as a
138 * state flag that lets the backend know that -binitfini has been done.
140 link_info.init_function = NULL;
141 link_info.fini_function = NULL;
145 /* Handle AIX specific options. */
148 gld${EMULATION_NAME}_parse_args (argc, argv)
152 int prevoptind = optind;
153 int prevopterr = opterr;
181 b64 is an empty option. The native linker uses -b64 for xcoff64 support
182 Our linker uses -m aixppc64 for xcoff64 support. The choice for the
183 correct emulation is done in collect2.c via the environmental varible
186 binitfini has special handling in the linker backend. The native linker
187 uses the arguemnts to generate a table of init and fini functions for
188 the executable. The important use for this option is to support aix 4.2+
189 c++ constructors and destructors. This is tied into gcc via collect2.c.
190 The function table is accessed by the runtime linker/loader by checking if
191 the first symbol in the loader symbol table is "__rtinit". The native
192 linker generates this table and the loader symbol. The gnu linker looks
193 for the symbol "__rtinit" and makes it the first loader symbol. It is the
194 responsiblity of the user to define the __rtinit symbol. The format for
195 __rtinit is given by the aix system file /usr/include/rtinit.h. You can
196 look at collect2.c to see an example of how this is done for 32 and 64 bit.
197 Below is an exmaple of a 32 bit assembly file that defines __rtinit.
203 .extern init_function
204 .extern fini_function
212 f1i: .long init_function
218 f1f: .long fini_function
225 s1i: .string "init_function"
227 s1f: .string "fini_function"
231 static const struct option longopts[] = {
232 {"basis", no_argument, NULL, OPTION_IGNORE},
233 {"bautoimp", no_argument, NULL, OPTION_AUTOIMP},
234 {"bcomprld", no_argument, NULL, OPTION_IGNORE},
235 {"bcrld", no_argument, NULL, OPTION_IGNORE},
236 {"bcror31", no_argument, NULL, OPTION_IGNORE},
237 {"bD", required_argument, NULL, OPTION_MAXDATA},
238 {"bE", required_argument, NULL, OPTION_EXPORT},
239 {"bernotok", no_argument, NULL, OPTION_ERNOTOK},
240 {"berok", no_argument, NULL, OPTION_EROK},
241 {"berrmsg", no_argument, NULL, OPTION_IGNORE},
242 {"bexport", required_argument, NULL, OPTION_EXPORT},
243 {"bf", no_argument, NULL, OPTION_ERNOTOK},
244 {"bgc", no_argument, &gc, 1},
245 {"bh", required_argument, NULL, OPTION_IGNORE},
246 {"bhalt", required_argument, NULL, OPTION_IGNORE},
247 {"bI", required_argument, NULL, OPTION_IMPORT},
248 {"bimport", required_argument, NULL, OPTION_IMPORT},
249 {"binitfini", required_argument, NULL, OPTION_INITFINI},
250 {"bl", required_argument, NULL, OPTION_LOADMAP},
251 {"bloadmap", required_argument, NULL, OPTION_LOADMAP},
252 {"bmaxdata", required_argument, NULL, OPTION_MAXDATA},
253 {"bmaxstack", required_argument, NULL, OPTION_MAXSTACK},
254 {"bM", required_argument, NULL, OPTION_MODTYPE},
255 {"bmodtype", required_argument, NULL, OPTION_MODTYPE},
256 {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP},
257 {"bnodelcsect", no_argument, NULL, OPTION_IGNORE},
258 {"bnoentry", no_argument, NULL, OPTION_IGNORE},
259 {"bnogc", no_argument, &gc, 0},
260 {"bnso", no_argument, NULL, OPTION_NOAUTOIMP},
261 {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT},
262 {"bnotextro", no_argument, &textro, 0},
263 {"bnro", no_argument, &textro, 0},
264 {"bpD", required_argument, NULL, OPTION_PD},
265 {"bpT", required_argument, NULL, OPTION_PT},
266 {"bro", no_argument, &textro, 1},
267 {"bS", required_argument, NULL, OPTION_MAXSTACK},
268 {"bso", no_argument, NULL, OPTION_AUTOIMP},
269 {"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT},
270 {"btextro", no_argument, &textro, 1},
271 {"b64", no_argument, NULL, 0},
272 {"static", no_argument, NULL, OPTION_NOAUTOIMP},
273 {"unix", no_argument, NULL, OPTION_UNIX},
274 {NULL, no_argument, NULL, 0}
277 /* Options supported by the AIX linker which we do not support: -f,
278 -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps,
279 -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl,
280 -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl,
281 -bnobind, -bnocomprld, -bnocrld, -bnoerrmsg, -bnoglink,
282 -bnoloadmap, -bnl, -bnoobjreorder, -bnoquiet, -bnoreorder,
283 -bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk,
286 /* If the current option starts with -b, change the first : to an =.
287 The AIX linker uses : to separate the option from the argument;
288 changing it to = lets us treat it as a getopt option. */
295 if (indx < argc && strncmp (argv[indx], "-b", 2) == 0)
299 for (s = argv[indx]; *s != '\0'; s++)
310 /* We add s and u so to the short options list so that -s and -u on
311 the command line do not match -static and -unix. */
314 optc = getopt_long_only (argc, argv, "-D:H:KT:zsu", longopts, &longind);
326 /* Long option which just sets a flag. */
330 val = strtoll (optarg, &end, 0);
332 einfo ("%P: warning: ignoring invalid -D number %s\n", optarg);
334 lang_section_start (".data", exp_intop (val));
338 val = strtoul (optarg, &end, 0);
340 || (val & (val - 1)) != 0)
341 einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
348 /* FIXME: This should use the page size for the target system. */
353 /* On AIX this is the same as GNU ld -Ttext. When we see -T
354 number, we assume the AIX option is intended. Otherwise, we
355 assume the usual GNU ld -T option is intended. We can't just
356 ignore the AIX option, because gcc passes it to the linker. */
357 val = strtoull (optarg, &end, 0);
363 lang_section_start (".text", exp_intop (val));
369 case OPTION_INITFINI:
372 * The aix linker init fini has the format :
374 * -binitfini:[ Initial][:Termination][:Priority]
376 * it allows the Termination and Priority to be optional.
378 * Since we support only one init/fini pair, we ignore the Priority.
380 * Define the special symbol __rtinit.
382 * strtok does not correctly handle the case of -binitfini::fini: so
388 while (*t && ':' != *t)
395 link_info.init_function = i;
399 while (*t && ':' != *t)
405 link_info.fini_function = f;
411 link_info.static_link = false;
415 force_make_executable = false;
419 force_make_executable = true;
423 gld${EMULATION_NAME}_read_file (optarg, false);
429 struct filelist **flpp;
431 n = (struct filelist *) xmalloc (sizeof (struct filelist));
434 flpp = &import_files;
435 while (*flpp != NULL)
436 flpp = &(*flpp)->next;
442 config.map_filename = optarg;
446 val = strtoull (optarg, &end, 0);
448 einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n", optarg);
453 case OPTION_MAXSTACK:
454 val = strtoull (optarg, &end, 0);
456 einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n", optarg);
464 link_info.shared = true;
467 if (*optarg == '\0' || optarg[1] == '\0')
468 einfo ("%P: warning: ignoring invalid module type %s\n", optarg);
470 modtype = (*optarg << 8) | optarg[1];
473 case OPTION_NOAUTOIMP:
474 link_info.static_link = true;
477 case OPTION_NOSTRCMPCT:
478 link_info.traditional_format = true;
482 /* This sets the page that the .data section is supposed to
483 start on. The offset within the page should still be the
484 offset within the file, so we need to build an appropriate
486 val = strtoull (optarg, &end, 0);
488 einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg);
496 exp_nameop (NAME, "."),
499 exp_binop ('+', t, exp_intop (31)),
500 exp_intop (~ (bfd_vma) 31));
501 lang_section_start (".data", t);
506 /* This set the page that the .text section is supposed to start
507 on. The offset within the page should still be the offset
509 val = strtoull (optarg, &end, 0);
511 einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg);
518 exp_nameop (SIZEOF_HEADERS, NULL));
520 exp_binop ('+', t, exp_intop (31)),
521 exp_intop (~ (bfd_vma) 31));
522 lang_section_start (".text", t);
526 case OPTION_STRCMPCT:
527 link_info.traditional_format = false;
538 /* This is called when an input file can not be recognized as a BFD
539 object or an archive. If the file starts with #!, we must treat it
540 as an import file. This is for AIX compatibility. */
543 gld${EMULATION_NAME}_unrecognized_file (entry)
544 lang_input_statement_type *entry;
549 e = fopen (entry->filename, FOPEN_RT);
555 if (getc (e) == '#' && getc (e) == '!')
558 struct filelist **flpp;
560 n = (struct filelist *) xmalloc (sizeof (struct filelist));
562 n->name = entry->filename;
563 flpp = &import_files;
564 while (*flpp != NULL)
565 flpp = &(*flpp)->next;
569 entry->loaded = true;
577 /* This is called after the input files have been opened. */
580 gld${EMULATION_NAME}_after_open ()
585 /* Call ldctor_build_sets, after pretending that this is a
586 relocateable link. We do this because AIX requires relocation
587 entries for all references to symbols, even in a final
588 executable. Of course, we only want to do this if we are
589 producing an XCOFF output file. */
590 r = link_info.relocateable;
591 if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL)
592 link_info.relocateable = true;
593 ldctor_build_sets ();
594 link_info.relocateable = r;
596 /* For each set, record the size, so that the XCOFF backend can
597 output the correct csect length. */
598 for (p = sets; p != (struct set_info *) NULL; p = p->next)
602 /* If the symbol is defined, we may have been invoked from
603 collect, and the sets may already have been built, so we do
605 if (p->h->type == bfd_link_hash_defined
606 || p->h->type == bfd_link_hash_defweak)
609 if (p->reloc != BFD_RELOC_CTOR)
611 /* Handle this if we need to. */
615 size = (p->count + 2) * 4;
616 if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
617 einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
621 /* This is called after the sections have been attached to output
622 sections, but before any sizes or addresses have been set. */
625 gld${EMULATION_NAME}_before_allocation ()
628 struct export_symbol_list *el;
630 asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS];
633 /* Handle the import and export files, if any. */
634 for (fl = import_files; fl != NULL; fl = fl->next)
635 gld${EMULATION_NAME}_read_file (fl->name, true);
636 for (el = export_symbols; el != NULL; el = el->next)
638 struct bfd_link_hash_entry *h;
640 h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
642 einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
643 if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall))
644 einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
647 /* Track down all relocations called for by the linker script (these
648 are typically constructor/destructor entries created by
649 CONSTRUCTORS) and let the backend know it will need to create
650 .loader relocs for them. */
651 lang_for_each_statement (gld${EMULATION_NAME}_find_relocs);
653 /* We need to build LIBPATH from the -L arguments. If any -rpath
654 arguments were used, though, we use -rpath instead, as a GNU
656 if (command_line.rpath != NULL)
657 libpath = command_line.rpath;
658 else if (search_head == NULL)
659 libpath = (char *) "";
663 search_dirs_type *search;
665 len = strlen (search_head->name);
666 libpath = xmalloc (len + 1);
667 strcpy (libpath, search_head->name);
668 for (search = search_head->next; search != NULL; search = search->next)
672 nlen = strlen (search->name);
673 libpath = xrealloc (libpath, len + nlen + 2);
675 strcpy (libpath + len + 1, search->name);
680 /* Let the XCOFF backend set up the .loader section. */
681 if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
682 entry_symbol, file_align,
684 gc && ! unix_ld ? true : false,
686 textro ? true : false,
689 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
691 /* Look through the special sections, and put them in the right
692 place in the link ordering. This is especially magic. */
693 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
696 lang_output_section_statement_type *os;
697 lang_statement_union_type **pls;
698 lang_input_section_type *is;
702 sec = special_sections[i];
706 /* Remove this section from the list of the output section.
707 This assumes we know what the script looks like. */
709 os = lang_output_section_find (sec->output_section->name);
711 einfo ("%P%F: can't find output section %s\n",
712 sec->output_section->name);
715 for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next)
718 if ((*pls)->header.type == lang_input_section_enum &&
719 (*pls)->input_section.section == sec)
721 is = (lang_input_section_type *) *pls;
722 *pls = (*pls)->header.next;
726 if ((*pls)->header.type == lang_wild_statement_enum)
728 lang_statement_union_type **pwls;
730 for (pwls = &(*pls)->wild_statement.children.head;
732 pwls = &(*pwls)->header.next)
735 if ((*pwls)->header.type == lang_input_section_enum &&
736 (*pwls)->input_section.section == sec)
739 is = (lang_input_section_type *) *pwls;
740 *pwls = (*pwls)->header.next;
752 einfo ("%P%F: can't find %s in output section\n",
753 bfd_get_section_name (sec->owner, sec));
756 /* Now figure out where the section should go. */
760 default: /* to avoid warnings */
761 case XCOFF_SPECIAL_SECTION_TEXT:
767 case XCOFF_SPECIAL_SECTION_ETEXT:
773 case XCOFF_SPECIAL_SECTION_DATA:
779 case XCOFF_SPECIAL_SECTION_EDATA:
785 case XCOFF_SPECIAL_SECTION_END:
786 case XCOFF_SPECIAL_SECTION_END2:
793 os = lang_output_section_find (oname);
797 is->header.next = os->children.head;
798 os->children.head = (lang_statement_union_type *) is;
802 is->header.next = NULL;
803 lang_statement_append (&os->children,
804 (lang_statement_union_type *) is,
810 static int change_symbol_mode (char *input)
817 char *symbol_mode_string[] = {
827 for (bit = 0; ; bit++)
829 string = symbol_mode_string[bit];
833 if (0 == strcmp (input, string))
835 symbol_mode = (1 << bit);
839 /* should not be here */
844 static int is_syscall (char *input)
849 * -1 : error, try something else
854 char *syscall_string[] = {
857 "svc3264", /* 0x04 */
859 "syscall", /* 0x10 */
860 "syscall32", /* 0x20 */
861 "syscall3264", /* 0x40 */
862 "syscall64", /* 0x80 */
866 for (bit = 0; ;bit++)
869 string = syscall_string[bit];
875 if (0 == strcmp (input, string))
877 if (1 << bit & ${SYSCALL_MASK})
887 /* should not be here */
892 /* Read an import or export file. For an import file, this is called
893 by the before_allocation emulation routine. For an export file,
894 this is called by the parse_args emulation routine. */
897 gld${EMULATION_NAME}_read_file (filename, import)
898 const char *filename;
908 const char *impmember;
910 o = (struct obstack *) xmalloc (sizeof (struct obstack));
911 obstack_specify_allocation (o, 0, 0, xmalloc, gld${EMULATION_NAME}_free);
913 f = fopen (filename, FOPEN_RT);
916 bfd_set_error (bfd_error_system_call);
917 einfo ("%F%s: %E\n", filename);
929 * default to 32 and 64 bit mode
930 * symbols at top of /lib/syscalls.exp do not have a mode modifier and they
931 * are not repeated, assume 64 bit routines also want to use them.
932 * See the routine change_symbol_mode for more information.
936 while ((c = getc (f)) != EOF)
942 struct bfd_link_hash_entry *h;
946 obstack_1grow (o, c);
950 obstack_1grow (o, '\0');
953 s = (char *) obstack_base (o);
954 while (isspace ((unsigned char) *s))
958 || change_symbol_mode (s)
959 || (*s == '#' && s[1] == ' ')
960 || (! import && *s == '#' && s[1] == '!'))
962 obstack_free (o, obstack_base (o));
966 if (*s == '#' && s[1] == '!')
969 while (isspace ((unsigned char) *s))
976 obstack_free (o, obstack_base (o));
979 einfo ("%F%s%d: #! ([member]) is not supported in import files\n",
986 (void) obstack_finish (o);
990 while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0')
1000 if (imppath == file - 1)
1010 while (isspace ((unsigned char) cs))
1019 einfo ("%s:%d: warning: syntax error in import file\n",
1026 while (*s != ')' && *s != '\0')
1031 einfo ("%s:%d: warning: syntax error in import file\n",
1039 if (symbol_mode & ${SYMBOL_MODE_MASK})
1041 /* This is a symbol to be imported or exported. */
1044 address = (bfd_vma) -1;
1046 while (! isspace ((unsigned char) *s) && *s != '\0')
1054 while (isspace ((unsigned char) *s))
1058 while (! isspace ((unsigned char) *se) && *se != '\0')
1063 while (isspace ((unsigned char) *se))
1066 einfo ("%s%d: warning: syntax error in import/export file\n",
1075 status = is_syscall (s);
1080 /* this is a system call */
1085 /* ignore this system call */
1089 /* not a system call, check for address */
1090 address = strtoul (s, &end, 0);
1093 einfo ("%s:%d: warning: syntax error in import/export file\n",
1103 struct export_symbol_list *n;
1105 ldlang_add_undef (symname);
1106 n = ((struct export_symbol_list *)
1107 xmalloc (sizeof (struct export_symbol_list)));
1108 n->next = export_symbols;
1109 n->name = xstrdup (symname);
1110 n->syscall = syscall;
1115 h = bfd_link_hash_lookup (link_info.hash, symname, false, false,
1117 if (h == NULL || h->type == bfd_link_hash_new)
1119 /* We can just ignore attempts to import an unreferenced
1124 if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
1125 address, imppath, impfile,
1127 einfo ("%X%s:%d: failed to import symbol %s: %E\n",
1128 filename, lineno, symname);
1132 obstack_free (o, obstack_base (o));
1135 if (obstack_object_size (o) > 0)
1137 einfo ("%s:%d: warning: ignoring unterminated last line\n",
1139 obstack_free (o, obstack_base (o));
1144 obstack_free (o, NULL);
1149 /* This routine saves us from worrying about declaring free. */
1152 gld${EMULATION_NAME}_free (p)
1158 /* This is called by the before_allocation routine via
1159 lang_for_each_statement. It looks for relocations and assignments
1163 gld${EMULATION_NAME}_find_relocs (s)
1164 lang_statement_union_type *s;
1166 if (s->header.type == lang_reloc_statement_enum)
1168 lang_reloc_statement_type *rs;
1170 rs = &s->reloc_statement;
1171 if (rs->name == NULL)
1172 einfo ("%F%P: only relocations against symbols are permitted\n");
1173 if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
1174 einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
1177 if (s->header.type == lang_assignment_statement_enum)
1178 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1181 /* Look through an expression for an assignment statement. */
1184 gld${EMULATION_NAME}_find_exp_assignment (exp)
1187 struct bfd_link_hash_entry *h;
1189 switch (exp->type.node_class)
1192 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
1193 false, false, false);
1198 if (strcmp (exp->assign.dst, ".") != 0)
1200 if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info,
1202 einfo ("%P%F: failed to record assignment to %s: %E\n",
1205 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1209 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1210 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1214 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1215 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1216 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1220 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1229 gld${EMULATION_NAME}_get_script (isfile)
1233 if test -n "$COMPILE_IN"
1235 # Scripts compiled in.
1237 # sed commands to quote an ld script as a C string.
1238 sc="-f ${srcdir}/emultempl/ostring.sed"
1240 cat >>e${EMULATION_NAME}.c <<EOF
1244 if (link_info.relocateable == true && config.build_constructors == true)
1247 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1248 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1249 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
1250 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
1251 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
1252 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
1253 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
1254 echo ' ; else return' >> e${EMULATION_NAME}.c
1255 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1256 echo '; }' >> e${EMULATION_NAME}.c
1259 # Scripts read from the filesystem.
1261 cat >>e${EMULATION_NAME}.c <<EOF
1265 if (link_info.relocateable == true && config.build_constructors == true)
1266 return "ldscripts/${EMULATION_NAME}.xu";
1267 else if (link_info.relocateable == true)
1268 return "ldscripts/${EMULATION_NAME}.xr";
1269 else if (!config.text_read_only)
1270 return "ldscripts/${EMULATION_NAME}.xbn";
1271 else if (!config.magic_demand_paged)
1272 return "ldscripts/${EMULATION_NAME}.xn";
1274 return "ldscripts/${EMULATION_NAME}.x";
1280 cat >>e${EMULATION_NAME}.c <<EOF
1282 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1284 gld${EMULATION_NAME}_before_parse,
1287 after_parse_default,
1288 gld${EMULATION_NAME}_after_open,
1289 after_allocation_default,
1290 set_output_arch_default,
1291 ldemul_default_target,
1292 gld${EMULATION_NAME}_before_allocation,
1293 gld${EMULATION_NAME}_get_script,
1294 "${EMULATION_NAME}",
1297 0, /* create_output_section_statements */
1298 0, /* open_dynamic_archive */
1299 0, /* place_orphan */
1300 0, /* set_symbols */
1301 gld${EMULATION_NAME}_parse_args,
1302 gld${EMULATION_NAME}_unrecognized_file,
1303 NULL, /* list_options */
1304 NULL, /* recognized_file */
1305 NULL, /* find potential_libraries */