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