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