1 # This shell script emits a C file. -*- C -*-
3 # Free Software Foundation, Inc.
5 # This file is part of the GNU Binutils.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 # This file is sourced from generic.em.
29 gld${EMULATION_NAME}_before_parse (void)
31 ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
32 input_flags.dynamic = TRUE;
33 config.has_shared = FALSE; /* Not yet. */
35 /* For ia64, harmless for alpha. */
36 link_info.emit_hash = FALSE;
37 link_info.spare_dynamic_tags = 0;
40 /* This is called before the input files are opened. We add the
44 gld${EMULATION_NAME}_create_output_section_statements (void)
46 lang_add_input_file ("imagelib", lang_input_file_is_l_enum, NULL);
47 lang_add_input_file ("starlet", lang_input_file_is_l_enum, NULL);
48 lang_add_input_file ("sys\$public_vectors", lang_input_file_is_l_enum, NULL);
51 /* Try to open a dynamic archive. This is where we know that VMS
52 shared images (dynamic libraries) have an extension of .exe. */
55 gld${EMULATION_NAME}_open_dynamic_archive (const char *arch ATTRIBUTE_UNUSED,
56 search_dirs_type *search,
57 lang_input_statement_type *entry)
61 if (! entry->flags.maybe_archive)
64 string = (char *) xmalloc (strlen (search->name)
65 + strlen (entry->filename)
68 sprintf (string, "%s/%s.exe", search->name, entry->filename);
70 if (! ldfile_try_open_bfd (string, entry))
76 entry->filename = string;
82 gld${EMULATION_NAME}_find_potential_libraries
83 (char *name, lang_input_statement_type *entry)
85 return ldfile_open_file_search (name, entry, "", ".olb");
88 /* Place an orphan section. We use this to put random OVR sections.
89 Much borrowed from elf32.em. */
91 static lang_output_section_statement_type *
92 vms_place_orphan (asection *s,
93 const char *secname ATTRIBUTE_UNUSED,
94 int constraint ATTRIBUTE_UNUSED)
96 static struct orphan_save hold_data =
99 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
103 /* We have nothing to say for anything other than a final link or an excluded
105 if (link_info.relocatable
106 || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
109 /* FIXME: we should place sections by VMS program section flags. */
111 /* Only handle data sections. */
112 if ((s->flags & SEC_DATA) == 0)
115 if (hold_data.os == NULL)
116 hold_data.os = lang_output_section_find (hold_data.name);
118 if (hold_data.os != NULL)
120 lang_add_section (&hold_data.os->children, s, NULL, hold_data.os);
127 /* VMS specific options. */
128 #define OPTION_IDENTIFICATION (300 + 1)
131 gld${EMULATION_NAME}_add_options
132 (int ns ATTRIBUTE_UNUSED,
133 char **shortopts ATTRIBUTE_UNUSED,
135 struct option **longopts,
136 int nrl ATTRIBUTE_UNUSED,
137 struct option **really_longopts ATTRIBUTE_UNUSED)
139 static const struct option xtra_long[] =
141 {"identification", required_argument, NULL, OPTION_IDENTIFICATION},
142 {NULL, no_argument, NULL, 0}
146 = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
147 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
151 gld${EMULATION_NAME}_list_options (FILE *file)
153 fprintf (file, _(" --identification <string> Set the identification of the output\n"));
157 gld${EMULATION_NAME}_handle_option (int optc)
164 case OPTION_IDENTIFICATION:
165 /* Currently ignored. */
174 if test "$OUTPUT_FORMAT" = "elf64-ia64-vms"; then
180 source_em ${srcdir}/emultempl/elf-generic.em
184 /* This is called after the sections have been attached to output
185 sections, but before any sizes or addresses have been set. */
188 gld${EMULATION_NAME}_before_allocation (void)
190 const struct elf_backend_data *bed;
192 if (!is_elf_hash_table (link_info.hash))
195 bed = get_elf_backend_data (link_info.output_bfd);
197 /* The backend must work out the sizes of all the other dynamic
199 if (elf_hash_table (&link_info)->dynamic_sections_created
200 && bed->elf_backend_size_dynamic_sections
201 && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd,
203 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
205 before_allocation_default ();
209 gld${EMULATION_NAME}_after_allocation (void)
211 bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
213 gld${EMULATION_NAME}_map_segments (need_layout);
217 gld${EMULATION_NAME}_after_parse (void)
219 link_info.relax_pass = 2;
220 after_parse_default ();
224 LDEMUL_BEFORE_ALLOCATION=gld"$EMULATION_NAME"_before_allocation
225 LDEMUL_AFTER_ALLOCATION=gld"$EMULATION_NAME"_after_allocation
227 LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse
228 source_em ${srcdir}/emultempl/needrelax.em
231 LDEMUL_PLACE_ORPHAN=vms_place_orphan
232 LDEMUL_BEFORE_PARSE=gld"$EMULATION_NAME"_before_parse
233 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=gld"$EMULATION_NAME"_create_output_section_statements
234 LDEMUL_FIND_POTENTIAL_LIBRARIES=gld"$EMULATION_NAME"_find_potential_libraries
235 LDEMUL_OPEN_DYNAMIC_ARCHIVE=gld"$EMULATION_NAME"_open_dynamic_archive
236 LDEMUL_ADD_OPTIONS=gld"$EMULATION_NAME"_add_options
237 LDEMUL_HANDLE_OPTION=gld"$EMULATION_NAME"_handle_option
238 LDEMUL_LIST_OPTIONS=gld"$EMULATION_NAME"_list_options