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. */
294 if (indx < argc && strncmp (argv[indx], "-b", 2) == 0) {
297 for (s = argv[indx]; *s != '\0'; s++) {
306 /* We add s and u so to the short options list so that -s and -u on
307 the command line do not match -static and -unix. */
310 optc = getopt_long_only (argc, argv, "-D:H:KT:zsu", longopts, &longind);
322 /* Long option which just sets a flag. */
326 val = strtoll (optarg, &end, 0);
328 einfo ("%P: warning: ignoring invalid -D number %s\n", optarg);
330 lang_section_start (".data", exp_intop (val));
334 val = strtoul (optarg, &end, 0);
336 || (val & (val - 1)) != 0)
337 einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
344 /* FIXME: This should use the page size for the target system. */
349 /* On AIX this is the same as GNU ld -Ttext. When we see -T
350 number, we assume the AIX option is intended. Otherwise, we
351 assume the usual GNU ld -T option is intended. We can't just
352 ignore the AIX option, because gcc passes it to the linker. */
353 val = strtoull (optarg, &end, 0);
359 lang_section_start (".text", exp_intop (val));
365 case OPTION_INITFINI: {
367 * The aix linker init fini has the format :
369 * -binitfini:[ Initial][:Termination][:Priority]
371 * it allows the Termination and Priority to be optional.
373 * Since we support only one init/fini pair, we ignore the Priority.
375 * Define the special symbol __rtinit.
377 * strtok does not correctly handle the case of -binitfini::fini: so
383 while (*t && ':' != *t) t++;
386 if (0 != strlen(i)) {
387 link_info.init_function = i;
391 while (*t && ':' != *t) t++;
394 if (0 != strlen(f)) {
395 link_info.fini_function = f;
401 link_info.static_link = false;
405 force_make_executable = false;
409 force_make_executable = true;
413 gld${EMULATION_NAME}_read_file (optarg, false);
419 struct filelist **flpp;
421 n = (struct filelist *) xmalloc (sizeof (struct filelist));
424 flpp = &import_files;
425 while (*flpp != NULL)
426 flpp = &(*flpp)->next;
432 config.map_filename = optarg;
436 val = strtoull (optarg, &end, 0);
438 einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n",
444 case OPTION_MAXSTACK:
445 val = strtoull (optarg, &end, 0);
447 einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n",
456 link_info.shared = true;
459 if (*optarg == '\0' || optarg[1] == '\0')
460 einfo ("%P: warning: ignoring invalid module type %s\n", optarg);
462 modtype = (*optarg << 8) | optarg[1];
465 case OPTION_NOAUTOIMP:
466 link_info.static_link = true;
469 case OPTION_NOSTRCMPCT:
470 link_info.traditional_format = true;
474 /* This sets the page that the .data section is supposed to
475 start on. The offset within the page should still be the
476 offset within the file, so we need to build an appropriate
478 val = strtoull (optarg, &end, 0);
480 einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg);
488 exp_nameop (NAME, "."),
491 exp_binop ('+', t, exp_intop (31)),
492 exp_intop (~ (bfd_vma) 31));
493 lang_section_start (".data", t);
498 /* This set the page that the .text section is supposed to start
499 on. The offset within the page should still be the offset
501 val = strtoull (optarg, &end, 0);
503 einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg);
510 exp_nameop (SIZEOF_HEADERS, NULL));
512 exp_binop ('+', t, exp_intop (31)),
513 exp_intop (~ (bfd_vma) 31));
514 lang_section_start (".text", t);
518 case OPTION_STRCMPCT:
519 link_info.traditional_format = false;
530 /* This is called when an input file can not be recognized as a BFD
531 object or an archive. If the file starts with #!, we must treat it
532 as an import file. This is for AIX compatibility. */
535 gld${EMULATION_NAME}_unrecognized_file (entry)
536 lang_input_statement_type *entry;
541 e = fopen (entry->filename, FOPEN_RT);
547 if (getc (e) == '#' && getc (e) == '!')
550 struct filelist **flpp;
552 n = (struct filelist *) xmalloc (sizeof (struct filelist));
554 n->name = entry->filename;
555 flpp = &import_files;
556 while (*flpp != NULL)
557 flpp = &(*flpp)->next;
561 entry->loaded = true;
569 /* This is called after the input files have been opened. */
572 gld${EMULATION_NAME}_after_open ()
577 /* Call ldctor_build_sets, after pretending that this is a
578 relocateable link. We do this because AIX requires relocation
579 entries for all references to symbols, even in a final
580 executable. Of course, we only want to do this if we are
581 producing an XCOFF output file. */
582 r = link_info.relocateable;
583 if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL)
584 link_info.relocateable = true;
585 ldctor_build_sets ();
586 link_info.relocateable = r;
588 /* For each set, record the size, so that the XCOFF backend can
589 output the correct csect length. */
590 for (p = sets; p != (struct set_info *) NULL; p = p->next)
594 /* If the symbol is defined, we may have been invoked from
595 collect, and the sets may already have been built, so we do
597 if (p->h->type == bfd_link_hash_defined
598 || p->h->type == bfd_link_hash_defweak)
601 if (p->reloc != BFD_RELOC_CTOR)
603 /* Handle this if we need to. */
607 size = (p->count + 2) * 4;
608 if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
609 einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
613 /* This is called after the sections have been attached to output
614 sections, but before any sizes or addresses have been set. */
617 gld${EMULATION_NAME}_before_allocation ()
620 struct export_symbol_list *el;
622 asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS];
625 /* Handle the import and export files, if any. */
626 for (fl = import_files; fl != NULL; fl = fl->next)
627 gld${EMULATION_NAME}_read_file (fl->name, true);
628 for (el = export_symbols; el != NULL; el = el->next) {
629 struct bfd_link_hash_entry *h;
631 h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
633 einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
634 if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall))
635 einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
638 /* Track down all relocations called for by the linker script (these
639 are typically constructor/destructor entries created by
640 CONSTRUCTORS) and let the backend know it will need to create
641 .loader relocs for them. */
642 lang_for_each_statement (gld${EMULATION_NAME}_find_relocs);
644 /* We need to build LIBPATH from the -L arguments. If any -rpath
645 arguments were used, though, we use -rpath instead, as a GNU
647 if (command_line.rpath != NULL)
648 libpath = command_line.rpath;
649 else if (search_head == NULL)
650 libpath = (char *) "";
654 search_dirs_type *search;
656 len = strlen (search_head->name);
657 libpath = xmalloc (len + 1);
658 strcpy (libpath, search_head->name);
659 for (search = search_head->next; search != NULL; search = search->next)
663 nlen = strlen (search->name);
664 libpath = xrealloc (libpath, len + nlen + 2);
666 strcpy (libpath + len + 1, search->name);
671 /* Let the XCOFF backend set up the .loader section. */
672 if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
673 entry_symbol, file_align,
675 gc && ! unix_ld ? true : false,
677 textro ? true : false,
680 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
682 /* Look through the special sections, and put them in the right
683 place in the link ordering. This is especially magic. */
684 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) {
686 lang_output_section_statement_type *os;
687 lang_statement_union_type **pls;
688 lang_input_section_type *is;
692 sec = special_sections[i];
696 /* Remove this section from the list of the output section.
697 This assumes we know what the script looks like. */
699 os = lang_output_section_find (sec->output_section->name);
701 einfo ("%P%F: can't find output section %s\n",
702 sec->output_section->name);
705 for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->next) {
707 if ((*pls)->header.type == lang_input_section_enum &&
708 (*pls)->input_section.section == sec) {
709 is = (lang_input_section_type *) *pls;
714 if ((*pls)->header.type == lang_wild_statement_enum) {
715 lang_statement_union_type **pwls;
717 for (pwls = &(*pls)->wild_statement.children.head;
719 pwls = &(*pwls)->next) {
721 if ((*pwls)->header.type == lang_input_section_enum &&
722 (*pwls)->input_section.section == sec) {
724 is = (lang_input_section_type *) *pwls;
725 *pwls = (*pwls)->next;
736 einfo ("%P%F: can't find %s in output section\n",
737 bfd_get_section_name (sec->owner, sec));
740 /* Now figure out where the section should go. */
743 default: /* to avoid warnings */
744 case XCOFF_SPECIAL_SECTION_TEXT:
750 case XCOFF_SPECIAL_SECTION_ETEXT:
756 case XCOFF_SPECIAL_SECTION_DATA:
762 case XCOFF_SPECIAL_SECTION_EDATA:
768 case XCOFF_SPECIAL_SECTION_END:
769 case XCOFF_SPECIAL_SECTION_END2:
776 os = lang_output_section_find (oname);
779 is->header.next = os->children.head;
780 os->children.head = (lang_statement_union_type *) is;
782 is->header.next = NULL;
783 lang_statement_append (&os->children,
784 (lang_statement_union_type *) is,
790 static int change_symbol_mode (char *input)
797 char *symbol_mode_string[] = {
807 for (bit = 0; ; bit++) {
808 string = symbol_mode_string[bit];
812 if (0 == strcmp(input, string)) {
813 symbol_mode = (1 << bit);
817 /* should not be here */
822 static int is_syscall(char *input)
827 * -1 : error, try something else
832 char *syscall_string[] = {
835 "svc3264", /* 0x04 */
837 "syscall", /* 0x10 */
838 "syscall32", /* 0x20 */
839 "syscall3264", /* 0x40 */
840 "syscall64", /* 0x80 */
844 for (bit = 0; ;bit++) {
846 string = syscall_string[bit];
847 if (NULL == string) {
851 if (0 == strcmp(input, string)) {
852 if (1 << bit & ${SYSCALL_MASK}) {
859 /* should not be here */
864 /* Read an import or export file. For an import file, this is called
865 by the before_allocation emulation routine. For an export file,
866 this is called by the parse_args emulation routine. */
869 gld${EMULATION_NAME}_read_file (filename, import)
870 const char *filename;
880 const char *impmember;
882 o = (struct obstack *) xmalloc (sizeof (struct obstack));
883 obstack_specify_allocation (o, 0, 0, xmalloc, gld${EMULATION_NAME}_free);
885 f = fopen (filename, FOPEN_RT);
888 bfd_set_error (bfd_error_system_call);
889 einfo ("%F%s: %E\n", filename);
901 * default to 32 and 64 bit mode
902 * symbols at top of /lib/syscalls.exp do not have a mode modifier and they
903 * are not repeated, assume 64 bit routines also want to use them.
904 * See the routine change_symbol_mode for more information.
908 while ((c = getc (f)) != EOF)
914 struct bfd_link_hash_entry *h;
918 obstack_1grow (o, c);
922 obstack_1grow (o, '\0');
925 s = (char *) obstack_base (o);
926 while (isspace ((unsigned char) *s))
930 change_symbol_mode (s) ||
931 (*s == '#' && s[1] == ' ') ||
932 (! import && *s == '#' && s[1] == '!'))
934 obstack_free (o, obstack_base (o));
938 if (*s == '#' && s[1] == '!')
941 while (isspace ((unsigned char) *s))
948 obstack_free (o, obstack_base (o));
951 einfo ("%F%s%d: #! ([member]) is not supported in import files\n",
958 (void) obstack_finish (o);
962 while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0')
972 if (imppath == file - 1)
982 while (isspace ((unsigned char) cs))
991 einfo ("%s:%d: warning: syntax error in import file\n",
998 while (*s != ')' && *s != '\0')
1003 einfo ("%s:%d: warning: syntax error in import file\n",
1011 if (symbol_mode & ${SYMBOL_MODE_MASK}) {
1013 /* This is a symbol to be imported or exported. */
1016 address = (bfd_vma) -1;
1018 while (! isspace ((unsigned char) *s) && *s != '\0')
1026 while (isspace ((unsigned char) *s))
1030 while (! isspace ((unsigned char) *se) && *se != '\0')
1035 while (isspace ((unsigned char) *se))
1038 einfo ("%s%d: warning: syntax error in import/export file\n",
1046 status = is_syscall(s);
1050 /* this is a system call */
1055 /* ignore this system call */
1059 /* not a system call, check for address */
1060 address = strtoul (s, &end, 0);
1062 einfo ("%s:%d: warning: syntax error in import/export file\n", filename, lineno);
1071 struct export_symbol_list *n;
1073 ldlang_add_undef (symname);
1074 n = ((struct export_symbol_list *)
1075 xmalloc (sizeof (struct export_symbol_list)));
1076 n->next = export_symbols;
1077 n->name = xstrdup (symname);
1078 n->syscall = syscall;
1083 h = bfd_link_hash_lookup (link_info.hash, symname, false, false,
1085 if (h == NULL || h->type == bfd_link_hash_new)
1087 /* We can just ignore attempts to import an unreferenced
1092 if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
1093 address, imppath, impfile,
1095 einfo ("%X%s:%d: failed to import symbol %s: %E\n",
1096 filename, lineno, symname);
1100 obstack_free (o, obstack_base (o));
1103 if (obstack_object_size (o) > 0)
1105 einfo ("%s:%d: warning: ignoring unterminated last line\n",
1107 obstack_free (o, obstack_base (o));
1112 obstack_free (o, NULL);
1117 /* This routine saves us from worrying about declaring free. */
1120 gld${EMULATION_NAME}_free (p)
1126 /* This is called by the before_allocation routine via
1127 lang_for_each_statement. It looks for relocations and assignments
1131 gld${EMULATION_NAME}_find_relocs (s)
1132 lang_statement_union_type *s;
1134 if (s->header.type == lang_reloc_statement_enum)
1136 lang_reloc_statement_type *rs;
1138 rs = &s->reloc_statement;
1139 if (rs->name == NULL)
1140 einfo ("%F%P: only relocations against symbols are permitted\n");
1141 if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
1142 einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
1145 if (s->header.type == lang_assignment_statement_enum)
1146 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1149 /* Look through an expression for an assignment statement. */
1152 gld${EMULATION_NAME}_find_exp_assignment (exp)
1155 struct bfd_link_hash_entry *h;
1157 switch (exp->type.node_class)
1160 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
1161 false, false, false);
1166 if (strcmp (exp->assign.dst, ".") != 0)
1168 if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info,
1170 einfo ("%P%F: failed to record assignment to %s: %E\n",
1173 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1177 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1178 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1182 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1183 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1184 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1188 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1197 gld${EMULATION_NAME}_get_script(isfile)
1201 if test -n "$COMPILE_IN"
1203 # Scripts compiled in.
1205 # sed commands to quote an ld script as a C string.
1206 sc="-f ${srcdir}/emultempl/ostring.sed"
1208 cat >>e${EMULATION_NAME}.c <<EOF
1212 if (link_info.relocateable == true && config.build_constructors == true)
1215 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1216 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1217 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
1218 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
1219 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
1220 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
1221 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
1222 echo ' ; else return' >> e${EMULATION_NAME}.c
1223 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1224 echo '; }' >> e${EMULATION_NAME}.c
1227 # Scripts read from the filesystem.
1229 cat >>e${EMULATION_NAME}.c <<EOF
1233 if (link_info.relocateable == true && config.build_constructors == true)
1234 return "ldscripts/${EMULATION_NAME}.xu";
1235 else if (link_info.relocateable == true)
1236 return "ldscripts/${EMULATION_NAME}.xr";
1237 else if (!config.text_read_only)
1238 return "ldscripts/${EMULATION_NAME}.xbn";
1239 else if (!config.magic_demand_paged)
1240 return "ldscripts/${EMULATION_NAME}.xn";
1242 return "ldscripts/${EMULATION_NAME}.x";
1248 cat >>e${EMULATION_NAME}.c <<EOF
1250 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1252 gld${EMULATION_NAME}_before_parse,
1255 after_parse_default,
1256 gld${EMULATION_NAME}_after_open,
1257 after_allocation_default,
1258 set_output_arch_default,
1259 ldemul_default_target,
1260 gld${EMULATION_NAME}_before_allocation,
1261 gld${EMULATION_NAME}_get_script,
1262 "${EMULATION_NAME}",
1265 0, /* create_output_section_statements */
1266 0, /* open_dynamic_archive */
1267 0, /* place_orphan */
1268 0, /* set_symbols */
1269 gld${EMULATION_NAME}_parse_args,
1270 gld${EMULATION_NAME}_unrecognized_file,
1271 NULL, /* list_options */
1272 NULL, /* recognized_file */
1273 NULL, /* find potential_libraries */