daily update
[deliverable/binutils-gdb.git] / ld / emultempl / vms.em
CommitLineData
8b351884
TG
1# This shell script emits a C file. -*- C -*-
2# Copyright 2010
3# Free Software Foundation, Inc.
4#
5# This file is part of the GNU Binutils.
6#
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.
11#
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.
16#
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,
20# MA 02110-1301, USA.
21#
22
23# This file is sourced from generic.em.
24
25fragment <<EOF
26static void
27gld${EMULATION_NAME}_before_parse (void)
28{
29 ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
30 config.dynamic_link = TRUE;
31 config.has_shared = FALSE; /* Not yet. */
32}
33
34/* This is called before the input files are opened. We add the
35 standard library. */
36
37static void
38gld${EMULATION_NAME}_create_output_section_statements (void)
39{
40 lang_add_input_file ("imagelib", lang_input_file_is_l_enum, NULL);
41 lang_add_input_file ("starlet", lang_input_file_is_l_enum, NULL);
42 lang_add_input_file ("sys\$public_vectors", lang_input_file_is_l_enum, NULL);
43}
44
45/* Try to open a dynamic archive. This is where we know that VMS
46 shared images (dynamic libraries) have an extension of .exe. */
47
48static bfd_boolean
49gld${EMULATION_NAME}_open_dynamic_archive (const char *arch ATTRIBUTE_UNUSED,
50 search_dirs_type *search,
51 lang_input_statement_type *entry)
52{
53 char *string;
54
55 if (! entry->is_archive)
56 return FALSE;
57
58 string = (char *) xmalloc (strlen (search->name)
59 + strlen (entry->filename)
60 + sizeof "/.exe");
61
62 sprintf (string, "%s/%s.exe", search->name, entry->filename);
63
64 if (! ldfile_try_open_bfd (string, entry))
65 {
66 free (string);
67 return FALSE;
68 }
69
70 entry->filename = string;
71
72 return TRUE;
73}
74
75static int
76gld${EMULATION_NAME}_find_potential_libraries
77 (char *name, lang_input_statement_type *entry)
78{
79 return ldfile_open_file_search (name, entry, "", ".olb");
80}
81
82/* Place an orphan section. We use this to put random OVR sections.
83 Much borrowed from elf32.em. */
84
85static lang_output_section_statement_type *
86vms_place_orphan (asection *s,
87 const char *secname ATTRIBUTE_UNUSED,
88 int constraint ATTRIBUTE_UNUSED)
89{
90 static struct orphan_save hold_data =
91 {
92 "\$DATA\$",
93 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
94 0, 0, 0, 0
95 };
96
97 /* We have nothing to say for anything other than a final link. */
98 if (link_info.relocatable
99 || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
100 return NULL;
101
102 /* Only handle data sections. */
103 if ((s->flags & SEC_DATA) == 0)
104 return NULL;
105
106 if (hold_data.os == NULL)
107 hold_data.os = lang_output_section_find (hold_data.name);
108
109 if (hold_data.os != NULL)
110 {
111 lang_add_section (&hold_data.os->children, s, hold_data.os);
112 return hold_data.os;
113 }
114 else
115 return NULL;
116}
117EOF
118
119LDEMUL_PLACE_ORPHAN=vms_place_orphan
120LDEMUL_BEFORE_PARSE=gld"$EMULATION_NAME"_before_parse
121LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=gld"$EMULATION_NAME"_create_output_section_statements
122LDEMUL_FIND_POTENTIAL_LIBRARIES=gld"$EMULATION_NAME"_find_potential_libraries
123LDEMUL_OPEN_DYNAMIC_ARCHIVE=gld"$EMULATION_NAME"_open_dynamic_archive
This page took 0.035006 seconds and 4 git commands to generate.