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));
68 static boolean gld${EMULATION_NAME}_unrecognized_file
69 PARAMS ((lang_input_statement_type *));
71 /* The file alignment required for each section. */
72 static unsigned long file_align;
74 /* The maximum size the stack is permitted to grow. This is stored in
76 static unsigned long maxstack;
78 /* The maximum data size. This is stored in the a.out header. */
79 static unsigned long maxdata;
81 /* Whether to perform garbage collection. */
84 /* The module type to use. */
85 static unsigned short modtype = ('1' << 8) | 'L';
87 /* Whether the .text section must be read-only (i.e., no relocs
91 /* Whether to implement Unix like linker semantics. */
94 /* Structure used to hold import file list. */
98 struct filelist *next;
102 /* List of import files. */
103 static struct filelist *import_files;
105 /* List of export symbols read from the export files. */
107 struct export_symbol_list
109 struct export_symbol_list *next;
113 static struct export_symbol_list *export_symbols;
115 /* Maintains the 32 or 64 bit mode state of import file */
116 static unsigned int symbol_mode = 0x04;
118 /* This routine is called before anything else is done. */
121 gld${EMULATION_NAME}_before_parse ()
123 #ifndef TARGET_ /* I.e., if not generic. */
124 const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
127 ldfile_output_architecture = arch->arch;
128 ldfile_output_machine = arch->mach;
129 ldfile_output_machine_name = arch->printable_name;
132 ldfile_output_architecture = bfd_arch_${ARCH};
133 #endif /* not TARGET_ */
134 config.has_shared = true;
137 * The link_info.[init|fini]_functions are initialized in ld/lexsup.c.
138 * Override them here so we can use the link_info.init_function as a
139 * state flag that lets the backend know that -binitfini has been done.
141 link_info.init_function = NULL;
142 link_info.fini_function = NULL;
146 /* Handle AIX specific options. */
149 gld${EMULATION_NAME}_parse_args (argc, argv)
153 int prevoptind = optind;
154 int prevopterr = opterr;
182 b64 is an empty option. The native linker uses -b64 for xcoff64 support
183 Our linker uses -m aixppc64 for xcoff64 support. The choice for the
184 correct emulation is done in collect2.c via the environmental varible
187 binitfini has special handling in the linker backend. The native linker
188 uses the arguemnts to generate a table of init and fini functions for
189 the executable. The important use for this option is to support aix 4.2+
190 c++ constructors and destructors. This is tied into gcc via collect2.c.
191 The function table is accessed by the runtime linker/loader by checking if
192 the first symbol in the loader symbol table is "__rtinit". The native
193 linker generates this table and the loader symbol. The gnu linker looks
194 for the symbol "__rtinit" and makes it the first loader symbol. It is the
195 responsiblity of the user to define the __rtinit symbol. The format for
196 __rtinit is given by the aix system file /usr/include/rtinit.h. You can
197 look at collect2.c to see an example of how this is done for 32 and 64 bit.
198 Below is an exmaple of a 32 bit assembly file that defines __rtinit.
204 .extern init_function
205 .extern fini_function
213 f1i: .long init_function
219 f1f: .long fini_function
226 s1i: .string "init_function"
228 s1f: .string "fini_function"
232 static const struct option longopts[] = {
233 {"basis", no_argument, NULL, OPTION_IGNORE},
234 {"bautoimp", no_argument, NULL, OPTION_AUTOIMP},
235 {"bcomprld", no_argument, NULL, OPTION_IGNORE},
236 {"bcrld", no_argument, NULL, OPTION_IGNORE},
237 {"bcror31", no_argument, NULL, OPTION_IGNORE},
238 {"bD", required_argument, NULL, OPTION_MAXDATA},
239 {"bE", required_argument, NULL, OPTION_EXPORT},
240 {"bernotok", no_argument, NULL, OPTION_ERNOTOK},
241 {"berok", no_argument, NULL, OPTION_EROK},
242 {"berrmsg", no_argument, NULL, OPTION_IGNORE},
243 {"bexport", required_argument, NULL, OPTION_EXPORT},
244 {"bf", no_argument, NULL, OPTION_ERNOTOK},
245 {"bgc", no_argument, &gc, 1},
246 {"bh", required_argument, NULL, OPTION_IGNORE},
247 {"bhalt", required_argument, NULL, OPTION_IGNORE},
248 {"bI", required_argument, NULL, OPTION_IMPORT},
249 {"bimport", required_argument, NULL, OPTION_IMPORT},
250 {"binitfini", required_argument, NULL, OPTION_INITFINI},
251 {"bl", required_argument, NULL, OPTION_LOADMAP},
252 {"bloadmap", required_argument, NULL, OPTION_LOADMAP},
253 {"bmaxdata", required_argument, NULL, OPTION_MAXDATA},
254 {"bmaxstack", required_argument, NULL, OPTION_MAXSTACK},
255 {"bM", required_argument, NULL, OPTION_MODTYPE},
256 {"bmodtype", required_argument, NULL, OPTION_MODTYPE},
257 {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP},
258 {"bnodelcsect", no_argument, NULL, OPTION_IGNORE},
259 {"bnoentry", no_argument, NULL, OPTION_IGNORE},
260 {"bnogc", no_argument, &gc, 0},
261 {"bnso", no_argument, NULL, OPTION_NOAUTOIMP},
262 {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT},
263 {"bnotextro", no_argument, &textro, 0},
264 {"bnro", no_argument, &textro, 0},
265 {"bpD", required_argument, NULL, OPTION_PD},
266 {"bpT", required_argument, NULL, OPTION_PT},
267 {"bro", no_argument, &textro, 1},
268 {"bS", required_argument, NULL, OPTION_MAXSTACK},
269 {"bso", no_argument, NULL, OPTION_AUTOIMP},
270 {"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT},
271 {"btextro", no_argument, &textro, 1},
272 {"b64", no_argument, NULL, 0},
273 {"static", no_argument, NULL, OPTION_NOAUTOIMP},
274 {"unix", no_argument, NULL, OPTION_UNIX},
275 {NULL, no_argument, NULL, 0}
278 /* Options supported by the AIX linker which we do not support: -f,
279 -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps,
280 -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl,
281 -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl,
282 -bnobind, -bnocomprld, -bnocrld, -bnoerrmsg, -bnoglink,
283 -bnoloadmap, -bnl, -bnoobjreorder, -bnoquiet, -bnoreorder,
284 -bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk,
287 /* If the current option starts with -b, change the first : to an =.
288 The AIX linker uses : to separate the option from the argument;
289 changing it to = lets us treat it as a getopt option. */
296 if (indx < argc && strncmp (argv[indx], "-b", 2) == 0)
300 for (s = argv[indx]; *s != '\0'; s++)
311 /* We add s and u so to the short options list so that -s and -u on
312 the command line do not match -static and -unix. */
315 optc = getopt_long_only (argc, argv, "-D:H:KT:zsu", longopts, &longind);
327 /* Long option which just sets a flag. */
331 val = strtoll (optarg, &end, 0);
333 einfo ("%P: warning: ignoring invalid -D number %s\n", optarg);
335 lang_section_start (".data", exp_intop (val));
339 val = strtoul (optarg, &end, 0);
341 || (val & (val - 1)) != 0)
342 einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
349 /* FIXME: This should use the page size for the target system. */
354 /* On AIX this is the same as GNU ld -Ttext. When we see -T
355 number, we assume the AIX option is intended. Otherwise, we
356 assume the usual GNU ld -T option is intended. We can't just
357 ignore the AIX option, because gcc passes it to the linker. */
358 val = strtoull (optarg, &end, 0);
364 lang_section_start (".text", exp_intop (val));
370 case OPTION_INITFINI:
373 * The aix linker init fini has the format :
375 * -binitfini:[ Initial][:Termination][:Priority]
377 * it allows the Termination and Priority to be optional.
379 * Since we support only one init/fini pair, we ignore the Priority.
381 * Define the special symbol __rtinit.
383 * strtok does not correctly handle the case of -binitfini::fini: so
389 while (*t && ':' != *t)
396 link_info.init_function = i;
400 while (*t && ':' != *t)
406 link_info.fini_function = f;
412 link_info.static_link = false;
416 force_make_executable = false;
420 force_make_executable = true;
424 gld${EMULATION_NAME}_read_file (optarg, false);
430 struct filelist **flpp;
432 n = (struct filelist *) xmalloc (sizeof (struct filelist));
435 flpp = &import_files;
436 while (*flpp != NULL)
437 flpp = &(*flpp)->next;
443 config.map_filename = optarg;
447 val = strtoull (optarg, &end, 0);
449 einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n", optarg);
454 case OPTION_MAXSTACK:
455 val = strtoull (optarg, &end, 0);
457 einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n", optarg);
465 link_info.shared = true;
468 if (*optarg == '\0' || optarg[1] == '\0')
469 einfo ("%P: warning: ignoring invalid module type %s\n", optarg);
471 modtype = (*optarg << 8) | optarg[1];
474 case OPTION_NOAUTOIMP:
475 link_info.static_link = true;
478 case OPTION_NOSTRCMPCT:
479 link_info.traditional_format = true;
483 /* This sets the page that the .data section is supposed to
484 start on. The offset within the page should still be the
485 offset within the file, so we need to build an appropriate
487 val = strtoull (optarg, &end, 0);
489 einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg);
497 exp_nameop (NAME, "."),
500 exp_binop ('+', t, exp_intop (31)),
501 exp_intop (~ (bfd_vma) 31));
502 lang_section_start (".data", t);
507 /* This set the page that the .text section is supposed to start
508 on. The offset within the page should still be the offset
510 val = strtoull (optarg, &end, 0);
512 einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg);
519 exp_nameop (SIZEOF_HEADERS, NULL));
521 exp_binop ('+', t, exp_intop (31)),
522 exp_intop (~ (bfd_vma) 31));
523 lang_section_start (".text", t);
527 case OPTION_STRCMPCT:
528 link_info.traditional_format = false;
539 /* This is called when an input file can not be recognized as a BFD
540 object or an archive. If the file starts with #!, we must treat it
541 as an import file. This is for AIX compatibility. */
544 gld${EMULATION_NAME}_unrecognized_file (entry)
545 lang_input_statement_type *entry;
550 e = fopen (entry->filename, FOPEN_RT);
556 if (getc (e) == '#' && getc (e) == '!')
559 struct filelist **flpp;
561 n = (struct filelist *) xmalloc (sizeof (struct filelist));
563 n->name = entry->filename;
564 flpp = &import_files;
565 while (*flpp != NULL)
566 flpp = &(*flpp)->next;
570 entry->loaded = true;
578 /* This is called after the input files have been opened. */
581 gld${EMULATION_NAME}_after_open ()
586 /* Call ldctor_build_sets, after pretending that this is a
587 relocateable link. We do this because AIX requires relocation
588 entries for all references to symbols, even in a final
589 executable. Of course, we only want to do this if we are
590 producing an XCOFF output file. */
591 r = link_info.relocateable;
592 if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL)
593 link_info.relocateable = true;
594 ldctor_build_sets ();
595 link_info.relocateable = r;
597 /* For each set, record the size, so that the XCOFF backend can
598 output the correct csect length. */
599 for (p = sets; p != (struct set_info *) NULL; p = p->next)
603 /* If the symbol is defined, we may have been invoked from
604 collect, and the sets may already have been built, so we do
606 if (p->h->type == bfd_link_hash_defined
607 || p->h->type == bfd_link_hash_defweak)
610 if (p->reloc != BFD_RELOC_CTOR)
612 /* Handle this if we need to. */
616 size = (p->count + 2) * 4;
617 if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
618 einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
622 /* This is called after the sections have been attached to output
623 sections, but before any sizes or addresses have been set. */
626 gld${EMULATION_NAME}_before_allocation ()
629 struct export_symbol_list *el;
631 asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS];
634 /* Handle the import and export files, if any. */
635 for (fl = import_files; fl != NULL; fl = fl->next)
636 gld${EMULATION_NAME}_read_file (fl->name, true);
637 for (el = export_symbols; el != NULL; el = el->next)
639 struct bfd_link_hash_entry *h;
641 h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
643 einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
644 if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h))
645 einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
648 /* Track down all relocations called for by the linker script (these
649 are typically constructor/destructor entries created by
650 CONSTRUCTORS) and let the backend know it will need to create
651 .loader relocs for them. */
652 lang_for_each_statement (gld${EMULATION_NAME}_find_relocs);
654 /* We need to build LIBPATH from the -L arguments. If any -rpath
655 arguments were used, though, we use -rpath instead, as a GNU
657 if (command_line.rpath != NULL)
658 libpath = command_line.rpath;
659 else if (search_head == NULL)
660 libpath = (char *) "";
664 search_dirs_type *search;
666 len = strlen (search_head->name);
667 libpath = xmalloc (len + 1);
668 strcpy (libpath, search_head->name);
669 for (search = search_head->next; search != NULL; search = search->next)
673 nlen = strlen (search->name);
674 libpath = xrealloc (libpath, len + nlen + 2);
676 strcpy (libpath + len + 1, search->name);
681 /* Let the XCOFF backend set up the .loader section. */
682 if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
683 entry_symbol, file_align,
685 gc && ! unix_ld ? true : false,
687 textro ? true : false,
690 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
692 /* Look through the special sections, and put them in the right
693 place in the link ordering. This is especially magic. */
694 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
697 lang_output_section_statement_type *os;
698 lang_statement_union_type **pls;
699 lang_input_section_type *is;
703 sec = special_sections[i];
707 /* Remove this section from the list of the output section.
708 This assumes we know what the script looks like. */
710 os = lang_output_section_find (sec->output_section->name);
712 einfo ("%P%F: can't find output section %s\n",
713 sec->output_section->name);
716 for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next)
719 if ((*pls)->header.type == lang_input_section_enum &&
720 (*pls)->input_section.section == sec)
722 is = (lang_input_section_type *) *pls;
723 *pls = (*pls)->header.next;
727 if ((*pls)->header.type == lang_wild_statement_enum)
729 lang_statement_union_type **pwls;
731 for (pwls = &(*pls)->wild_statement.children.head;
733 pwls = &(*pwls)->header.next)
736 if ((*pwls)->header.type == lang_input_section_enum &&
737 (*pwls)->input_section.section == sec)
740 is = (lang_input_section_type *) *pwls;
741 *pwls = (*pwls)->header.next;
753 einfo ("%P%F: can't find %s in output section\n",
754 bfd_get_section_name (sec->owner, sec));
757 /* Now figure out where the section should go. */
761 default: /* to avoid warnings */
762 case XCOFF_SPECIAL_SECTION_TEXT:
768 case XCOFF_SPECIAL_SECTION_ETEXT:
774 case XCOFF_SPECIAL_SECTION_DATA:
780 case XCOFF_SPECIAL_SECTION_EDATA:
786 case XCOFF_SPECIAL_SECTION_END:
787 case XCOFF_SPECIAL_SECTION_END2:
794 os = lang_output_section_find (oname);
798 is->header.next = os->children.head;
799 os->children.head = (lang_statement_union_type *) is;
803 is->header.next = NULL;
804 lang_statement_append (&os->children,
805 (lang_statement_union_type *) is,
811 static int change_symbol_mode (char *input)
818 char *symbol_mode_string[] = {
828 for (bit = 0; ; bit++)
830 string = symbol_mode_string[bit];
834 if (0 == strcmp (input, string))
836 symbol_mode = (1 << bit);
840 /* should not be here */
844 static int is_syscall(char *input, unsigned int *flag)
849 * -1 : error, try something else
855 char *syscall_string;
858 { "svc" /* 0x01 */, XCOFF_SYSCALL32 },
859 { "svc32" /* 0x02 */, XCOFF_SYSCALL32 },
860 { "svc3264" /* 0x04 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
861 { "svc64" /* 0x08 */, XCOFF_SYSCALL64 },
862 { "syscall" /* 0x10 */, XCOFF_SYSCALL32 },
863 { "syscall32" /* 0x20 */, XCOFF_SYSCALL32 },
864 { "syscall3264" /* 0x40 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
865 { "syscall64" /* 0x80 */, XCOFF_SYSCALL64 },
871 for (bit = 0; ;bit++) {
873 string = s[bit].syscall_string;
874 if (NULL == string) {
878 if (0 == strcmp(input, string)) {
879 if (1 << bit & ${SYSCALL_MASK}) {
887 /* should not be here */
891 /* Read an import or export file. For an import file, this is called
892 by the before_allocation emulation routine. For an export file,
893 this is called by the parse_args emulation routine. */
896 gld${EMULATION_NAME}_read_file (filename, import)
897 const char *filename;
907 const char *impmember;
909 o = (struct obstack *) xmalloc (sizeof (struct obstack));
910 obstack_specify_allocation (o, 0, 0, xmalloc, gld${EMULATION_NAME}_free);
912 f = fopen (filename, FOPEN_RT);
915 bfd_set_error (bfd_error_system_call);
916 einfo ("%F%s: %E\n", filename);
928 * default to 32 and 64 bit mode
929 * symbols at top of /lib/syscalls.exp do not have a mode modifier and they
930 * are not repeated, assume 64 bit routines also want to use them.
931 * See the routine change_symbol_mode for more information.
935 while ((c = getc (f)) != EOF)
939 unsigned int syscall_flag = 0;
941 struct bfd_link_hash_entry *h;
945 obstack_1grow (o, c);
949 obstack_1grow (o, '\0');
952 s = (char *) obstack_base (o);
953 while (isspace ((unsigned char) *s))
957 || change_symbol_mode (s)
958 || (*s == '#' && s[1] == ' ')
959 || (! import && *s == '#' && s[1] == '!'))
961 obstack_free (o, obstack_base (o));
965 if (*s == '#' && s[1] == '!')
968 while (isspace ((unsigned char) *s))
975 obstack_free (o, obstack_base (o));
978 einfo ("%F%s%d: #! ([member]) is not supported in import files\n",
985 (void) obstack_finish (o);
989 while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0')
999 if (imppath == file - 1)
1009 while (isspace ((unsigned char) cs))
1018 einfo ("%s:%d: warning: syntax error in import file\n",
1025 while (*s != ')' && *s != '\0')
1030 einfo ("%s:%d: warning: syntax error in import file\n",
1038 if (symbol_mode & ${SYMBOL_MODE_MASK})
1040 /* This is a symbol to be imported or exported. */
1043 address = (bfd_vma) -1;
1045 while (! isspace ((unsigned char) *s) && *s != '\0')
1053 while (isspace ((unsigned char) *s))
1057 while (! isspace ((unsigned char) *se) && *se != '\0')
1062 while (isspace ((unsigned char) *se))
1065 einfo ("%s%d: warning: syntax error in import/export file\n",
1074 status = is_syscall(s, &syscall_flag);
1077 /* not a system call, check for address */
1078 address = strtoul (s, &end, 0);
1080 /* not a system call, check for address */
1081 address = strtoul (s, &end, 0);
1084 einfo ("%s:%d: warning: syntax error in import/export file\n",
1094 struct export_symbol_list *n;
1096 ldlang_add_undef (symname);
1097 n = ((struct export_symbol_list *)
1098 xmalloc (sizeof (struct export_symbol_list)));
1099 n->next = export_symbols;
1100 n->name = xstrdup (symname);
1105 h = bfd_link_hash_lookup (link_info.hash, symname, false, false,
1107 if (h == NULL || h->type == bfd_link_hash_new)
1109 /* We can just ignore attempts to import an unreferenced
1114 if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
1115 address, imppath, impfile,
1116 impmember, syscall_flag))
1117 einfo ("%X%s:%d: failed to import symbol %s: %E\n",
1118 filename, lineno, symname);
1122 obstack_free (o, obstack_base (o));
1125 if (obstack_object_size (o) > 0)
1127 einfo ("%s:%d: warning: ignoring unterminated last line\n",
1129 obstack_free (o, obstack_base (o));
1134 obstack_free (o, NULL);
1139 /* This routine saves us from worrying about declaring free. */
1142 gld${EMULATION_NAME}_free (p)
1148 /* This is called by the before_allocation routine via
1149 lang_for_each_statement. It looks for relocations and assignments
1153 gld${EMULATION_NAME}_find_relocs (s)
1154 lang_statement_union_type *s;
1156 if (s->header.type == lang_reloc_statement_enum)
1158 lang_reloc_statement_type *rs;
1160 rs = &s->reloc_statement;
1161 if (rs->name == NULL)
1162 einfo ("%F%P: only relocations against symbols are permitted\n");
1163 if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
1164 einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
1167 if (s->header.type == lang_assignment_statement_enum)
1168 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1171 /* Look through an expression for an assignment statement. */
1174 gld${EMULATION_NAME}_find_exp_assignment (exp)
1177 struct bfd_link_hash_entry *h;
1179 switch (exp->type.node_class)
1182 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
1183 false, false, false);
1188 if (strcmp (exp->assign.dst, ".") != 0)
1190 if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info,
1192 einfo ("%P%F: failed to record assignment to %s: %E\n",
1195 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1199 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1200 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1204 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1205 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1206 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1210 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1219 gld${EMULATION_NAME}_get_script (isfile)
1223 if test -n "$COMPILE_IN"
1225 # Scripts compiled in.
1227 # sed commands to quote an ld script as a C string.
1228 sc="-f ${srcdir}/emultempl/ostring.sed"
1230 cat >>e${EMULATION_NAME}.c <<EOF
1234 if (link_info.relocateable == true && config.build_constructors == true)
1237 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1238 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1239 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
1240 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
1241 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
1242 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
1243 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
1244 echo ' ; else return' >> e${EMULATION_NAME}.c
1245 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1246 echo '; }' >> e${EMULATION_NAME}.c
1249 # Scripts read from the filesystem.
1251 cat >>e${EMULATION_NAME}.c <<EOF
1255 if (link_info.relocateable == true && config.build_constructors == true)
1256 return "ldscripts/${EMULATION_NAME}.xu";
1257 else if (link_info.relocateable == true)
1258 return "ldscripts/${EMULATION_NAME}.xr";
1259 else if (!config.text_read_only)
1260 return "ldscripts/${EMULATION_NAME}.xbn";
1261 else if (!config.magic_demand_paged)
1262 return "ldscripts/${EMULATION_NAME}.xn";
1264 return "ldscripts/${EMULATION_NAME}.x";
1270 cat >>e${EMULATION_NAME}.c <<EOF
1272 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1274 gld${EMULATION_NAME}_before_parse,
1277 after_parse_default,
1278 gld${EMULATION_NAME}_after_open,
1279 after_allocation_default,
1280 set_output_arch_default,
1281 ldemul_default_target,
1282 gld${EMULATION_NAME}_before_allocation,
1283 gld${EMULATION_NAME}_get_script,
1284 "${EMULATION_NAME}",
1287 0, /* create_output_section_statements */
1288 0, /* open_dynamic_archive */
1289 0, /* place_orphan */
1290 0, /* set_symbols */
1291 gld${EMULATION_NAME}_parse_args,
1292 gld${EMULATION_NAME}_unrecognized_file,
1293 NULL, /* list_options */
1294 NULL, /* recognized_file */
1295 NULL, /* find potential_libraries */