Updated Malay translation for the bfd sub-directory
[binutils-gdb.git] / ld / emultempl / vms.em
blob1b68b0db64fef1bf9a90193c09fe5f3eaa07e4dc
1 # This shell script emits a C file. -*- C -*-
2 #   Copyright (C) 2010-2025 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
22 # This file is sourced from generic.em.
24 fragment <<EOF
25 #include "libiberty.h"
26 #include "getopt.h"
27 #include "ldlex.h"
29 static void
30 gld${EMULATION_NAME}_before_parse (void)
32   ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
33   input_flags.dynamic = true;
34   config.has_shared = false; /* Not yet.  */
36   /* For ia64, harmless for alpha.  */
37   link_info.emit_hash = false;
38   link_info.spare_dynamic_tags = 0;
41 /* This is called before the input files are opened.  We add the
42    standard library.  */
44 static void
45 gld${EMULATION_NAME}_create_output_section_statements (void)
47   lang_add_input_file ("imagelib", lang_input_file_is_l_enum, NULL);
48   lang_add_input_file ("starlet", lang_input_file_is_l_enum, NULL);
49   lang_add_input_file ("sys\$public_vectors", lang_input_file_is_l_enum, NULL);
52 /* Try to open a dynamic archive.  This is where we know that VMS
53    shared images (dynamic libraries) have an extension of .exe.  */
55 static bool
56 gld${EMULATION_NAME}_open_dynamic_archive (const char *arch ATTRIBUTE_UNUSED,
57                                            search_dirs_type *search,
58                                            lang_input_statement_type *entry)
60   char *string;
62   if (! entry->flags.maybe_archive || entry->flags.full_name_provided)
63     return false;
65   string = (char *) xmalloc (strlen (search->name)
66                              + strlen (entry->filename)
67                              + sizeof "/.exe");
69   sprintf (string, "%s/%s.exe", search->name, entry->filename);
71   if (! ldfile_try_open_bfd (string, entry))
72     {
73       free (string);
74       return false;
75     }
77   entry->filename = string;
79   return true;
82 static int
83 gld${EMULATION_NAME}_find_potential_libraries
84   (char *name, lang_input_statement_type *entry)
86   return ldfile_open_file_search (name, entry, "", ".olb");
89 /* Place an orphan section.  We use this to put random OVR sections.
90    Much borrowed from elf.em.  */
92 static lang_output_section_statement_type *
93 vms_place_orphan (asection *s,
94                   const char *secname ATTRIBUTE_UNUSED,
95                   int constraint ATTRIBUTE_UNUSED)
97   static struct orphan_save hold_data =
98     {
99       "\$DATA\$",
100       SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
101       0, 0, 0, 0
102     };
104   /* We have nothing to say for anything other than a final link or an excluded
105      section.  */
106   if (bfd_link_relocatable (&link_info)
107       || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
108     return NULL;
110   /* FIXME: we should place sections by VMS program section flags.  */
112   /* Only handle data sections.  */
113   if ((s->flags & SEC_DATA) == 0)
114     return NULL;
116   if (hold_data.os == NULL)
117     hold_data.os = lang_output_section_find (hold_data.name);
119   if (hold_data.os != NULL)
120     {
121       lang_add_section (&hold_data.os->children, s, NULL, NULL, hold_data.os);
122       return hold_data.os;
123     }
124   else
125     return NULL;
128 /* VMS specific options.  */
130 static void
131 gld${EMULATION_NAME}_add_options
132   (int ns ATTRIBUTE_UNUSED,
133    char **shortopts ATTRIBUTE_UNUSED,
134    int nl,
135    struct option **longopts,
136    int nrl ATTRIBUTE_UNUSED,
137    struct option **really_longopts ATTRIBUTE_UNUSED)
139   static const struct option xtra_long[] =
140   {
141     {"identification", required_argument, NULL, OPTION_IDENTIFICATION},
142     {NULL, no_argument, NULL, 0}
143   };
145   *longopts
146     = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
147   memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
150 static void
151 gld${EMULATION_NAME}_list_options (FILE *file)
153   fprintf (file, _("  --identification <string>          Set the identification of the output\n"));
156 static bool
157 gld${EMULATION_NAME}_handle_option (int optc)
159   switch (optc)
160     {
161     default:
162       return false;
164     case OPTION_IDENTIFICATION:
165       /* Currently ignored.  */
166       break;
167     }
169   return true;
174 if test "$OUTPUT_FORMAT" = "elf64-ia64-vms"; then
176 fragment <<EOF
177 #include "elf-bfd.h"
178 #include "ldelfgen.h"
181 source_em ${srcdir}/emultempl/elf-generic.em
183 fragment <<EOF
185 /* This is called after the sections have been attached to output
186    sections, but before any sizes or addresses have been set.  */
188 static void
189 gld${EMULATION_NAME}_before_allocation (void)
191   const struct elf_backend_data *bed;
193   if (!is_elf_hash_table (link_info.hash))
194     return;
196   bed = get_elf_backend_data (link_info.output_bfd);
198   /* The backend must work out the sizes of all the other dynamic
199      sections.  */
200   if (bed->elf_backend_late_size_sections
201       && !bed->elf_backend_late_size_sections (link_info.output_bfd,
202                                                &link_info))
203     einfo (_("%F%P: failed to set dynamic section sizes: %E\n"));
205   before_allocation_default ();
208 static void
209 gld${EMULATION_NAME}_after_allocation (void)
211   int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
213   if (need_layout < 0)
214     einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
215   else
216     ldelf_map_segments (need_layout);
219 static void
220 gld${EMULATION_NAME}_after_parse (void)
222   link_info.relax_pass = 2;
223   after_parse_default ();
227 LDEMUL_BEFORE_ALLOCATION=gld"$EMULATION_NAME"_before_allocation
228 LDEMUL_AFTER_ALLOCATION=gld"$EMULATION_NAME"_after_allocation
230 LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse
231 source_em ${srcdir}/emultempl/needrelax.em
234 LDEMUL_PLACE_ORPHAN=vms_place_orphan
235 LDEMUL_BEFORE_PARSE=gld"$EMULATION_NAME"_before_parse
236 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=gld"$EMULATION_NAME"_create_output_section_statements
237 LDEMUL_FIND_POTENTIAL_LIBRARIES=gld"$EMULATION_NAME"_find_potential_libraries
238 LDEMUL_OPEN_DYNAMIC_ARCHIVE=gld"$EMULATION_NAME"_open_dynamic_archive
239 LDEMUL_ADD_OPTIONS=gld"$EMULATION_NAME"_add_options
240 LDEMUL_HANDLE_OPTION=gld"$EMULATION_NAME"_handle_option
241 LDEMUL_LIST_OPTIONS=gld"$EMULATION_NAME"_list_options