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