1*3d8817e4Smiod /* vms.c -- BFD back-end for VAX (openVMS/VAX) and
2*3d8817e4Smiod EVAX (openVMS/Alpha) files.
3*3d8817e4Smiod Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4*3d8817e4Smiod 2006 Free Software Foundation, Inc.
5*3d8817e4Smiod
6*3d8817e4Smiod Written by Klaus K"ampf (kkaempf@rmi.de)
7*3d8817e4Smiod
8*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
9*3d8817e4Smiod it under the terms of the GNU General Public License as published by
10*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or
11*3d8817e4Smiod (at your option) any later version.
12*3d8817e4Smiod
13*3d8817e4Smiod This program is distributed in the hope that it will be useful,
14*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
15*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16*3d8817e4Smiod GNU General Public License for more details.
17*3d8817e4Smiod
18*3d8817e4Smiod You should have received a copy of the GNU General Public License
19*3d8817e4Smiod along with this program; if not, write to the Free Software
20*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
21*3d8817e4Smiod
22*3d8817e4Smiod #include "bfd.h"
23*3d8817e4Smiod #include "sysdep.h"
24*3d8817e4Smiod #include "bfdlink.h"
25*3d8817e4Smiod #include "libbfd.h"
26*3d8817e4Smiod
27*3d8817e4Smiod #include "vms.h"
28*3d8817e4Smiod
29*3d8817e4Smiod #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
30*3d8817e4Smiod #define vms_make_empty_symbol _bfd_generic_make_empty_symbol
31*3d8817e4Smiod #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
32*3d8817e4Smiod #define vms_bfd_is_group_section bfd_generic_is_group_section
33*3d8817e4Smiod #define vms_bfd_discard_group bfd_generic_discard_group
34*3d8817e4Smiod #define vms_section_already_linked _bfd_generic_section_already_linked
35*3d8817e4Smiod #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
36*3d8817e4Smiod #define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
37*3d8817e4Smiod
38*3d8817e4Smiod static unsigned int priv_section_count;
39*3d8817e4Smiod extern const bfd_target vms_vax_vec;
40*3d8817e4Smiod extern const bfd_target vms_alpha_vec;
41*3d8817e4Smiod
42*3d8817e4Smiod /* Initialize private data. */
43*3d8817e4Smiod
44*3d8817e4Smiod static bfd_boolean
vms_initialize(bfd * abfd)45*3d8817e4Smiod vms_initialize (bfd * abfd)
46*3d8817e4Smiod {
47*3d8817e4Smiod int i;
48*3d8817e4Smiod bfd_size_type amt;
49*3d8817e4Smiod
50*3d8817e4Smiod bfd_set_start_address (abfd, (bfd_vma) -1);
51*3d8817e4Smiod
52*3d8817e4Smiod amt = sizeof (struct vms_private_data_struct);
53*3d8817e4Smiod abfd->tdata.any = bfd_alloc (abfd, amt);
54*3d8817e4Smiod if (abfd->tdata.any == NULL)
55*3d8817e4Smiod return FALSE;
56*3d8817e4Smiod
57*3d8817e4Smiod #ifdef __ALPHA
58*3d8817e4Smiod PRIV (is_vax) = FALSE;
59*3d8817e4Smiod #else
60*3d8817e4Smiod PRIV (is_vax) = TRUE;
61*3d8817e4Smiod #endif
62*3d8817e4Smiod PRIV (vms_buf) = NULL;
63*3d8817e4Smiod PRIV (buf_size) = 0;
64*3d8817e4Smiod PRIV (rec_length) = 0;
65*3d8817e4Smiod PRIV (file_format) = FF_UNKNOWN;
66*3d8817e4Smiod PRIV (fixup_done) = FALSE;
67*3d8817e4Smiod PRIV (sections) = NULL;
68*3d8817e4Smiod
69*3d8817e4Smiod amt = sizeof (struct stack_struct) * STACKSIZE;
70*3d8817e4Smiod PRIV (stack) = bfd_alloc (abfd, amt);
71*3d8817e4Smiod if (PRIV (stack) == NULL)
72*3d8817e4Smiod goto error_ret1;
73*3d8817e4Smiod PRIV (stackptr) = 0;
74*3d8817e4Smiod
75*3d8817e4Smiod amt = sizeof (struct bfd_hash_table);
76*3d8817e4Smiod PRIV (vms_symbol_table) = bfd_alloc (abfd, amt);
77*3d8817e4Smiod if (PRIV (vms_symbol_table) == NULL)
78*3d8817e4Smiod goto error_ret1;
79*3d8817e4Smiod
80*3d8817e4Smiod if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
81*3d8817e4Smiod sizeof (vms_symbol_entry)))
82*3d8817e4Smiod goto error_ret1;
83*3d8817e4Smiod
84*3d8817e4Smiod amt = sizeof (struct location_struct) * LOCATION_SAVE_SIZE;
85*3d8817e4Smiod PRIV (location_stack) = bfd_alloc (abfd, amt);
86*3d8817e4Smiod if (PRIV (location_stack) == NULL)
87*3d8817e4Smiod goto error_ret2;
88*3d8817e4Smiod
89*3d8817e4Smiod for (i = 0; i < VMS_SECTION_COUNT; i++)
90*3d8817e4Smiod PRIV (vms_section_table)[i] = NULL;
91*3d8817e4Smiod
92*3d8817e4Smiod amt = MAX_OUTREC_SIZE;
93*3d8817e4Smiod PRIV (output_buf) = bfd_alloc (abfd, amt);
94*3d8817e4Smiod if (PRIV (output_buf) == NULL)
95*3d8817e4Smiod goto error_ret2;
96*3d8817e4Smiod
97*3d8817e4Smiod PRIV (push_level) = 0;
98*3d8817e4Smiod PRIV (pushed_size) = 0;
99*3d8817e4Smiod PRIV (length_pos) = 2;
100*3d8817e4Smiod PRIV (output_size) = 0;
101*3d8817e4Smiod PRIV (output_alignment) = 1;
102*3d8817e4Smiod
103*3d8817e4Smiod return TRUE;
104*3d8817e4Smiod
105*3d8817e4Smiod error_ret2:
106*3d8817e4Smiod bfd_hash_table_free (PRIV (vms_symbol_table));
107*3d8817e4Smiod error_ret1:
108*3d8817e4Smiod bfd_release (abfd, abfd->tdata.any);
109*3d8817e4Smiod abfd->tdata.any = NULL;
110*3d8817e4Smiod return FALSE;
111*3d8817e4Smiod }
112*3d8817e4Smiod
113*3d8817e4Smiod /* Fill symbol->section with section ptr
114*3d8817e4Smiod symbol->section is filled with the section index for defined symbols
115*3d8817e4Smiod during reading the GSD/EGSD section. But we need the pointer to the
116*3d8817e4Smiod bfd section later.
117*3d8817e4Smiod
118*3d8817e4Smiod It has the correct value for referenced (undefined section) symbols
119*3d8817e4Smiod
120*3d8817e4Smiod called from bfd_hash_traverse in vms_fixup_sections. */
121*3d8817e4Smiod
122*3d8817e4Smiod static bfd_boolean
fill_section_ptr(struct bfd_hash_entry * entry,void * sections)123*3d8817e4Smiod fill_section_ptr (struct bfd_hash_entry * entry, void * sections)
124*3d8817e4Smiod {
125*3d8817e4Smiod asection *sec;
126*3d8817e4Smiod asymbol *sym;
127*3d8817e4Smiod
128*3d8817e4Smiod sym = ((vms_symbol_entry *) entry)->symbol;
129*3d8817e4Smiod sec = sym->section;
130*3d8817e4Smiod
131*3d8817e4Smiod #if VMS_DEBUG
132*3d8817e4Smiod vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
133*3d8817e4Smiod #endif
134*3d8817e4Smiod
135*3d8817e4Smiod /* Fill forward references (these contain section number, not section ptr). */
136*3d8817e4Smiod if ((unsigned int) (size_t) sec < priv_section_count)
137*3d8817e4Smiod sec = ((vms_symbol_entry *) entry)->symbol->section =
138*3d8817e4Smiod ((asection **) sections)[(unsigned int) (size_t) sec];
139*3d8817e4Smiod
140*3d8817e4Smiod if (strcmp (sym->name, sec->name) == 0)
141*3d8817e4Smiod sym->flags |= BSF_SECTION_SYM;
142*3d8817e4Smiod
143*3d8817e4Smiod return TRUE;
144*3d8817e4Smiod }
145*3d8817e4Smiod
146*3d8817e4Smiod /* Fixup sections
147*3d8817e4Smiod set up all pointers and arrays, counters and sizes are fixed now
148*3d8817e4Smiod
149*3d8817e4Smiod we build a private sections vector for easy access since sections
150*3d8817e4Smiod are always referenced by an index number.
151*3d8817e4Smiod
152*3d8817e4Smiod alloc PRIV(sections) according to abfd->section_count
153*3d8817e4Smiod copy abfd->sections to PRIV(sections). */
154*3d8817e4Smiod
155*3d8817e4Smiod static bfd_boolean
vms_fixup_sections(bfd * abfd)156*3d8817e4Smiod vms_fixup_sections (bfd * abfd)
157*3d8817e4Smiod {
158*3d8817e4Smiod if (PRIV (fixup_done))
159*3d8817e4Smiod return TRUE;
160*3d8817e4Smiod
161*3d8817e4Smiod /* Traverse symbol table and fill in all section pointers. */
162*3d8817e4Smiod
163*3d8817e4Smiod /* Can't provide section count as argument to fill_section_ptr(). */
164*3d8817e4Smiod priv_section_count = PRIV (section_count);
165*3d8817e4Smiod bfd_hash_traverse (PRIV (vms_symbol_table), fill_section_ptr, (PRIV (sections)));
166*3d8817e4Smiod
167*3d8817e4Smiod PRIV (fixup_done) = TRUE;
168*3d8817e4Smiod
169*3d8817e4Smiod return TRUE;
170*3d8817e4Smiod }
171*3d8817e4Smiod
172*3d8817e4Smiod /* Check the format for a file being read.
173*3d8817e4Smiod Return a (bfd_target *) if it's an object file or zero if not. */
174*3d8817e4Smiod
175*3d8817e4Smiod static const struct bfd_target *
vms_object_p(bfd * abfd)176*3d8817e4Smiod vms_object_p (bfd * abfd)
177*3d8817e4Smiod {
178*3d8817e4Smiod int err = 0;
179*3d8817e4Smiod int prev_type;
180*3d8817e4Smiod const struct bfd_target *target_vector = NULL;
181*3d8817e4Smiod const bfd_arch_info_type *arch = NULL;
182*3d8817e4Smiod void * tdata_save = abfd->tdata.any;
183*3d8817e4Smiod bfd_vma saddr_save = bfd_get_start_address (abfd);
184*3d8817e4Smiod
185*3d8817e4Smiod #if VMS_DEBUG
186*3d8817e4Smiod vms_debug (1, "vms_object_p (%p)\n", abfd);
187*3d8817e4Smiod #endif
188*3d8817e4Smiod
189*3d8817e4Smiod if (!vms_initialize (abfd))
190*3d8817e4Smiod goto error_ret;
191*3d8817e4Smiod
192*3d8817e4Smiod if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
193*3d8817e4Smiod goto err_wrong_format;
194*3d8817e4Smiod
195*3d8817e4Smiod prev_type = -1;
196*3d8817e4Smiod
197*3d8817e4Smiod do
198*3d8817e4Smiod {
199*3d8817e4Smiod #if VMS_DEBUG
200*3d8817e4Smiod vms_debug (7, "reading at %08lx\n", bfd_tell (abfd));
201*3d8817e4Smiod #endif
202*3d8817e4Smiod if (_bfd_vms_next_record (abfd) < 0)
203*3d8817e4Smiod {
204*3d8817e4Smiod #if VMS_DEBUG
205*3d8817e4Smiod vms_debug (2, "next_record failed\n");
206*3d8817e4Smiod #endif
207*3d8817e4Smiod goto err_wrong_format;
208*3d8817e4Smiod }
209*3d8817e4Smiod
210*3d8817e4Smiod if ((prev_type == EOBJ_S_C_EGSD)
211*3d8817e4Smiod && (PRIV (rec_type) != EOBJ_S_C_EGSD))
212*3d8817e4Smiod {
213*3d8817e4Smiod if (! vms_fixup_sections (abfd))
214*3d8817e4Smiod {
215*3d8817e4Smiod #if VMS_DEBUG
216*3d8817e4Smiod vms_debug (2, "vms_fixup_sections failed\n");
217*3d8817e4Smiod #endif
218*3d8817e4Smiod goto err_wrong_format;
219*3d8817e4Smiod }
220*3d8817e4Smiod }
221*3d8817e4Smiod
222*3d8817e4Smiod prev_type = PRIV (rec_type);
223*3d8817e4Smiod
224*3d8817e4Smiod if (target_vector == NULL)
225*3d8817e4Smiod {
226*3d8817e4Smiod if (prev_type <= OBJ_S_C_MAXRECTYP)
227*3d8817e4Smiod target_vector = & vms_vax_vec;
228*3d8817e4Smiod else
229*3d8817e4Smiod target_vector = & vms_alpha_vec;
230*3d8817e4Smiod }
231*3d8817e4Smiod
232*3d8817e4Smiod switch (prev_type)
233*3d8817e4Smiod {
234*3d8817e4Smiod case OBJ_S_C_HDR:
235*3d8817e4Smiod case EOBJ_S_C_EMH:
236*3d8817e4Smiod err = _bfd_vms_slurp_hdr (abfd, prev_type);
237*3d8817e4Smiod break;
238*3d8817e4Smiod case OBJ_S_C_EOM:
239*3d8817e4Smiod case OBJ_S_C_EOMW:
240*3d8817e4Smiod case EOBJ_S_C_EEOM:
241*3d8817e4Smiod err = _bfd_vms_slurp_eom (abfd, prev_type);
242*3d8817e4Smiod break;
243*3d8817e4Smiod case OBJ_S_C_GSD:
244*3d8817e4Smiod case EOBJ_S_C_EGSD:
245*3d8817e4Smiod err = _bfd_vms_slurp_gsd (abfd, prev_type);
246*3d8817e4Smiod break;
247*3d8817e4Smiod case OBJ_S_C_TIR:
248*3d8817e4Smiod case EOBJ_S_C_ETIR:
249*3d8817e4Smiod err = _bfd_vms_slurp_tir (abfd, prev_type);
250*3d8817e4Smiod break;
251*3d8817e4Smiod case OBJ_S_C_DBG:
252*3d8817e4Smiod case EOBJ_S_C_EDBG:
253*3d8817e4Smiod err = _bfd_vms_slurp_dbg (abfd, prev_type);
254*3d8817e4Smiod break;
255*3d8817e4Smiod case OBJ_S_C_TBT:
256*3d8817e4Smiod case EOBJ_S_C_ETBT:
257*3d8817e4Smiod err = _bfd_vms_slurp_tbt (abfd, prev_type);
258*3d8817e4Smiod break;
259*3d8817e4Smiod case OBJ_S_C_LNK:
260*3d8817e4Smiod err = _bfd_vms_slurp_lnk (abfd, prev_type);
261*3d8817e4Smiod break;
262*3d8817e4Smiod default:
263*3d8817e4Smiod err = -1;
264*3d8817e4Smiod }
265*3d8817e4Smiod if (err != 0)
266*3d8817e4Smiod {
267*3d8817e4Smiod #if VMS_DEBUG
268*3d8817e4Smiod vms_debug (2, "slurp type %d failed with %d\n", prev_type, err);
269*3d8817e4Smiod #endif
270*3d8817e4Smiod goto err_wrong_format;
271*3d8817e4Smiod }
272*3d8817e4Smiod }
273*3d8817e4Smiod while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW));
274*3d8817e4Smiod
275*3d8817e4Smiod if (target_vector == & vms_vax_vec)
276*3d8817e4Smiod {
277*3d8817e4Smiod if (! vms_fixup_sections (abfd))
278*3d8817e4Smiod {
279*3d8817e4Smiod #if VMS_DEBUG
280*3d8817e4Smiod vms_debug (2, "vms_fixup_sections failed\n");
281*3d8817e4Smiod #endif
282*3d8817e4Smiod goto err_wrong_format;
283*3d8817e4Smiod }
284*3d8817e4Smiod
285*3d8817e4Smiod /* Set arch_info to vax. */
286*3d8817e4Smiod
287*3d8817e4Smiod arch = bfd_scan_arch ("vax");
288*3d8817e4Smiod PRIV (is_vax) = TRUE;
289*3d8817e4Smiod #if VMS_DEBUG
290*3d8817e4Smiod vms_debug (2, "arch is vax\n");
291*3d8817e4Smiod #endif
292*3d8817e4Smiod }
293*3d8817e4Smiod else if (target_vector == & vms_alpha_vec)
294*3d8817e4Smiod {
295*3d8817e4Smiod /* Set arch_info to alpha. */
296*3d8817e4Smiod
297*3d8817e4Smiod arch = bfd_scan_arch ("alpha");
298*3d8817e4Smiod PRIV (is_vax) = FALSE;
299*3d8817e4Smiod #if VMS_DEBUG
300*3d8817e4Smiod vms_debug (2, "arch is alpha\n");
301*3d8817e4Smiod #endif
302*3d8817e4Smiod }
303*3d8817e4Smiod
304*3d8817e4Smiod if (arch == NULL)
305*3d8817e4Smiod {
306*3d8817e4Smiod #if VMS_DEBUG
307*3d8817e4Smiod vms_debug (2, "arch not found\n");
308*3d8817e4Smiod #endif
309*3d8817e4Smiod goto err_wrong_format;
310*3d8817e4Smiod }
311*3d8817e4Smiod abfd->arch_info = arch;
312*3d8817e4Smiod
313*3d8817e4Smiod return target_vector;
314*3d8817e4Smiod
315*3d8817e4Smiod err_wrong_format:
316*3d8817e4Smiod bfd_set_error (bfd_error_wrong_format);
317*3d8817e4Smiod error_ret:
318*3d8817e4Smiod if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
319*3d8817e4Smiod bfd_release (abfd, abfd->tdata.any);
320*3d8817e4Smiod abfd->tdata.any = tdata_save;
321*3d8817e4Smiod bfd_set_start_address (abfd, saddr_save);
322*3d8817e4Smiod return NULL;
323*3d8817e4Smiod }
324*3d8817e4Smiod
325*3d8817e4Smiod /* Check the format for a file being read.
326*3d8817e4Smiod Return a (bfd_target *) if it's an archive file or zero. */
327*3d8817e4Smiod
328*3d8817e4Smiod static const struct bfd_target *
vms_archive_p(bfd * abfd ATTRIBUTE_UNUSED)329*3d8817e4Smiod vms_archive_p (bfd * abfd ATTRIBUTE_UNUSED)
330*3d8817e4Smiod {
331*3d8817e4Smiod #if VMS_DEBUG
332*3d8817e4Smiod vms_debug (1, "vms_archive_p (%p)\n", abfd);
333*3d8817e4Smiod #endif
334*3d8817e4Smiod
335*3d8817e4Smiod return NULL;
336*3d8817e4Smiod }
337*3d8817e4Smiod
338*3d8817e4Smiod /* Set the format of a file being written. */
339*3d8817e4Smiod
340*3d8817e4Smiod static bfd_boolean
vms_mkobject(bfd * abfd)341*3d8817e4Smiod vms_mkobject (bfd * abfd)
342*3d8817e4Smiod {
343*3d8817e4Smiod #if VMS_DEBUG
344*3d8817e4Smiod vms_debug (1, "vms_mkobject (%p)\n", abfd);
345*3d8817e4Smiod #endif
346*3d8817e4Smiod
347*3d8817e4Smiod if (!vms_initialize (abfd))
348*3d8817e4Smiod return FALSE;
349*3d8817e4Smiod
350*3d8817e4Smiod {
351*3d8817e4Smiod #ifdef __VAX
352*3d8817e4Smiod const bfd_arch_info_type *arch = bfd_scan_arch ("vax");
353*3d8817e4Smiod #else
354*3d8817e4Smiod const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
355*3d8817e4Smiod #endif
356*3d8817e4Smiod if (arch == NULL)
357*3d8817e4Smiod {
358*3d8817e4Smiod bfd_set_error (bfd_error_wrong_format);
359*3d8817e4Smiod return FALSE;
360*3d8817e4Smiod }
361*3d8817e4Smiod abfd->arch_info = arch;
362*3d8817e4Smiod }
363*3d8817e4Smiod
364*3d8817e4Smiod return TRUE;
365*3d8817e4Smiod }
366*3d8817e4Smiod
367*3d8817e4Smiod /* Write cached information into a file being written, at bfd_close. */
368*3d8817e4Smiod
369*3d8817e4Smiod static bfd_boolean
vms_write_object_contents(bfd * abfd)370*3d8817e4Smiod vms_write_object_contents (bfd * abfd)
371*3d8817e4Smiod {
372*3d8817e4Smiod #if VMS_DEBUG
373*3d8817e4Smiod vms_debug (1, "vms_write_object_contents (%p)\n", abfd);
374*3d8817e4Smiod #endif
375*3d8817e4Smiod
376*3d8817e4Smiod if (abfd->section_count > 0) /* we have sections */
377*3d8817e4Smiod {
378*3d8817e4Smiod if (PRIV (is_vax))
379*3d8817e4Smiod {
380*3d8817e4Smiod if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
381*3d8817e4Smiod return FALSE;
382*3d8817e4Smiod if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
383*3d8817e4Smiod return FALSE;
384*3d8817e4Smiod if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
385*3d8817e4Smiod return FALSE;
386*3d8817e4Smiod if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
387*3d8817e4Smiod return FALSE;
388*3d8817e4Smiod if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
389*3d8817e4Smiod return FALSE;
390*3d8817e4Smiod if (abfd->section_count > 255)
391*3d8817e4Smiod {
392*3d8817e4Smiod if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
393*3d8817e4Smiod return FALSE;
394*3d8817e4Smiod }
395*3d8817e4Smiod else
396*3d8817e4Smiod {
397*3d8817e4Smiod if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
398*3d8817e4Smiod return FALSE;
399*3d8817e4Smiod }
400*3d8817e4Smiod }
401*3d8817e4Smiod else
402*3d8817e4Smiod {
403*3d8817e4Smiod if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
404*3d8817e4Smiod return FALSE;
405*3d8817e4Smiod if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
406*3d8817e4Smiod return FALSE;
407*3d8817e4Smiod if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
408*3d8817e4Smiod return FALSE;
409*3d8817e4Smiod if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
410*3d8817e4Smiod return FALSE;
411*3d8817e4Smiod if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
412*3d8817e4Smiod return FALSE;
413*3d8817e4Smiod if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
414*3d8817e4Smiod return FALSE;
415*3d8817e4Smiod }
416*3d8817e4Smiod }
417*3d8817e4Smiod return TRUE;
418*3d8817e4Smiod }
419*3d8817e4Smiod
420*3d8817e4Smiod /* 4.1, generic. */
421*3d8817e4Smiod
422*3d8817e4Smiod /* Called when the BFD is being closed to do any necessary cleanup. */
423*3d8817e4Smiod
424*3d8817e4Smiod static bfd_boolean
vms_close_and_cleanup(bfd * abfd)425*3d8817e4Smiod vms_close_and_cleanup (bfd * abfd)
426*3d8817e4Smiod {
427*3d8817e4Smiod #if VMS_DEBUG
428*3d8817e4Smiod vms_debug (1, "vms_close_and_cleanup (%p)\n", abfd);
429*3d8817e4Smiod #endif
430*3d8817e4Smiod if (abfd == NULL)
431*3d8817e4Smiod return TRUE;
432*3d8817e4Smiod
433*3d8817e4Smiod if (PRIV (vms_buf) != NULL)
434*3d8817e4Smiod free (PRIV (vms_buf));
435*3d8817e4Smiod
436*3d8817e4Smiod if (PRIV (sections) != NULL)
437*3d8817e4Smiod free (PRIV (sections));
438*3d8817e4Smiod
439*3d8817e4Smiod if (PRIV (vms_symbol_table))
440*3d8817e4Smiod bfd_hash_table_free (PRIV (vms_symbol_table));
441*3d8817e4Smiod
442*3d8817e4Smiod bfd_release (abfd, abfd->tdata.any);
443*3d8817e4Smiod abfd->tdata.any = NULL;
444*3d8817e4Smiod
445*3d8817e4Smiod return TRUE;
446*3d8817e4Smiod }
447*3d8817e4Smiod
448*3d8817e4Smiod /* Ask the BFD to free all cached information. */
449*3d8817e4Smiod
450*3d8817e4Smiod static bfd_boolean
vms_bfd_free_cached_info(bfd * abfd ATTRIBUTE_UNUSED)451*3d8817e4Smiod vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED)
452*3d8817e4Smiod {
453*3d8817e4Smiod #if VMS_DEBUG
454*3d8817e4Smiod vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd);
455*3d8817e4Smiod #endif
456*3d8817e4Smiod return TRUE;
457*3d8817e4Smiod }
458*3d8817e4Smiod
459*3d8817e4Smiod /* Called when a new section is created. */
460*3d8817e4Smiod
461*3d8817e4Smiod static bfd_boolean
vms_new_section_hook(bfd * abfd,asection * section)462*3d8817e4Smiod vms_new_section_hook (bfd * abfd, asection *section)
463*3d8817e4Smiod {
464*3d8817e4Smiod /* Count hasn't been incremented yet. */
465*3d8817e4Smiod unsigned int section_count = abfd->section_count + 1;
466*3d8817e4Smiod
467*3d8817e4Smiod #if VMS_DEBUG
468*3d8817e4Smiod vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
469*3d8817e4Smiod abfd, section->index, section->name, section_count);
470*3d8817e4Smiod #endif
471*3d8817e4Smiod bfd_set_section_alignment (abfd, section, 4);
472*3d8817e4Smiod
473*3d8817e4Smiod if (section_count > PRIV (section_count))
474*3d8817e4Smiod {
475*3d8817e4Smiod bfd_size_type amt = section_count;
476*3d8817e4Smiod amt *= sizeof (asection *);
477*3d8817e4Smiod PRIV (sections) = bfd_realloc (PRIV (sections), amt);
478*3d8817e4Smiod if (PRIV (sections) == NULL)
479*3d8817e4Smiod return FALSE;
480*3d8817e4Smiod PRIV (section_count) = section_count;
481*3d8817e4Smiod }
482*3d8817e4Smiod #if VMS_DEBUG
483*3d8817e4Smiod vms_debug (6, "section_count: %d\n", PRIV (section_count));
484*3d8817e4Smiod #endif
485*3d8817e4Smiod PRIV (sections)[section->index] = section;
486*3d8817e4Smiod #if VMS_DEBUG
487*3d8817e4Smiod vms_debug (7, "%d: %s\n", section->index, section->name);
488*3d8817e4Smiod #endif
489*3d8817e4Smiod
490*3d8817e4Smiod return TRUE;
491*3d8817e4Smiod }
492*3d8817e4Smiod
493*3d8817e4Smiod /* Read the contents of a section.
494*3d8817e4Smiod buf points to a buffer of buf_size bytes to be filled with
495*3d8817e4Smiod section data (starting at offset into section) */
496*3d8817e4Smiod
497*3d8817e4Smiod static bfd_boolean
vms_get_section_contents(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,void * buf ATTRIBUTE_UNUSED,file_ptr offset ATTRIBUTE_UNUSED,bfd_size_type buf_size ATTRIBUTE_UNUSED)498*3d8817e4Smiod vms_get_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
499*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
500*3d8817e4Smiod void * buf ATTRIBUTE_UNUSED,
501*3d8817e4Smiod file_ptr offset ATTRIBUTE_UNUSED,
502*3d8817e4Smiod bfd_size_type buf_size ATTRIBUTE_UNUSED)
503*3d8817e4Smiod {
504*3d8817e4Smiod #if VMS_DEBUG
505*3d8817e4Smiod vms_debug (1, "vms_get_section_contents (%p, %s, %p, off %ld, size %d)\n",
506*3d8817e4Smiod abfd, section->name, buf, offset, (int)buf_size);
507*3d8817e4Smiod #endif
508*3d8817e4Smiod
509*3d8817e4Smiod /* Shouldn't be called, since all sections are IN_MEMORY. */
510*3d8817e4Smiod return FALSE;
511*3d8817e4Smiod }
512*3d8817e4Smiod
513*3d8817e4Smiod /* Read the contents of a section.
514*3d8817e4Smiod buf points to a buffer of buf_size bytes to be filled with
515*3d8817e4Smiod section data (starting at offset into section). */
516*3d8817e4Smiod
517*3d8817e4Smiod static bfd_boolean
vms_get_section_contents_in_window(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,bfd_window * w ATTRIBUTE_UNUSED,file_ptr offset ATTRIBUTE_UNUSED,bfd_size_type count ATTRIBUTE_UNUSED)518*3d8817e4Smiod vms_get_section_contents_in_window (bfd * abfd ATTRIBUTE_UNUSED,
519*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
520*3d8817e4Smiod bfd_window *w ATTRIBUTE_UNUSED,
521*3d8817e4Smiod file_ptr offset ATTRIBUTE_UNUSED,
522*3d8817e4Smiod bfd_size_type count ATTRIBUTE_UNUSED)
523*3d8817e4Smiod {
524*3d8817e4Smiod #if VMS_DEBUG
525*3d8817e4Smiod vms_debug (1, "vms_get_section_contents_in_window (%p, %s, %p, off %ld, count %d)\n",
526*3d8817e4Smiod abfd, section->name, w, offset, (int)count);
527*3d8817e4Smiod #endif
528*3d8817e4Smiod
529*3d8817e4Smiod /* Shouldn't be called, since all sections are IN_MEMORY. */
530*3d8817e4Smiod return FALSE;
531*3d8817e4Smiod }
532*3d8817e4Smiod
533*3d8817e4Smiod /* Part 4.2, copy private data. */
534*3d8817e4Smiod
535*3d8817e4Smiod /* Called to copy BFD general private data from one object file
536*3d8817e4Smiod to another. */
537*3d8817e4Smiod
538*3d8817e4Smiod static bfd_boolean
vms_bfd_copy_private_bfd_data(bfd * src ATTRIBUTE_UNUSED,bfd * dest ATTRIBUTE_UNUSED)539*3d8817e4Smiod vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED,
540*3d8817e4Smiod bfd *dest ATTRIBUTE_UNUSED)
541*3d8817e4Smiod {
542*3d8817e4Smiod #if VMS_DEBUG
543*3d8817e4Smiod vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest);
544*3d8817e4Smiod #endif
545*3d8817e4Smiod return TRUE;
546*3d8817e4Smiod }
547*3d8817e4Smiod
548*3d8817e4Smiod /* Merge private BFD information from the BFD @var{ibfd} to the
549*3d8817e4Smiod the output file BFD @var{obfd} when linking. Return <<TRUE>>
550*3d8817e4Smiod on success, <<FALSE>> on error. Possible error returns are:
551*3d8817e4Smiod
552*3d8817e4Smiod o <<bfd_error_no_memory>> -
553*3d8817e4Smiod Not enough memory exists to create private data for @var{obfd}. */
554*3d8817e4Smiod
555*3d8817e4Smiod static bfd_boolean
vms_bfd_merge_private_bfd_data(bfd * ibfd ATTRIBUTE_UNUSED,bfd * obfd ATTRIBUTE_UNUSED)556*3d8817e4Smiod vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED,
557*3d8817e4Smiod bfd * obfd ATTRIBUTE_UNUSED)
558*3d8817e4Smiod {
559*3d8817e4Smiod #if VMS_DEBUG
560*3d8817e4Smiod vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd);
561*3d8817e4Smiod #endif
562*3d8817e4Smiod return TRUE;
563*3d8817e4Smiod }
564*3d8817e4Smiod
565*3d8817e4Smiod /* Set private BFD flag information in the BFD @var{abfd}.
566*3d8817e4Smiod Return <<TRUE>> on success, <<FALSE>> on error. Possible error
567*3d8817e4Smiod returns are:
568*3d8817e4Smiod
569*3d8817e4Smiod o <<bfd_error_no_memory>> -
570*3d8817e4Smiod Not enough memory exists to create private data for @var{obfd}. */
571*3d8817e4Smiod
572*3d8817e4Smiod static bfd_boolean
vms_bfd_set_private_flags(bfd * abfd ATTRIBUTE_UNUSED,flagword flags ATTRIBUTE_UNUSED)573*3d8817e4Smiod vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED,
574*3d8817e4Smiod flagword flags ATTRIBUTE_UNUSED)
575*3d8817e4Smiod {
576*3d8817e4Smiod #if VMS_DEBUG
577*3d8817e4Smiod vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags);
578*3d8817e4Smiod #endif
579*3d8817e4Smiod return TRUE;
580*3d8817e4Smiod }
581*3d8817e4Smiod
582*3d8817e4Smiod /* Called to copy BFD private section data from one object file
583*3d8817e4Smiod to another. */
584*3d8817e4Smiod
585*3d8817e4Smiod static bfd_boolean
vms_bfd_copy_private_section_data(bfd * srcbfd ATTRIBUTE_UNUSED,asection * srcsec ATTRIBUTE_UNUSED,bfd * dstbfd ATTRIBUTE_UNUSED,asection * dstsec ATTRIBUTE_UNUSED)586*3d8817e4Smiod vms_bfd_copy_private_section_data (bfd *srcbfd ATTRIBUTE_UNUSED,
587*3d8817e4Smiod asection *srcsec ATTRIBUTE_UNUSED,
588*3d8817e4Smiod bfd *dstbfd ATTRIBUTE_UNUSED,
589*3d8817e4Smiod asection *dstsec ATTRIBUTE_UNUSED)
590*3d8817e4Smiod {
591*3d8817e4Smiod #if VMS_DEBUG
592*3d8817e4Smiod vms_debug (1, "vms_bfd_copy_private_section_data (%p, %s, %p, %s)\n",
593*3d8817e4Smiod srcbfd, srcsec->name, dstbfd, dstsec->name);
594*3d8817e4Smiod #endif
595*3d8817e4Smiod return TRUE;
596*3d8817e4Smiod }
597*3d8817e4Smiod
598*3d8817e4Smiod /* Called to copy BFD private symbol data from one object file
599*3d8817e4Smiod to another. */
600*3d8817e4Smiod
601*3d8817e4Smiod static bfd_boolean
vms_bfd_copy_private_symbol_data(bfd * ibfd ATTRIBUTE_UNUSED,asymbol * isym ATTRIBUTE_UNUSED,bfd * obfd ATTRIBUTE_UNUSED,asymbol * osym ATTRIBUTE_UNUSED)602*3d8817e4Smiod vms_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
603*3d8817e4Smiod asymbol *isym ATTRIBUTE_UNUSED,
604*3d8817e4Smiod bfd *obfd ATTRIBUTE_UNUSED,
605*3d8817e4Smiod asymbol *osym ATTRIBUTE_UNUSED)
606*3d8817e4Smiod {
607*3d8817e4Smiod #if VMS_DEBUG
608*3d8817e4Smiod vms_debug (1, "vms_bfd_copy_private_symbol_data (%p, %s, %p, %s)\n",
609*3d8817e4Smiod ibfd, isym->name, obfd, osym->name);
610*3d8817e4Smiod #endif
611*3d8817e4Smiod return TRUE;
612*3d8817e4Smiod }
613*3d8817e4Smiod
614*3d8817e4Smiod /* Part 4.3, core file. */
615*3d8817e4Smiod
616*3d8817e4Smiod /* Return a read-only string explaining which program was running
617*3d8817e4Smiod when it failed and produced the core file abfd. */
618*3d8817e4Smiod
619*3d8817e4Smiod static char *
vms_core_file_failing_command(bfd * abfd ATTRIBUTE_UNUSED)620*3d8817e4Smiod vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED)
621*3d8817e4Smiod {
622*3d8817e4Smiod #if VMS_DEBUG
623*3d8817e4Smiod vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd);
624*3d8817e4Smiod #endif
625*3d8817e4Smiod return NULL;
626*3d8817e4Smiod }
627*3d8817e4Smiod
628*3d8817e4Smiod /* Returns the signal number which caused the core dump which
629*3d8817e4Smiod generated the file the BFD abfd is attached to. */
630*3d8817e4Smiod
631*3d8817e4Smiod static int
vms_core_file_failing_signal(bfd * abfd ATTRIBUTE_UNUSED)632*3d8817e4Smiod vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED)
633*3d8817e4Smiod {
634*3d8817e4Smiod #if VMS_DEBUG
635*3d8817e4Smiod vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd);
636*3d8817e4Smiod #endif
637*3d8817e4Smiod return 0;
638*3d8817e4Smiod }
639*3d8817e4Smiod
640*3d8817e4Smiod /* Return TRUE if the core file attached to core_bfd was generated
641*3d8817e4Smiod by a run of the executable file attached to exec_bfd, FALSE otherwise. */
642*3d8817e4Smiod
643*3d8817e4Smiod static bfd_boolean
vms_core_file_matches_executable_p(bfd * abfd ATTRIBUTE_UNUSED,bfd * bbfd ATTRIBUTE_UNUSED)644*3d8817e4Smiod vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED,
645*3d8817e4Smiod bfd *bbfd ATTRIBUTE_UNUSED)
646*3d8817e4Smiod {
647*3d8817e4Smiod #if VMS_DEBUG
648*3d8817e4Smiod vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd);
649*3d8817e4Smiod #endif
650*3d8817e4Smiod return FALSE;
651*3d8817e4Smiod }
652*3d8817e4Smiod
653*3d8817e4Smiod /* Part 4.4, archive. */
654*3d8817e4Smiod
655*3d8817e4Smiod /* ??? do something with an archive map.
656*3d8817e4Smiod Return FALSE on error, TRUE otherwise. */
657*3d8817e4Smiod
658*3d8817e4Smiod static bfd_boolean
vms_slurp_armap(bfd * abfd ATTRIBUTE_UNUSED)659*3d8817e4Smiod vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED)
660*3d8817e4Smiod {
661*3d8817e4Smiod #if VMS_DEBUG
662*3d8817e4Smiod vms_debug (1, "vms_slurp_armap (%p)\n", abfd);
663*3d8817e4Smiod #endif
664*3d8817e4Smiod return FALSE;
665*3d8817e4Smiod }
666*3d8817e4Smiod
667*3d8817e4Smiod /* ??? do something with an extended name table.
668*3d8817e4Smiod Return FALSE on error, TRUE otherwise. */
669*3d8817e4Smiod
670*3d8817e4Smiod static bfd_boolean
vms_slurp_extended_name_table(bfd * abfd ATTRIBUTE_UNUSED)671*3d8817e4Smiod vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED)
672*3d8817e4Smiod {
673*3d8817e4Smiod #if VMS_DEBUG
674*3d8817e4Smiod vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd);
675*3d8817e4Smiod #endif
676*3d8817e4Smiod return FALSE;
677*3d8817e4Smiod }
678*3d8817e4Smiod
679*3d8817e4Smiod /* ??? do something with an extended name table.
680*3d8817e4Smiod Return FALSE on error, TRUE otherwise. */
681*3d8817e4Smiod
682*3d8817e4Smiod static bfd_boolean
vms_construct_extended_name_table(bfd * abfd ATTRIBUTE_UNUSED,char ** tabloc ATTRIBUTE_UNUSED,bfd_size_type * tablen ATTRIBUTE_UNUSED,const char ** name ATTRIBUTE_UNUSED)683*3d8817e4Smiod vms_construct_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED,
684*3d8817e4Smiod char **tabloc ATTRIBUTE_UNUSED,
685*3d8817e4Smiod bfd_size_type *tablen ATTRIBUTE_UNUSED,
686*3d8817e4Smiod const char **name ATTRIBUTE_UNUSED)
687*3d8817e4Smiod {
688*3d8817e4Smiod #if VMS_DEBUG
689*3d8817e4Smiod vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd);
690*3d8817e4Smiod #endif
691*3d8817e4Smiod return FALSE;
692*3d8817e4Smiod }
693*3d8817e4Smiod
694*3d8817e4Smiod /* Truncate the name of an archive to match system-dependent restrictions. */
695*3d8817e4Smiod
696*3d8817e4Smiod static void
vms_truncate_arname(bfd * abfd ATTRIBUTE_UNUSED,const char * pathname ATTRIBUTE_UNUSED,char * arhdr ATTRIBUTE_UNUSED)697*3d8817e4Smiod vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED,
698*3d8817e4Smiod const char *pathname ATTRIBUTE_UNUSED,
699*3d8817e4Smiod char *arhdr ATTRIBUTE_UNUSED)
700*3d8817e4Smiod {
701*3d8817e4Smiod #if VMS_DEBUG
702*3d8817e4Smiod vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr);
703*3d8817e4Smiod #endif
704*3d8817e4Smiod return;
705*3d8817e4Smiod }
706*3d8817e4Smiod
707*3d8817e4Smiod /* ??? write archive map. */
708*3d8817e4Smiod
709*3d8817e4Smiod static bfd_boolean
vms_write_armap(bfd * arch ATTRIBUTE_UNUSED,unsigned int elength ATTRIBUTE_UNUSED,struct orl * map ATTRIBUTE_UNUSED,unsigned int orl_count ATTRIBUTE_UNUSED,int stridx ATTRIBUTE_UNUSED)710*3d8817e4Smiod vms_write_armap (bfd *arch ATTRIBUTE_UNUSED,
711*3d8817e4Smiod unsigned int elength ATTRIBUTE_UNUSED,
712*3d8817e4Smiod struct orl *map ATTRIBUTE_UNUSED,
713*3d8817e4Smiod unsigned int orl_count ATTRIBUTE_UNUSED,
714*3d8817e4Smiod int stridx ATTRIBUTE_UNUSED)
715*3d8817e4Smiod {
716*3d8817e4Smiod #if VMS_DEBUG
717*3d8817e4Smiod vms_debug (1, "vms_write_armap (%p, %d, %p, %d %d)\n",
718*3d8817e4Smiod arch, elength, map, orl_count, stridx);
719*3d8817e4Smiod #endif
720*3d8817e4Smiod return TRUE;
721*3d8817e4Smiod }
722*3d8817e4Smiod
723*3d8817e4Smiod /* Read archive header ??? */
724*3d8817e4Smiod
725*3d8817e4Smiod static void *
vms_read_ar_hdr(bfd * abfd ATTRIBUTE_UNUSED)726*3d8817e4Smiod vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED)
727*3d8817e4Smiod {
728*3d8817e4Smiod #if VMS_DEBUG
729*3d8817e4Smiod vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd);
730*3d8817e4Smiod #endif
731*3d8817e4Smiod return NULL;
732*3d8817e4Smiod }
733*3d8817e4Smiod
734*3d8817e4Smiod /* Provided a BFD, @var{archive}, containing an archive and NULL, open
735*3d8817e4Smiod an input BFD on the first contained element and returns that.
736*3d8817e4Smiod Subsequent calls should pass the archive and the previous return value
737*3d8817e4Smiod to return a created BFD to the next contained element.
738*3d8817e4Smiod NULL is returned when there are no more. */
739*3d8817e4Smiod
740*3d8817e4Smiod static bfd *
vms_openr_next_archived_file(bfd * arch ATTRIBUTE_UNUSED,bfd * prev ATTRIBUTE_UNUSED)741*3d8817e4Smiod vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED,
742*3d8817e4Smiod bfd *prev ATTRIBUTE_UNUSED)
743*3d8817e4Smiod {
744*3d8817e4Smiod #if VMS_DEBUG
745*3d8817e4Smiod vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev);
746*3d8817e4Smiod #endif
747*3d8817e4Smiod return NULL;
748*3d8817e4Smiod }
749*3d8817e4Smiod
750*3d8817e4Smiod /* Return the BFD which is referenced by the symbol in ABFD indexed by
751*3d8817e4Smiod INDEX. INDEX should have been returned by bfd_get_next_mapent. */
752*3d8817e4Smiod
753*3d8817e4Smiod static bfd *
vms_get_elt_at_index(bfd * abfd,symindex index)754*3d8817e4Smiod vms_get_elt_at_index (bfd * abfd, symindex index)
755*3d8817e4Smiod {
756*3d8817e4Smiod #if VMS_DEBUG
757*3d8817e4Smiod vms_debug (1, "vms_get_elt_at_index (%p, %p)\n", abfd, index);
758*3d8817e4Smiod #endif
759*3d8817e4Smiod return _bfd_generic_get_elt_at_index (abfd, index);
760*3d8817e4Smiod }
761*3d8817e4Smiod
762*3d8817e4Smiod /* ???
763*3d8817e4Smiod -> bfd_generic_stat_arch_elt. */
764*3d8817e4Smiod
765*3d8817e4Smiod static int
vms_generic_stat_arch_elt(bfd * abfd,struct stat * st)766*3d8817e4Smiod vms_generic_stat_arch_elt (bfd * abfd, struct stat *st)
767*3d8817e4Smiod {
768*3d8817e4Smiod #if VMS_DEBUG
769*3d8817e4Smiod vms_debug (1, "vms_generic_stat_arch_elt (%p, %p)\n", abfd, st);
770*3d8817e4Smiod #endif
771*3d8817e4Smiod return bfd_generic_stat_arch_elt (abfd, st);
772*3d8817e4Smiod }
773*3d8817e4Smiod
774*3d8817e4Smiod /* This is a new function in bfd 2.5. */
775*3d8817e4Smiod
776*3d8817e4Smiod static bfd_boolean
vms_update_armap_timestamp(bfd * abfd ATTRIBUTE_UNUSED)777*3d8817e4Smiod vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED)
778*3d8817e4Smiod {
779*3d8817e4Smiod #if VMS_DEBUG
780*3d8817e4Smiod vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd);
781*3d8817e4Smiod #endif
782*3d8817e4Smiod return TRUE;
783*3d8817e4Smiod }
784*3d8817e4Smiod
785*3d8817e4Smiod /* Part 4.5, symbols. */
786*3d8817e4Smiod
787*3d8817e4Smiod /* Return the number of bytes required to store a vector of pointers
788*3d8817e4Smiod to asymbols for all the symbols in the BFD abfd, including a
789*3d8817e4Smiod terminal NULL pointer. If there are no symbols in the BFD,
790*3d8817e4Smiod then return 0. If an error occurs, return -1. */
791*3d8817e4Smiod
792*3d8817e4Smiod static long
vms_get_symtab_upper_bound(bfd * abfd)793*3d8817e4Smiod vms_get_symtab_upper_bound (bfd * abfd)
794*3d8817e4Smiod {
795*3d8817e4Smiod #if VMS_DEBUG
796*3d8817e4Smiod vms_debug (1, "vms_get_symtab_upper_bound (%p), %d symbols\n", abfd, PRIV (gsd_sym_count));
797*3d8817e4Smiod #endif
798*3d8817e4Smiod return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
799*3d8817e4Smiod }
800*3d8817e4Smiod
801*3d8817e4Smiod /* Copy symbols from hash table to symbol vector
802*3d8817e4Smiod
803*3d8817e4Smiod called from bfd_hash_traverse in vms_canonicalize_symtab
804*3d8817e4Smiod init counter to 0 if entry == 0. */
805*3d8817e4Smiod
806*3d8817e4Smiod static bfd_boolean
copy_symbols(struct bfd_hash_entry * entry,void * arg)807*3d8817e4Smiod copy_symbols (struct bfd_hash_entry *entry, void * arg)
808*3d8817e4Smiod {
809*3d8817e4Smiod bfd * abfd = (bfd *) arg;
810*3d8817e4Smiod
811*3d8817e4Smiod if (entry == NULL) /* Init counter. */
812*3d8817e4Smiod PRIV (symnum) = 0;
813*3d8817e4Smiod else /* Fill vector, inc counter. */
814*3d8817e4Smiod PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol;
815*3d8817e4Smiod
816*3d8817e4Smiod return TRUE;
817*3d8817e4Smiod }
818*3d8817e4Smiod
819*3d8817e4Smiod /* Read the symbols from the BFD abfd, and fills in the vector
820*3d8817e4Smiod location with pointers to the symbols and a trailing NULL.
821*3d8817e4Smiod
822*3d8817e4Smiod Return number of symbols read. */
823*3d8817e4Smiod
824*3d8817e4Smiod static long
vms_canonicalize_symtab(bfd * abfd,asymbol ** symbols)825*3d8817e4Smiod vms_canonicalize_symtab (bfd * abfd, asymbol **symbols)
826*3d8817e4Smiod {
827*3d8817e4Smiod #if VMS_DEBUG
828*3d8817e4Smiod vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd);
829*3d8817e4Smiod #endif
830*3d8817e4Smiod
831*3d8817e4Smiod /* Init counter. */
832*3d8817e4Smiod copy_symbols (NULL, abfd);
833*3d8817e4Smiod
834*3d8817e4Smiod /* Traverse table and fill symbols vector. */
835*3d8817e4Smiod PRIV (symcache) = symbols;
836*3d8817e4Smiod bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd);
837*3d8817e4Smiod
838*3d8817e4Smiod symbols[PRIV (gsd_sym_count)] = NULL;
839*3d8817e4Smiod
840*3d8817e4Smiod return PRIV (gsd_sym_count);
841*3d8817e4Smiod }
842*3d8817e4Smiod
843*3d8817e4Smiod /* Print symbol to file according to how. how is one of
844*3d8817e4Smiod bfd_print_symbol_name just print the name
845*3d8817e4Smiod bfd_print_symbol_more print more (???)
846*3d8817e4Smiod bfd_print_symbol_all print all we know, which is not much right now :-). */
847*3d8817e4Smiod
848*3d8817e4Smiod static void
vms_print_symbol(bfd * abfd,void * file,asymbol * symbol,bfd_print_symbol_type how)849*3d8817e4Smiod vms_print_symbol (bfd * abfd,
850*3d8817e4Smiod void * file,
851*3d8817e4Smiod asymbol *symbol,
852*3d8817e4Smiod bfd_print_symbol_type how)
853*3d8817e4Smiod {
854*3d8817e4Smiod #if VMS_DEBUG
855*3d8817e4Smiod vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how);
856*3d8817e4Smiod #endif
857*3d8817e4Smiod
858*3d8817e4Smiod switch (how)
859*3d8817e4Smiod {
860*3d8817e4Smiod case bfd_print_symbol_name:
861*3d8817e4Smiod case bfd_print_symbol_more:
862*3d8817e4Smiod fprintf ((FILE *)file," %s", symbol->name);
863*3d8817e4Smiod break;
864*3d8817e4Smiod
865*3d8817e4Smiod case bfd_print_symbol_all:
866*3d8817e4Smiod {
867*3d8817e4Smiod const char *section_name = symbol->section->name;
868*3d8817e4Smiod
869*3d8817e4Smiod bfd_print_symbol_vandf (abfd, file, symbol);
870*3d8817e4Smiod
871*3d8817e4Smiod fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
872*3d8817e4Smiod }
873*3d8817e4Smiod break;
874*3d8817e4Smiod }
875*3d8817e4Smiod }
876*3d8817e4Smiod
877*3d8817e4Smiod /* Return information about symbol in ret.
878*3d8817e4Smiod
879*3d8817e4Smiod fill type, value and name
880*3d8817e4Smiod type:
881*3d8817e4Smiod A absolute
882*3d8817e4Smiod B bss segment symbol
883*3d8817e4Smiod C common symbol
884*3d8817e4Smiod D data segment symbol
885*3d8817e4Smiod f filename
886*3d8817e4Smiod t a static function symbol
887*3d8817e4Smiod T text segment symbol
888*3d8817e4Smiod U undefined
889*3d8817e4Smiod - debug. */
890*3d8817e4Smiod
891*3d8817e4Smiod static void
vms_get_symbol_info(bfd * abfd ATTRIBUTE_UNUSED,asymbol * symbol,symbol_info * ret)892*3d8817e4Smiod vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
893*3d8817e4Smiod asymbol *symbol,
894*3d8817e4Smiod symbol_info *ret)
895*3d8817e4Smiod {
896*3d8817e4Smiod asection *sec;
897*3d8817e4Smiod
898*3d8817e4Smiod #if VMS_DEBUG
899*3d8817e4Smiod vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret);
900*3d8817e4Smiod #endif
901*3d8817e4Smiod
902*3d8817e4Smiod sec = symbol->section;
903*3d8817e4Smiod
904*3d8817e4Smiod if (ret == NULL)
905*3d8817e4Smiod return;
906*3d8817e4Smiod
907*3d8817e4Smiod if (bfd_is_com_section (sec))
908*3d8817e4Smiod ret->type = 'C';
909*3d8817e4Smiod else if (bfd_is_abs_section (sec))
910*3d8817e4Smiod ret->type = 'A';
911*3d8817e4Smiod else if (bfd_is_und_section (sec))
912*3d8817e4Smiod ret->type = 'U';
913*3d8817e4Smiod else if (bfd_is_ind_section (sec))
914*3d8817e4Smiod ret->type = 'I';
915*3d8817e4Smiod else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
916*3d8817e4Smiod ret->type = 'T';
917*3d8817e4Smiod else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
918*3d8817e4Smiod ret->type = 'D';
919*3d8817e4Smiod else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
920*3d8817e4Smiod ret->type = 'B';
921*3d8817e4Smiod else
922*3d8817e4Smiod ret->type = '-';
923*3d8817e4Smiod
924*3d8817e4Smiod if (ret->type != 'U')
925*3d8817e4Smiod ret->value = symbol->value + symbol->section->vma;
926*3d8817e4Smiod else
927*3d8817e4Smiod ret->value = 0;
928*3d8817e4Smiod ret->name = symbol->name;
929*3d8817e4Smiod }
930*3d8817e4Smiod
931*3d8817e4Smiod /* Return TRUE if the given symbol sym in the BFD abfd is
932*3d8817e4Smiod a compiler generated local label, else return FALSE. */
933*3d8817e4Smiod
934*3d8817e4Smiod static bfd_boolean
vms_bfd_is_local_label_name(bfd * abfd ATTRIBUTE_UNUSED,const char * name)935*3d8817e4Smiod vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
936*3d8817e4Smiod const char *name)
937*3d8817e4Smiod {
938*3d8817e4Smiod #if VMS_DEBUG
939*3d8817e4Smiod vms_debug (1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name);
940*3d8817e4Smiod #endif
941*3d8817e4Smiod return name[0] == '$';
942*3d8817e4Smiod }
943*3d8817e4Smiod
944*3d8817e4Smiod /* Get source line number for symbol. */
945*3d8817e4Smiod
946*3d8817e4Smiod static alent *
vms_get_lineno(bfd * abfd ATTRIBUTE_UNUSED,asymbol * symbol ATTRIBUTE_UNUSED)947*3d8817e4Smiod vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED,
948*3d8817e4Smiod asymbol *symbol ATTRIBUTE_UNUSED)
949*3d8817e4Smiod {
950*3d8817e4Smiod #if VMS_DEBUG
951*3d8817e4Smiod vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol);
952*3d8817e4Smiod #endif
953*3d8817e4Smiod return NULL;
954*3d8817e4Smiod }
955*3d8817e4Smiod
956*3d8817e4Smiod /* Provided a BFD, a section and an offset into the section, calculate and
957*3d8817e4Smiod return the name of the source file and the line nearest to the wanted
958*3d8817e4Smiod location. */
959*3d8817e4Smiod
960*3d8817e4Smiod static bfd_boolean
vms_find_nearest_line(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED,bfd_vma offset ATTRIBUTE_UNUSED,const char ** file ATTRIBUTE_UNUSED,const char ** func ATTRIBUTE_UNUSED,unsigned int * line ATTRIBUTE_UNUSED)961*3d8817e4Smiod vms_find_nearest_line (bfd * abfd ATTRIBUTE_UNUSED,
962*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
963*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED,
964*3d8817e4Smiod bfd_vma offset ATTRIBUTE_UNUSED,
965*3d8817e4Smiod const char **file ATTRIBUTE_UNUSED,
966*3d8817e4Smiod const char **func ATTRIBUTE_UNUSED,
967*3d8817e4Smiod unsigned int *line ATTRIBUTE_UNUSED)
968*3d8817e4Smiod {
969*3d8817e4Smiod #if VMS_DEBUG
970*3d8817e4Smiod vms_debug (1, "vms_find_nearest_line (%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
971*3d8817e4Smiod abfd, section->name, symbols, (long int)offset);
972*3d8817e4Smiod #endif
973*3d8817e4Smiod return FALSE;
974*3d8817e4Smiod }
975*3d8817e4Smiod
976*3d8817e4Smiod static bfd_boolean
vms_find_inliner_info(bfd * abfd ATTRIBUTE_UNUSED,const char ** file ATTRIBUTE_UNUSED,const char ** func ATTRIBUTE_UNUSED,unsigned int * line ATTRIBUTE_UNUSED)977*3d8817e4Smiod vms_find_inliner_info (bfd * abfd ATTRIBUTE_UNUSED,
978*3d8817e4Smiod const char **file ATTRIBUTE_UNUSED,
979*3d8817e4Smiod const char **func ATTRIBUTE_UNUSED,
980*3d8817e4Smiod unsigned int *line ATTRIBUTE_UNUSED)
981*3d8817e4Smiod {
982*3d8817e4Smiod #if VMS_DEBUG
983*3d8817e4Smiod vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n",
984*3d8817e4Smiod abfd);
985*3d8817e4Smiod #endif
986*3d8817e4Smiod return FALSE;
987*3d8817e4Smiod }
988*3d8817e4Smiod
989*3d8817e4Smiod /* Back-door to allow format-aware applications to create debug symbols
990*3d8817e4Smiod while using BFD for everything else. Currently used by the assembler
991*3d8817e4Smiod when creating COFF files. */
992*3d8817e4Smiod
993*3d8817e4Smiod static asymbol *
vms_bfd_make_debug_symbol(bfd * abfd ATTRIBUTE_UNUSED,void * ptr ATTRIBUTE_UNUSED,unsigned long size ATTRIBUTE_UNUSED)994*3d8817e4Smiod vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED,
995*3d8817e4Smiod void *ptr ATTRIBUTE_UNUSED,
996*3d8817e4Smiod unsigned long size ATTRIBUTE_UNUSED)
997*3d8817e4Smiod {
998*3d8817e4Smiod #if VMS_DEBUG
999*3d8817e4Smiod vms_debug (1, "vms_bfd_make_debug_symbol (%p, %p, %ld)\n", abfd, ptr, size);
1000*3d8817e4Smiod #endif
1001*3d8817e4Smiod return NULL;
1002*3d8817e4Smiod }
1003*3d8817e4Smiod
1004*3d8817e4Smiod /* Read minisymbols. For minisymbols, we use the unmodified a.out
1005*3d8817e4Smiod symbols. The minisymbol_to_symbol function translates these into
1006*3d8817e4Smiod BFD asymbol structures. */
1007*3d8817e4Smiod
1008*3d8817e4Smiod static long
vms_read_minisymbols(bfd * abfd,bfd_boolean dynamic,void ** minisymsp,unsigned int * sizep)1009*3d8817e4Smiod vms_read_minisymbols (bfd * abfd,
1010*3d8817e4Smiod bfd_boolean dynamic,
1011*3d8817e4Smiod void * *minisymsp,
1012*3d8817e4Smiod unsigned int *sizep)
1013*3d8817e4Smiod {
1014*3d8817e4Smiod #if VMS_DEBUG
1015*3d8817e4Smiod vms_debug (1, "vms_read_minisymbols (%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
1016*3d8817e4Smiod #endif
1017*3d8817e4Smiod return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
1018*3d8817e4Smiod }
1019*3d8817e4Smiod
1020*3d8817e4Smiod /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1021*3d8817e4Smiod unmodified a.out symbol. The SYM argument is a structure returned
1022*3d8817e4Smiod by bfd_make_empty_symbol, which we fill in here. */
1023*3d8817e4Smiod
1024*3d8817e4Smiod static asymbol *
vms_minisymbol_to_symbol(bfd * abfd,bfd_boolean dynamic,const void * minisym,asymbol * sym)1025*3d8817e4Smiod vms_minisymbol_to_symbol (bfd * abfd,
1026*3d8817e4Smiod bfd_boolean dynamic,
1027*3d8817e4Smiod const void * minisym,
1028*3d8817e4Smiod asymbol *sym)
1029*3d8817e4Smiod {
1030*3d8817e4Smiod #if VMS_DEBUG
1031*3d8817e4Smiod vms_debug (1, "vms_minisymbol_to_symbol (%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
1032*3d8817e4Smiod #endif
1033*3d8817e4Smiod return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
1034*3d8817e4Smiod }
1035*3d8817e4Smiod
1036*3d8817e4Smiod /* Part 4.6, relocations. */
1037*3d8817e4Smiod
1038*3d8817e4Smiod /* Return the number of bytes required to store the relocation information
1039*3d8817e4Smiod associated with section sect attached to bfd abfd.
1040*3d8817e4Smiod If an error occurs, return -1. */
1041*3d8817e4Smiod
1042*3d8817e4Smiod static long
vms_get_reloc_upper_bound(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED)1043*3d8817e4Smiod vms_get_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED,
1044*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED)
1045*3d8817e4Smiod {
1046*3d8817e4Smiod #if VMS_DEBUG
1047*3d8817e4Smiod vms_debug (1, "vms_get_reloc_upper_bound (%p, %s)\n", abfd, section->name);
1048*3d8817e4Smiod #endif
1049*3d8817e4Smiod return -1L;
1050*3d8817e4Smiod }
1051*3d8817e4Smiod
1052*3d8817e4Smiod /* Call the back end associated with the open BFD abfd and translate the
1053*3d8817e4Smiod external form of the relocation information attached to sec into the
1054*3d8817e4Smiod internal canonical form. Place the table into memory at loc, which has
1055*3d8817e4Smiod been preallocated, usually by a call to bfd_get_reloc_upper_bound.
1056*3d8817e4Smiod Returns the number of relocs, or -1 on error. */
1057*3d8817e4Smiod
1058*3d8817e4Smiod static long
vms_canonicalize_reloc(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,arelent ** location ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED)1059*3d8817e4Smiod vms_canonicalize_reloc (bfd * abfd ATTRIBUTE_UNUSED,
1060*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
1061*3d8817e4Smiod arelent **location ATTRIBUTE_UNUSED,
1062*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED)
1063*3d8817e4Smiod {
1064*3d8817e4Smiod #if VMS_DEBUG
1065*3d8817e4Smiod vms_debug (1, "vms_canonicalize_reloc (%p, %s, <ret>, <ret>)\n", abfd, section->name);
1066*3d8817e4Smiod #endif
1067*3d8817e4Smiod return FALSE;
1068*3d8817e4Smiod }
1069*3d8817e4Smiod
1070*3d8817e4Smiod /* This is just copied from ecoff-alpha, needs to be fixed probably. */
1071*3d8817e4Smiod
1072*3d8817e4Smiod /* How to process the various reloc types. */
1073*3d8817e4Smiod
1074*3d8817e4Smiod static bfd_reloc_status_type
reloc_nil(bfd * abfd ATTRIBUTE_UNUSED,arelent * reloc ATTRIBUTE_UNUSED,asymbol * sym ATTRIBUTE_UNUSED,void * data ATTRIBUTE_UNUSED,asection * sec ATTRIBUTE_UNUSED,bfd * output_bfd ATTRIBUTE_UNUSED,char ** error_message ATTRIBUTE_UNUSED)1075*3d8817e4Smiod reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
1076*3d8817e4Smiod arelent *reloc ATTRIBUTE_UNUSED,
1077*3d8817e4Smiod asymbol *sym ATTRIBUTE_UNUSED,
1078*3d8817e4Smiod void * data ATTRIBUTE_UNUSED,
1079*3d8817e4Smiod asection *sec ATTRIBUTE_UNUSED,
1080*3d8817e4Smiod bfd *output_bfd ATTRIBUTE_UNUSED,
1081*3d8817e4Smiod char **error_message ATTRIBUTE_UNUSED)
1082*3d8817e4Smiod {
1083*3d8817e4Smiod #if VMS_DEBUG
1084*3d8817e4Smiod vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
1085*3d8817e4Smiod vms_debug (2, "In section %s, symbol %s\n",
1086*3d8817e4Smiod sec->name, sym->name);
1087*3d8817e4Smiod vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1088*3d8817e4Smiod reloc->sym_ptr_ptr[0]->name,
1089*3d8817e4Smiod (unsigned long)reloc->address,
1090*3d8817e4Smiod (unsigned long)reloc->addend, reloc->howto->name);
1091*3d8817e4Smiod vms_debug (2, "data at %p\n", data);
1092*3d8817e4Smiod /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
1093*3d8817e4Smiod #endif
1094*3d8817e4Smiod
1095*3d8817e4Smiod return bfd_reloc_ok;
1096*3d8817e4Smiod }
1097*3d8817e4Smiod
1098*3d8817e4Smiod /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1099*3d8817e4Smiod from smaller values. Start with zero, widen, *then* decrement. */
1100*3d8817e4Smiod #define MINUS_ONE (((bfd_vma)0) - 1)
1101*3d8817e4Smiod
1102*3d8817e4Smiod static reloc_howto_type alpha_howto_table[] =
1103*3d8817e4Smiod {
1104*3d8817e4Smiod HOWTO (ALPHA_R_IGNORE, /* Type. */
1105*3d8817e4Smiod 0, /* Rightshift. */
1106*3d8817e4Smiod 0, /* Size (0 = byte, 1 = short, 2 = long). */
1107*3d8817e4Smiod 8, /* Bitsize. */
1108*3d8817e4Smiod TRUE, /* PC relative. */
1109*3d8817e4Smiod 0, /* Bitpos. */
1110*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1111*3d8817e4Smiod reloc_nil, /* Special_function. */
1112*3d8817e4Smiod "IGNORE", /* Name. */
1113*3d8817e4Smiod TRUE, /* Partial_inplace. */
1114*3d8817e4Smiod 0, /* Source mask */
1115*3d8817e4Smiod 0, /* Dest mask. */
1116*3d8817e4Smiod TRUE), /* PC rel offset. */
1117*3d8817e4Smiod
1118*3d8817e4Smiod /* A 64 bit reference to a symbol. */
1119*3d8817e4Smiod HOWTO (ALPHA_R_REFQUAD, /* Type. */
1120*3d8817e4Smiod 0, /* Rightshift. */
1121*3d8817e4Smiod 4, /* Size (0 = byte, 1 = short, 2 = long). */
1122*3d8817e4Smiod 64, /* Bitsize. */
1123*3d8817e4Smiod FALSE, /* PC relative. */
1124*3d8817e4Smiod 0, /* Bitpos. */
1125*3d8817e4Smiod complain_overflow_bitfield, /* Complain_on_overflow. */
1126*3d8817e4Smiod reloc_nil, /* Special_function. */
1127*3d8817e4Smiod "REFQUAD", /* Name. */
1128*3d8817e4Smiod TRUE, /* Partial_inplace. */
1129*3d8817e4Smiod MINUS_ONE, /* Source mask. */
1130*3d8817e4Smiod MINUS_ONE, /* Dest mask. */
1131*3d8817e4Smiod FALSE), /* PC rel offset. */
1132*3d8817e4Smiod
1133*3d8817e4Smiod /* A 21 bit branch. The native assembler generates these for
1134*3d8817e4Smiod branches within the text segment, and also fills in the PC
1135*3d8817e4Smiod relative offset in the instruction. */
1136*3d8817e4Smiod HOWTO (ALPHA_R_BRADDR, /* Type. */
1137*3d8817e4Smiod 2, /* Rightshift. */
1138*3d8817e4Smiod 2, /* Size (0 = byte, 1 = short, 2 = long). */
1139*3d8817e4Smiod 21, /* Bitsize. */
1140*3d8817e4Smiod TRUE, /* PC relative. */
1141*3d8817e4Smiod 0, /* Bitpos. */
1142*3d8817e4Smiod complain_overflow_signed, /* Complain_on_overflow. */
1143*3d8817e4Smiod reloc_nil, /* Special_function. */
1144*3d8817e4Smiod "BRADDR", /* Name. */
1145*3d8817e4Smiod TRUE, /* Partial_inplace. */
1146*3d8817e4Smiod 0x1fffff, /* Source mask. */
1147*3d8817e4Smiod 0x1fffff, /* Dest mask. */
1148*3d8817e4Smiod FALSE), /* PC rel offset. */
1149*3d8817e4Smiod
1150*3d8817e4Smiod /* A hint for a jump to a register. */
1151*3d8817e4Smiod HOWTO (ALPHA_R_HINT, /* Type. */
1152*3d8817e4Smiod 2, /* Rightshift. */
1153*3d8817e4Smiod 1, /* Size (0 = byte, 1 = short, 2 = long). */
1154*3d8817e4Smiod 14, /* Bitsize. */
1155*3d8817e4Smiod TRUE, /* PC relative. */
1156*3d8817e4Smiod 0, /* Bitpos. */
1157*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1158*3d8817e4Smiod reloc_nil, /* Special_function. */
1159*3d8817e4Smiod "HINT", /* Name. */
1160*3d8817e4Smiod TRUE, /* Partial_inplace. */
1161*3d8817e4Smiod 0x3fff, /* Source mask. */
1162*3d8817e4Smiod 0x3fff, /* Dest mask. */
1163*3d8817e4Smiod FALSE), /* PC rel offset. */
1164*3d8817e4Smiod
1165*3d8817e4Smiod /* 16 bit PC relative offset. */
1166*3d8817e4Smiod HOWTO (ALPHA_R_SREL16, /* Type. */
1167*3d8817e4Smiod 0, /* Rightshift. */
1168*3d8817e4Smiod 1, /* Size (0 = byte, 1 = short, 2 = long). */
1169*3d8817e4Smiod 16, /* Bitsize. */
1170*3d8817e4Smiod TRUE, /* PC relative. */
1171*3d8817e4Smiod 0, /* Bitpos. */
1172*3d8817e4Smiod complain_overflow_signed, /* Complain_on_overflow. */
1173*3d8817e4Smiod reloc_nil, /* Special_function. */
1174*3d8817e4Smiod "SREL16", /* Name. */
1175*3d8817e4Smiod TRUE, /* Partial_inplace. */
1176*3d8817e4Smiod 0xffff, /* Source mask. */
1177*3d8817e4Smiod 0xffff, /* Dest mask. */
1178*3d8817e4Smiod FALSE), /* PC rel offset. */
1179*3d8817e4Smiod
1180*3d8817e4Smiod /* 32 bit PC relative offset. */
1181*3d8817e4Smiod HOWTO (ALPHA_R_SREL32, /* Type. */
1182*3d8817e4Smiod 0, /* Rightshift. */
1183*3d8817e4Smiod 2, /* Size (0 = byte, 1 = short, 2 = long). */
1184*3d8817e4Smiod 32, /* Bitsize. */
1185*3d8817e4Smiod TRUE, /* PC relative. */
1186*3d8817e4Smiod 0, /* Bitpos. */
1187*3d8817e4Smiod complain_overflow_signed, /* Complain_on_overflow. */
1188*3d8817e4Smiod reloc_nil, /* Special_function. */
1189*3d8817e4Smiod "SREL32", /* Name. */
1190*3d8817e4Smiod TRUE, /* Partial_inplace. */
1191*3d8817e4Smiod 0xffffffff, /* Source mask. */
1192*3d8817e4Smiod 0xffffffff, /* Dest mask. */
1193*3d8817e4Smiod FALSE), /* PC rel offset. */
1194*3d8817e4Smiod
1195*3d8817e4Smiod /* A 64 bit PC relative offset. */
1196*3d8817e4Smiod HOWTO (ALPHA_R_SREL64, /* Type. */
1197*3d8817e4Smiod 0, /* Rightshift. */
1198*3d8817e4Smiod 4, /* Size (0 = byte, 1 = short, 2 = long). */
1199*3d8817e4Smiod 64, /* Bitsize. */
1200*3d8817e4Smiod TRUE, /* PC relative. */
1201*3d8817e4Smiod 0, /* Bitpos. */
1202*3d8817e4Smiod complain_overflow_signed, /* Complain_on_overflow. */
1203*3d8817e4Smiod reloc_nil, /* Special_function. */
1204*3d8817e4Smiod "SREL64", /* Name. */
1205*3d8817e4Smiod TRUE, /* Partial_inplace. */
1206*3d8817e4Smiod MINUS_ONE, /* Source mask. */
1207*3d8817e4Smiod MINUS_ONE, /* Dest mask. */
1208*3d8817e4Smiod FALSE), /* PC rel offset. */
1209*3d8817e4Smiod
1210*3d8817e4Smiod /* Push a value on the reloc evaluation stack. */
1211*3d8817e4Smiod HOWTO (ALPHA_R_OP_PUSH, /* Type. */
1212*3d8817e4Smiod 0, /* Rightshift. */
1213*3d8817e4Smiod 0, /* Size (0 = byte, 1 = short, 2 = long). */
1214*3d8817e4Smiod 0, /* Bitsize. */
1215*3d8817e4Smiod FALSE, /* PC relative. */
1216*3d8817e4Smiod 0, /* Bitpos. */
1217*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1218*3d8817e4Smiod reloc_nil, /* Special_function. */
1219*3d8817e4Smiod "OP_PUSH", /* Name. */
1220*3d8817e4Smiod FALSE, /* Partial_inplace. */
1221*3d8817e4Smiod 0, /* Source mask. */
1222*3d8817e4Smiod 0, /* Dest mask. */
1223*3d8817e4Smiod FALSE), /* PC rel offset. */
1224*3d8817e4Smiod
1225*3d8817e4Smiod /* Store the value from the stack at the given address. Store it in
1226*3d8817e4Smiod a bitfield of size r_size starting at bit position r_offset. */
1227*3d8817e4Smiod HOWTO (ALPHA_R_OP_STORE, /* Type. */
1228*3d8817e4Smiod 0, /* Rightshift. */
1229*3d8817e4Smiod 4, /* Size (0 = byte, 1 = short, 2 = long). */
1230*3d8817e4Smiod 64, /* Bitsize. */
1231*3d8817e4Smiod FALSE, /* PC relative. */
1232*3d8817e4Smiod 0, /* Bitpos. */
1233*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1234*3d8817e4Smiod reloc_nil, /* Special_function. */
1235*3d8817e4Smiod "OP_STORE", /* Name. */
1236*3d8817e4Smiod FALSE, /* Partial_inplace. */
1237*3d8817e4Smiod 0, /* Source mask. */
1238*3d8817e4Smiod MINUS_ONE, /* Dest mask. */
1239*3d8817e4Smiod FALSE), /* PC rel offset. */
1240*3d8817e4Smiod
1241*3d8817e4Smiod /* Subtract the reloc address from the value on the top of the
1242*3d8817e4Smiod relocation stack. */
1243*3d8817e4Smiod HOWTO (ALPHA_R_OP_PSUB, /* Type. */
1244*3d8817e4Smiod 0, /* Rightshift. */
1245*3d8817e4Smiod 0, /* Size (0 = byte, 1 = short, 2 = long). */
1246*3d8817e4Smiod 0, /* Bitsize. */
1247*3d8817e4Smiod FALSE, /* PC relative. */
1248*3d8817e4Smiod 0, /* Bitpos. */
1249*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1250*3d8817e4Smiod reloc_nil, /* Special_function. */
1251*3d8817e4Smiod "OP_PSUB", /* Name. */
1252*3d8817e4Smiod FALSE, /* Partial_inplace. */
1253*3d8817e4Smiod 0, /* Source mask. */
1254*3d8817e4Smiod 0, /* Dest mask. */
1255*3d8817e4Smiod FALSE), /* PC rel offset. */
1256*3d8817e4Smiod
1257*3d8817e4Smiod /* Shift the value on the top of the relocation stack right by the
1258*3d8817e4Smiod given value. */
1259*3d8817e4Smiod HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
1260*3d8817e4Smiod 0, /* Rightshift. */
1261*3d8817e4Smiod 0, /* Size (0 = byte, 1 = short, 2 = long). */
1262*3d8817e4Smiod 0, /* Bitsize. */
1263*3d8817e4Smiod FALSE, /* PC relative. */
1264*3d8817e4Smiod 0, /* Bitpos. */
1265*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1266*3d8817e4Smiod reloc_nil, /* Special_function. */
1267*3d8817e4Smiod "OP_PRSHIFT", /* Name. */
1268*3d8817e4Smiod FALSE, /* Partial_inplace. */
1269*3d8817e4Smiod 0, /* Source mask. */
1270*3d8817e4Smiod 0, /* Dest mask. */
1271*3d8817e4Smiod FALSE), /* PC rel offset. */
1272*3d8817e4Smiod
1273*3d8817e4Smiod /* Hack. Linkage is done by linker. */
1274*3d8817e4Smiod HOWTO (ALPHA_R_LINKAGE, /* Type. */
1275*3d8817e4Smiod 0, /* Rightshift. */
1276*3d8817e4Smiod 8, /* Size (0 = byte, 1 = short, 2 = long). */
1277*3d8817e4Smiod 256, /* Bitsize. */
1278*3d8817e4Smiod FALSE, /* PC relative. */
1279*3d8817e4Smiod 0, /* Bitpos. */
1280*3d8817e4Smiod complain_overflow_dont,/* Complain_on_overflow. */
1281*3d8817e4Smiod reloc_nil, /* Special_function. */
1282*3d8817e4Smiod "LINKAGE", /* Name. */
1283*3d8817e4Smiod FALSE, /* Partial_inplace. */
1284*3d8817e4Smiod 0, /* Source mask. */
1285*3d8817e4Smiod 0, /* Dest mask. */
1286*3d8817e4Smiod FALSE), /* PC rel offset. */
1287*3d8817e4Smiod
1288*3d8817e4Smiod /* A 32 bit reference to a symbol. */
1289*3d8817e4Smiod HOWTO (ALPHA_R_REFLONG, /* Type. */
1290*3d8817e4Smiod 0, /* Rightshift. */
1291*3d8817e4Smiod 2, /* Size (0 = byte, 1 = short, 2 = long). */
1292*3d8817e4Smiod 32, /* Bitsize. */
1293*3d8817e4Smiod FALSE, /* PC relative. */
1294*3d8817e4Smiod 0, /* Bitpos. */
1295*3d8817e4Smiod complain_overflow_bitfield, /* Complain_on_overflow. */
1296*3d8817e4Smiod reloc_nil, /* Special_function. */
1297*3d8817e4Smiod "REFLONG", /* Name. */
1298*3d8817e4Smiod TRUE, /* Partial_inplace. */
1299*3d8817e4Smiod 0xffffffff, /* Source mask. */
1300*3d8817e4Smiod 0xffffffff, /* Dest mask. */
1301*3d8817e4Smiod FALSE), /* PC rel offset. */
1302*3d8817e4Smiod
1303*3d8817e4Smiod /* A 64 bit reference to a procedure, written as 32 bit value. */
1304*3d8817e4Smiod HOWTO (ALPHA_R_CODEADDR, /* Type. */
1305*3d8817e4Smiod 0, /* Rightshift. */
1306*3d8817e4Smiod 4, /* Size (0 = byte, 1 = short, 2 = long). */
1307*3d8817e4Smiod 64, /* Bitsize. */
1308*3d8817e4Smiod FALSE, /* PC relative. */
1309*3d8817e4Smiod 0, /* Bitpos. */
1310*3d8817e4Smiod complain_overflow_signed,/* Complain_on_overflow. */
1311*3d8817e4Smiod reloc_nil, /* Special_function. */
1312*3d8817e4Smiod "CODEADDR", /* Name. */
1313*3d8817e4Smiod FALSE, /* Partial_inplace. */
1314*3d8817e4Smiod 0xffffffff, /* Source mask. */
1315*3d8817e4Smiod 0xffffffff, /* Dest mask. */
1316*3d8817e4Smiod FALSE), /* PC rel offset. */
1317*3d8817e4Smiod
1318*3d8817e4Smiod };
1319*3d8817e4Smiod
1320*3d8817e4Smiod /* Return a pointer to a howto structure which, when invoked, will perform
1321*3d8817e4Smiod the relocation code on data from the architecture noted. */
1322*3d8817e4Smiod
1323*3d8817e4Smiod static const struct reloc_howto_struct *
vms_bfd_reloc_type_lookup(bfd * abfd ATTRIBUTE_UNUSED,bfd_reloc_code_real_type code)1324*3d8817e4Smiod vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
1325*3d8817e4Smiod bfd_reloc_code_real_type code)
1326*3d8817e4Smiod {
1327*3d8817e4Smiod int alpha_type;
1328*3d8817e4Smiod
1329*3d8817e4Smiod #if VMS_DEBUG
1330*3d8817e4Smiod vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code);
1331*3d8817e4Smiod #endif
1332*3d8817e4Smiod
1333*3d8817e4Smiod switch (code)
1334*3d8817e4Smiod {
1335*3d8817e4Smiod case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
1336*3d8817e4Smiod case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
1337*3d8817e4Smiod case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
1338*3d8817e4Smiod case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
1339*3d8817e4Smiod case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
1340*3d8817e4Smiod case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
1341*3d8817e4Smiod case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
1342*3d8817e4Smiod case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
1343*3d8817e4Smiod case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
1344*3d8817e4Smiod case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
1345*3d8817e4Smiod case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
1346*3d8817e4Smiod default:
1347*3d8817e4Smiod (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
1348*3d8817e4Smiod return NULL;
1349*3d8817e4Smiod }
1350*3d8817e4Smiod #if VMS_DEBUG
1351*3d8817e4Smiod vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
1352*3d8817e4Smiod #endif
1353*3d8817e4Smiod return & alpha_howto_table[alpha_type];
1354*3d8817e4Smiod }
1355*3d8817e4Smiod
1356*3d8817e4Smiod /* Part 4.7, writing an object file. */
1357*3d8817e4Smiod
1358*3d8817e4Smiod /* Set the architecture and machine type in BFD abfd to arch and mach.
1359*3d8817e4Smiod Find the correct pointer to a structure and insert it into the arch_info
1360*3d8817e4Smiod pointer. */
1361*3d8817e4Smiod
1362*3d8817e4Smiod static bfd_boolean
vms_set_arch_mach(bfd * abfd,enum bfd_architecture arch ATTRIBUTE_UNUSED,unsigned long mach ATTRIBUTE_UNUSED)1363*3d8817e4Smiod vms_set_arch_mach (bfd * abfd,
1364*3d8817e4Smiod enum bfd_architecture arch ATTRIBUTE_UNUSED,
1365*3d8817e4Smiod unsigned long mach ATTRIBUTE_UNUSED)
1366*3d8817e4Smiod {
1367*3d8817e4Smiod #if VMS_DEBUG
1368*3d8817e4Smiod vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach);
1369*3d8817e4Smiod #endif
1370*3d8817e4Smiod abfd->arch_info = bfd_scan_arch ("alpha");
1371*3d8817e4Smiod
1372*3d8817e4Smiod return TRUE;
1373*3d8817e4Smiod }
1374*3d8817e4Smiod
1375*3d8817e4Smiod /* Sets the contents of the section section in BFD abfd to the data starting
1376*3d8817e4Smiod in memory at data. The data is written to the output section starting at
1377*3d8817e4Smiod offset offset for count bytes.
1378*3d8817e4Smiod
1379*3d8817e4Smiod Normally TRUE is returned, else FALSE. Possible error returns are:
1380*3d8817e4Smiod o bfd_error_no_contents - The output section does not have the
1381*3d8817e4Smiod SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1382*3d8817e4Smiod o and some more too */
1383*3d8817e4Smiod
1384*3d8817e4Smiod static bfd_boolean
vms_set_section_contents(bfd * abfd,asection * section,const void * location,file_ptr offset,bfd_size_type count)1385*3d8817e4Smiod vms_set_section_contents (bfd * abfd,
1386*3d8817e4Smiod asection *section,
1387*3d8817e4Smiod const void * location,
1388*3d8817e4Smiod file_ptr offset,
1389*3d8817e4Smiod bfd_size_type count)
1390*3d8817e4Smiod {
1391*3d8817e4Smiod #if VMS_DEBUG
1392*3d8817e4Smiod vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n",
1393*3d8817e4Smiod abfd, section->name, location, (long int)offset, (int)count);
1394*3d8817e4Smiod vms_debug (2, "size %d\n", (int) section->size);
1395*3d8817e4Smiod #endif
1396*3d8817e4Smiod return _bfd_save_vms_section (abfd, section, location, offset, count);
1397*3d8817e4Smiod }
1398*3d8817e4Smiod
1399*3d8817e4Smiod /* Part 4.8, linker. */
1400*3d8817e4Smiod
1401*3d8817e4Smiod /* Get the size of the section headers. */
1402*3d8817e4Smiod
1403*3d8817e4Smiod static int
vms_sizeof_headers(bfd * abfd ATTRIBUTE_UNUSED,bfd_boolean reloc ATTRIBUTE_UNUSED)1404*3d8817e4Smiod vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED,
1405*3d8817e4Smiod bfd_boolean reloc ATTRIBUTE_UNUSED)
1406*3d8817e4Smiod {
1407*3d8817e4Smiod #if VMS_DEBUG
1408*3d8817e4Smiod vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False");
1409*3d8817e4Smiod #endif
1410*3d8817e4Smiod return 0;
1411*3d8817e4Smiod }
1412*3d8817e4Smiod
1413*3d8817e4Smiod /* Provides default handling of relocation effort for back ends
1414*3d8817e4Smiod which can't be bothered to do it efficiently. */
1415*3d8817e4Smiod
1416*3d8817e4Smiod static bfd_byte *
vms_bfd_get_relocated_section_contents(bfd * abfd ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED,struct bfd_link_order * link_order ATTRIBUTE_UNUSED,bfd_byte * data ATTRIBUTE_UNUSED,bfd_boolean relocatable ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED)1417*3d8817e4Smiod vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
1418*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1419*3d8817e4Smiod struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
1420*3d8817e4Smiod bfd_byte *data ATTRIBUTE_UNUSED,
1421*3d8817e4Smiod bfd_boolean relocatable ATTRIBUTE_UNUSED,
1422*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED)
1423*3d8817e4Smiod {
1424*3d8817e4Smiod #if VMS_DEBUG
1425*3d8817e4Smiod vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n",
1426*3d8817e4Smiod abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols);
1427*3d8817e4Smiod #endif
1428*3d8817e4Smiod return NULL;
1429*3d8817e4Smiod }
1430*3d8817e4Smiod
1431*3d8817e4Smiod /* ??? */
1432*3d8817e4Smiod
1433*3d8817e4Smiod static bfd_boolean
vms_bfd_relax_section(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED,bfd_boolean * again ATTRIBUTE_UNUSED)1434*3d8817e4Smiod vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED,
1435*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED,
1436*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1437*3d8817e4Smiod bfd_boolean *again ATTRIBUTE_UNUSED)
1438*3d8817e4Smiod {
1439*3d8817e4Smiod #if VMS_DEBUG
1440*3d8817e4Smiod vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n",
1441*3d8817e4Smiod abfd, section->name, link_info);
1442*3d8817e4Smiod #endif
1443*3d8817e4Smiod return TRUE;
1444*3d8817e4Smiod }
1445*3d8817e4Smiod
1446*3d8817e4Smiod static bfd_boolean
vms_bfd_gc_sections(bfd * abfd ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED)1447*3d8817e4Smiod vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED,
1448*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1449*3d8817e4Smiod {
1450*3d8817e4Smiod #if VMS_DEBUG
1451*3d8817e4Smiod vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info);
1452*3d8817e4Smiod #endif
1453*3d8817e4Smiod return TRUE;
1454*3d8817e4Smiod }
1455*3d8817e4Smiod
1456*3d8817e4Smiod static bfd_boolean
vms_bfd_merge_sections(bfd * abfd ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED)1457*3d8817e4Smiod vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED,
1458*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1459*3d8817e4Smiod {
1460*3d8817e4Smiod #if VMS_DEBUG
1461*3d8817e4Smiod vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info);
1462*3d8817e4Smiod #endif
1463*3d8817e4Smiod return TRUE;
1464*3d8817e4Smiod }
1465*3d8817e4Smiod
1466*3d8817e4Smiod /* Create a hash table for the linker. Different backends store
1467*3d8817e4Smiod different information in this table. */
1468*3d8817e4Smiod
1469*3d8817e4Smiod static struct bfd_link_hash_table *
vms_bfd_link_hash_table_create(bfd * abfd ATTRIBUTE_UNUSED)1470*3d8817e4Smiod vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED)
1471*3d8817e4Smiod {
1472*3d8817e4Smiod #if VMS_DEBUG
1473*3d8817e4Smiod vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd);
1474*3d8817e4Smiod #endif
1475*3d8817e4Smiod return NULL;
1476*3d8817e4Smiod }
1477*3d8817e4Smiod
1478*3d8817e4Smiod /* Free a linker hash table. */
1479*3d8817e4Smiod
1480*3d8817e4Smiod static void
vms_bfd_link_hash_table_free(struct bfd_link_hash_table * hash ATTRIBUTE_UNUSED)1481*3d8817e4Smiod vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED)
1482*3d8817e4Smiod {
1483*3d8817e4Smiod #if VMS_DEBUG
1484*3d8817e4Smiod vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd);
1485*3d8817e4Smiod #endif
1486*3d8817e4Smiod }
1487*3d8817e4Smiod
1488*3d8817e4Smiod /* Add symbols from this object file into the hash table. */
1489*3d8817e4Smiod
1490*3d8817e4Smiod static bfd_boolean
vms_bfd_link_add_symbols(bfd * abfd ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED)1491*3d8817e4Smiod vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED,
1492*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1493*3d8817e4Smiod {
1494*3d8817e4Smiod #if VMS_DEBUG
1495*3d8817e4Smiod vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info);
1496*3d8817e4Smiod #endif
1497*3d8817e4Smiod return FALSE;
1498*3d8817e4Smiod }
1499*3d8817e4Smiod
1500*3d8817e4Smiod /* Do a link based on the link_order structures attached to each
1501*3d8817e4Smiod section of the BFD. */
1502*3d8817e4Smiod
1503*3d8817e4Smiod static bfd_boolean
vms_bfd_final_link(bfd * abfd ATTRIBUTE_UNUSED,struct bfd_link_info * link_info ATTRIBUTE_UNUSED)1504*3d8817e4Smiod vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED,
1505*3d8817e4Smiod struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1506*3d8817e4Smiod {
1507*3d8817e4Smiod #if VMS_DEBUG
1508*3d8817e4Smiod vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info);
1509*3d8817e4Smiod #endif
1510*3d8817e4Smiod return TRUE;
1511*3d8817e4Smiod }
1512*3d8817e4Smiod
1513*3d8817e4Smiod /* Should this section be split up into smaller pieces during linking. */
1514*3d8817e4Smiod
1515*3d8817e4Smiod static bfd_boolean
vms_bfd_link_split_section(bfd * abfd ATTRIBUTE_UNUSED,asection * section ATTRIBUTE_UNUSED)1516*3d8817e4Smiod vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED,
1517*3d8817e4Smiod asection *section ATTRIBUTE_UNUSED)
1518*3d8817e4Smiod {
1519*3d8817e4Smiod #if VMS_DEBUG
1520*3d8817e4Smiod vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name);
1521*3d8817e4Smiod #endif
1522*3d8817e4Smiod return FALSE;
1523*3d8817e4Smiod }
1524*3d8817e4Smiod
1525*3d8817e4Smiod /* Part 4.9, dynamic symbols and relocations. */
1526*3d8817e4Smiod
1527*3d8817e4Smiod /* Get the amount of memory required to hold the dynamic symbols. */
1528*3d8817e4Smiod
1529*3d8817e4Smiod static long
vms_get_dynamic_symtab_upper_bound(bfd * abfd ATTRIBUTE_UNUSED)1530*3d8817e4Smiod vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1531*3d8817e4Smiod {
1532*3d8817e4Smiod #if VMS_DEBUG
1533*3d8817e4Smiod vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd);
1534*3d8817e4Smiod #endif
1535*3d8817e4Smiod return 0;
1536*3d8817e4Smiod }
1537*3d8817e4Smiod
1538*3d8817e4Smiod static bfd_boolean
vms_bfd_print_private_bfd_data(bfd * abfd ATTRIBUTE_UNUSED,void * file ATTRIBUTE_UNUSED)1539*3d8817e4Smiod vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED,
1540*3d8817e4Smiod void *file ATTRIBUTE_UNUSED)
1541*3d8817e4Smiod {
1542*3d8817e4Smiod #if VMS_DEBUG
1543*3d8817e4Smiod vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd);
1544*3d8817e4Smiod #endif
1545*3d8817e4Smiod return FALSE;
1546*3d8817e4Smiod }
1547*3d8817e4Smiod
1548*3d8817e4Smiod /* Read in the dynamic symbols. */
1549*3d8817e4Smiod
1550*3d8817e4Smiod static long
vms_canonicalize_dynamic_symtab(bfd * abfd ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED)1551*3d8817e4Smiod vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED,
1552*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED)
1553*3d8817e4Smiod {
1554*3d8817e4Smiod #if VMS_DEBUG
1555*3d8817e4Smiod vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd);
1556*3d8817e4Smiod #endif
1557*3d8817e4Smiod return 0L;
1558*3d8817e4Smiod }
1559*3d8817e4Smiod
1560*3d8817e4Smiod /* Get the amount of memory required to hold the dynamic relocs. */
1561*3d8817e4Smiod
1562*3d8817e4Smiod static long
vms_get_dynamic_reloc_upper_bound(bfd * abfd ATTRIBUTE_UNUSED)1563*3d8817e4Smiod vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1564*3d8817e4Smiod {
1565*3d8817e4Smiod #if VMS_DEBUG
1566*3d8817e4Smiod vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd);
1567*3d8817e4Smiod #endif
1568*3d8817e4Smiod return 0L;
1569*3d8817e4Smiod }
1570*3d8817e4Smiod
1571*3d8817e4Smiod /* Read in the dynamic relocs. */
1572*3d8817e4Smiod
1573*3d8817e4Smiod static long
vms_canonicalize_dynamic_reloc(bfd * abfd ATTRIBUTE_UNUSED,arelent ** arel ATTRIBUTE_UNUSED,asymbol ** symbols ATTRIBUTE_UNUSED)1574*3d8817e4Smiod vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED,
1575*3d8817e4Smiod arelent **arel ATTRIBUTE_UNUSED,
1576*3d8817e4Smiod asymbol **symbols ATTRIBUTE_UNUSED)
1577*3d8817e4Smiod {
1578*3d8817e4Smiod #if VMS_DEBUG
1579*3d8817e4Smiod vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd);
1580*3d8817e4Smiod #endif
1581*3d8817e4Smiod return 0L;
1582*3d8817e4Smiod }
1583*3d8817e4Smiod
1584*3d8817e4Smiod const bfd_target vms_alpha_vec =
1585*3d8817e4Smiod {
1586*3d8817e4Smiod "vms-alpha", /* Name. */
1587*3d8817e4Smiod bfd_target_evax_flavour,
1588*3d8817e4Smiod BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1589*3d8817e4Smiod BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1590*3d8817e4Smiod
1591*3d8817e4Smiod (HAS_RELOC | HAS_SYMS
1592*3d8817e4Smiod | WP_TEXT | D_PAGED), /* Object flags. */
1593*3d8817e4Smiod (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1594*3d8817e4Smiod | SEC_READONLY | SEC_CODE | SEC_DATA
1595*3d8817e4Smiod | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1596*3d8817e4Smiod 0, /* Symbol_leading_char. */
1597*3d8817e4Smiod ' ', /* AR_pad_char. */
1598*3d8817e4Smiod 15, /* AR_max_namelen. */
1599*3d8817e4Smiod bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1600*3d8817e4Smiod bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1601*3d8817e4Smiod bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1602*3d8817e4Smiod bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1603*3d8817e4Smiod bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1604*3d8817e4Smiod bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1605*3d8817e4Smiod
1606*3d8817e4Smiod {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1607*3d8817e4Smiod vms_archive_p, _bfd_dummy_target},
1608*3d8817e4Smiod {bfd_false, vms_mkobject, /* bfd_set_format. */
1609*3d8817e4Smiod _bfd_generic_mkarchive, bfd_false},
1610*3d8817e4Smiod {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1611*3d8817e4Smiod _bfd_write_archive_contents, bfd_false},
1612*3d8817e4Smiod
1613*3d8817e4Smiod BFD_JUMP_TABLE_GENERIC (vms),
1614*3d8817e4Smiod BFD_JUMP_TABLE_COPY (vms),
1615*3d8817e4Smiod BFD_JUMP_TABLE_CORE (vms),
1616*3d8817e4Smiod BFD_JUMP_TABLE_ARCHIVE (vms),
1617*3d8817e4Smiod BFD_JUMP_TABLE_SYMBOLS (vms),
1618*3d8817e4Smiod BFD_JUMP_TABLE_RELOCS (vms),
1619*3d8817e4Smiod BFD_JUMP_TABLE_WRITE (vms),
1620*3d8817e4Smiod BFD_JUMP_TABLE_LINK (vms),
1621*3d8817e4Smiod BFD_JUMP_TABLE_DYNAMIC (vms),
1622*3d8817e4Smiod
1623*3d8817e4Smiod NULL,
1624*3d8817e4Smiod
1625*3d8817e4Smiod NULL
1626*3d8817e4Smiod };
1627*3d8817e4Smiod
1628*3d8817e4Smiod const bfd_target vms_vax_vec =
1629*3d8817e4Smiod {
1630*3d8817e4Smiod "vms-vax", /* Name. */
1631*3d8817e4Smiod bfd_target_ovax_flavour,
1632*3d8817e4Smiod BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1633*3d8817e4Smiod BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1634*3d8817e4Smiod
1635*3d8817e4Smiod (HAS_RELOC | HAS_SYMS /* Object flags. */
1636*3d8817e4Smiod | WP_TEXT | D_PAGED
1637*3d8817e4Smiod | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
1638*3d8817e4Smiod
1639*3d8817e4Smiod (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1640*3d8817e4Smiod | SEC_READONLY | SEC_CODE | SEC_DATA
1641*3d8817e4Smiod | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1642*3d8817e4Smiod 0, /* Symbol_leading_char. */
1643*3d8817e4Smiod ' ', /* AR_pad_char. */
1644*3d8817e4Smiod 15, /* AR_max_namelen. */
1645*3d8817e4Smiod bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1646*3d8817e4Smiod bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1647*3d8817e4Smiod bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
1648*3d8817e4Smiod bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1649*3d8817e4Smiod bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1650*3d8817e4Smiod bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */
1651*3d8817e4Smiod
1652*3d8817e4Smiod {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1653*3d8817e4Smiod vms_archive_p, _bfd_dummy_target},
1654*3d8817e4Smiod {bfd_false, vms_mkobject, /* bfd_set_format. */
1655*3d8817e4Smiod _bfd_generic_mkarchive, bfd_false},
1656*3d8817e4Smiod {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1657*3d8817e4Smiod _bfd_write_archive_contents, bfd_false},
1658*3d8817e4Smiod
1659*3d8817e4Smiod BFD_JUMP_TABLE_GENERIC (vms),
1660*3d8817e4Smiod BFD_JUMP_TABLE_COPY (vms),
1661*3d8817e4Smiod BFD_JUMP_TABLE_CORE (vms),
1662*3d8817e4Smiod BFD_JUMP_TABLE_ARCHIVE (vms),
1663*3d8817e4Smiod BFD_JUMP_TABLE_SYMBOLS (vms),
1664*3d8817e4Smiod BFD_JUMP_TABLE_RELOCS (vms),
1665*3d8817e4Smiod BFD_JUMP_TABLE_WRITE (vms),
1666*3d8817e4Smiod BFD_JUMP_TABLE_LINK (vms),
1667*3d8817e4Smiod BFD_JUMP_TABLE_DYNAMIC (vms),
1668*3d8817e4Smiod
1669*3d8817e4Smiod NULL,
1670*3d8817e4Smiod
1671*3d8817e4Smiod NULL
1672*3d8817e4Smiod };
1673