1 /* vms.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001
4 Free Software Foundation, Inc.
6 Written by Klaus K"ampf (kkaempf@rmi.de)
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 static boolean vms_initialize
PARAMS ((bfd
*));
30 static unsigned int priv_section_count
;
31 static boolean fill_section_ptr
PARAMS ((struct bfd_hash_entry
*, PTR
));
32 static boolean vms_fixup_sections
PARAMS ((bfd
*));
33 static boolean copy_symbols
PARAMS ((struct bfd_hash_entry
*, PTR
));
34 static bfd_reloc_status_type reloc_nil
35 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
36 static const struct bfd_target
*vms_object_p
PARAMS ((bfd
*abfd
));
37 static const struct bfd_target
*vms_archive_p
PARAMS ((bfd
*abfd
));
38 static boolean vms_mkobject
PARAMS ((bfd
*abfd
));
39 static boolean vms_write_object_contents
PARAMS ((bfd
*abfd
));
40 static boolean vms_close_and_cleanup
PARAMS ((bfd
*abfd
));
41 static boolean vms_bfd_free_cached_info
PARAMS ((bfd
*abfd
));
42 static boolean vms_new_section_hook
PARAMS ((bfd
*abfd
, asection
*section
));
43 static boolean vms_get_section_contents
44 PARAMS ((bfd
*abfd
, asection
*section
, PTR x1
, file_ptr x2
,
46 static boolean vms_get_section_contents_in_window
47 PARAMS ((bfd
*abfd
, asection
*section
, bfd_window
*w
, file_ptr offset
,
48 bfd_size_type count
));
49 static boolean vms_bfd_copy_private_bfd_data
PARAMS ((bfd
*src
, bfd
*dest
));
50 static boolean vms_bfd_copy_private_section_data
51 PARAMS ((bfd
*srcbfd
, asection
*srcsec
, bfd
*dstbfd
, asection
*dstsec
));
52 static boolean vms_bfd_copy_private_symbol_data
53 PARAMS ((bfd
*ibfd
, asymbol
*isym
, bfd
*obfd
, asymbol
*osym
));
54 static boolean vms_bfd_print_private_bfd_data
55 PARAMS ((bfd
*abfd
, void *file
));
56 static char *vms_core_file_failing_command
PARAMS ((bfd
*abfd
));
57 static int vms_core_file_failing_signal
PARAMS ((bfd
*abfd
));
58 static boolean vms_core_file_matches_executable_p
59 PARAMS ((bfd
*abfd
, bfd
*bbfd
));
60 static boolean vms_slurp_armap
PARAMS ((bfd
*abfd
));
61 static boolean vms_slurp_extended_name_table
PARAMS ((bfd
*abfd
));
62 static boolean vms_construct_extended_name_table
63 PARAMS ((bfd
*abfd
, char **tabloc
, bfd_size_type
*tablen
,
65 static void vms_truncate_arname
66 PARAMS ((bfd
*abfd
, const char *pathname
, char *arhdr
));
67 static boolean vms_write_armap
68 PARAMS ((bfd
*arch
, unsigned int elength
, struct orl
*map
,
69 unsigned int orl_count
, int stridx
));
70 static PTR vms_read_ar_hdr
PARAMS ((bfd
*abfd
));
71 static bfd
*vms_get_elt_at_index
PARAMS ((bfd
*abfd
, symindex index
));
72 static bfd
*vms_openr_next_archived_file
PARAMS ((bfd
*arch
, bfd
*prev
));
73 static boolean vms_update_armap_timestamp
PARAMS ((bfd
*abfd
));
74 static int vms_generic_stat_arch_elt
PARAMS ((bfd
*, struct stat
*));
75 static long vms_get_symtab_upper_bound
PARAMS ((bfd
*abfd
));
76 static long vms_get_symtab
PARAMS ((bfd
*abfd
, asymbol
**symbols
));
77 static void vms_print_symbol
78 PARAMS ((bfd
*abfd
, PTR file
, asymbol
*symbol
, bfd_print_symbol_type how
));
79 static void vms_get_symbol_info
80 PARAMS ((bfd
*abfd
, asymbol
*symbol
, symbol_info
*ret
));
81 static boolean vms_bfd_is_local_label_name
PARAMS ((bfd
*abfd
, const char *));
82 static alent
*vms_get_lineno
PARAMS ((bfd
*abfd
, asymbol
*symbol
));
83 static boolean vms_find_nearest_line
84 PARAMS ((bfd
*abfd
, asection
*section
, asymbol
**symbols
, bfd_vma offset
,
85 const char **file
, const char **func
, unsigned int *line
));
86 static asymbol
*vms_bfd_make_debug_symbol
87 PARAMS ((bfd
*abfd
, void *ptr
, unsigned long size
));
88 static long vms_read_minisymbols
89 PARAMS ((bfd
*abfd
, boolean dynamic
, PTR
*minisymsp
, unsigned int *sizep
));
90 static asymbol
*vms_minisymbol_to_symbol
91 PARAMS ((bfd
*abfd
, boolean dynamic
, const PTR minisym
, asymbol
*sym
));
92 static long vms_get_reloc_upper_bound
PARAMS ((bfd
*abfd
, asection
*sect
));
93 static long vms_canonicalize_reloc
94 PARAMS ((bfd
*abfd
, asection
*srcsec
, arelent
**location
,
96 static const struct reloc_howto_struct
*vms_bfd_reloc_type_lookup
97 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
98 static boolean vms_set_arch_mach
99 PARAMS ((bfd
*abfd
, enum bfd_architecture arch
, unsigned long mach
));
100 static boolean vms_set_section_contents
101 PARAMS ((bfd
*abfd
, asection
*section
, PTR location
, file_ptr offset
,
102 bfd_size_type count
));
103 static int vms_sizeof_headers
PARAMS ((bfd
*abfd
, boolean reloc
));
104 static bfd_byte
*vms_bfd_get_relocated_section_contents
105 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
,
106 struct bfd_link_order
*link_order
, bfd_byte
*data
,
107 boolean relocateable
, asymbol
**symbols
));
108 static boolean vms_bfd_relax_section
109 PARAMS ((bfd
*abfd
, asection
*section
, struct bfd_link_info
*link_info
,
111 static boolean vms_bfd_gc_sections
112 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
113 static boolean vms_bfd_merge_sections
114 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
115 static struct bfd_link_hash_table
*vms_bfd_link_hash_table_create
116 PARAMS ((bfd
*abfd
));
117 static boolean vms_bfd_link_add_symbols
118 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
119 static boolean vms_bfd_final_link
120 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
121 static boolean vms_bfd_link_split_section
122 PARAMS ((bfd
*abfd
, asection
*section
));
123 static long vms_get_dynamic_symtab_upper_bound
PARAMS ((bfd
*abfd
));
124 static long vms_canonicalize_dynamic_symtab
125 PARAMS ((bfd
*abfd
, asymbol
**symbols
));
126 static long vms_get_dynamic_reloc_upper_bound
PARAMS ((bfd
*abfd
));
127 static long vms_canonicalize_dynamic_reloc
128 PARAMS ((bfd
*abfd
, arelent
**arel
, asymbol
**symbols
));
129 static boolean vms_bfd_merge_private_bfd_data
PARAMS ((bfd
*ibfd
, bfd
*obfd
));
130 static boolean vms_bfd_set_private_flags
PARAMS ((bfd
*abfd
, flagword flags
));
132 #define vms_make_empty_symbol _bfd_vms_make_empty_symbol
134 /*===========================================================================*/
136 const bfd_target vms_alpha_vec
=
138 "vms-alpha", /* name */
139 bfd_target_evax_flavour
,
140 BFD_ENDIAN_LITTLE
, /* data byte order is little */
141 BFD_ENDIAN_LITTLE
, /* header byte order is little */
143 (HAS_RELOC
| HAS_SYMS
144 | WP_TEXT
| D_PAGED
), /* object flags */
145 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
146 | SEC_READONLY
| SEC_CODE
| SEC_DATA
147 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* sect flags */
148 0, /* symbol_leading_char */
149 ' ', /* ar_pad_char */
150 15, /* ar_max_namelen */
151 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
152 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
153 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
154 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
155 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
156 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
158 {_bfd_dummy_target
, vms_object_p
, /* bfd_check_format */
159 vms_archive_p
, _bfd_dummy_target
},
160 {bfd_false
, vms_mkobject
, /* bfd_set_format */
161 _bfd_generic_mkarchive
, bfd_false
},
162 {bfd_false
, vms_write_object_contents
, /* bfd_write_contents */
163 _bfd_write_archive_contents
, bfd_false
},
165 BFD_JUMP_TABLE_GENERIC (vms
),
166 BFD_JUMP_TABLE_COPY (vms
),
167 BFD_JUMP_TABLE_CORE (vms
),
168 BFD_JUMP_TABLE_ARCHIVE (vms
),
169 BFD_JUMP_TABLE_SYMBOLS (vms
),
170 BFD_JUMP_TABLE_RELOCS (vms
),
171 BFD_JUMP_TABLE_WRITE (vms
),
172 BFD_JUMP_TABLE_LINK (vms
),
173 BFD_JUMP_TABLE_DYNAMIC (vms
),
180 const bfd_target vms_vax_vec
=
182 "vms-vax", /* name */
183 bfd_target_ovax_flavour
,
184 BFD_ENDIAN_LITTLE
, /* data byte order is little */
185 BFD_ENDIAN_LITTLE
, /* header byte order is little */
187 (HAS_RELOC
| HAS_SYMS
/* object flags */
189 | HAS_LINENO
| HAS_DEBUG
| HAS_LOCALS
),
191 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
192 | SEC_READONLY
| SEC_CODE
| SEC_DATA
193 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* sect flags */
194 0, /* symbol_leading_char */
195 ' ', /* ar_pad_char */
196 15, /* ar_max_namelen */
197 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
198 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
199 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
200 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
201 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
202 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
204 {_bfd_dummy_target
, vms_object_p
, /* bfd_check_format */
205 vms_archive_p
, _bfd_dummy_target
},
206 {bfd_false
, vms_mkobject
, /* bfd_set_format */
207 _bfd_generic_mkarchive
, bfd_false
},
208 {bfd_false
, vms_write_object_contents
, /* bfd_write_contents */
209 _bfd_write_archive_contents
, bfd_false
},
211 BFD_JUMP_TABLE_GENERIC (vms
),
212 BFD_JUMP_TABLE_COPY (vms
),
213 BFD_JUMP_TABLE_CORE (vms
),
214 BFD_JUMP_TABLE_ARCHIVE (vms
),
215 BFD_JUMP_TABLE_SYMBOLS (vms
),
216 BFD_JUMP_TABLE_RELOCS (vms
),
217 BFD_JUMP_TABLE_WRITE (vms
),
218 BFD_JUMP_TABLE_LINK (vms
),
219 BFD_JUMP_TABLE_DYNAMIC (vms
),
226 /*===========================================================================*/
228 /* Initialize private data */
231 vms_initialize (abfd
)
237 if (abfd
->tdata
.any
!= 0)
240 bfd_set_start_address (abfd
, (bfd_vma
) -1);
242 amt
= sizeof (struct vms_private_data_struct
);
243 abfd
->tdata
.any
= (struct vms_private_data_struct
*) bfd_malloc (amt
);
244 if (abfd
->tdata
.any
== 0)
254 PRIV (rec_length
) = 0;
255 PRIV (file_format
) = FF_UNKNOWN
;
256 PRIV (fixup_done
) = false;
257 PRIV (sections
) = NULL
;
259 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
260 PRIV (stack
) = (struct stack_struct
*) bfd_malloc (amt
);
261 if (PRIV (stack
) == 0)
264 free (abfd
->tdata
.any
);
270 amt
= sizeof (struct bfd_hash_table
);
271 PRIV (vms_symbol_table
) = (struct bfd_hash_table
*) bfd_malloc (amt
);
272 if (PRIV (vms_symbol_table
) == 0)
277 goto vms_init_no_mem1
;
280 if (!bfd_hash_table_init (PRIV (vms_symbol_table
), _bfd_vms_hash_newfunc
))
283 amt
= sizeof (struct location_struct
) * LOCATION_SAVE_SIZE
;
284 PRIV (location_stack
) = (struct location_struct
*) bfd_malloc (amt
);
285 if (PRIV (location_stack
) == 0)
288 free (PRIV (vms_symbol_table
));
289 PRIV (vms_symbol_table
) = 0;
290 goto vms_init_no_mem2
;
293 for (i
= 0; i
< VMS_SECTION_COUNT
; i
++)
294 PRIV (vms_section_table
)[i
] = NULL
;
296 PRIV (output_buf
) = (unsigned char *) malloc (MAX_OUTREC_SIZE
);
297 if (PRIV (output_buf
) == 0)
299 free (PRIV (location_stack
));
300 PRIV (location_stack
) = 0;
301 goto vms_init_no_mem3
;
303 PRIV (push_level
) = 0;
304 PRIV (pushed_size
) = 0;
305 PRIV (length_pos
) = 2;
306 PRIV (output_size
) = 0;
307 PRIV (output_alignment
) = 1;
312 /* Fill symbol->section with section ptr
313 symbol->section is filled with the section index for defined symbols
314 during reading the GSD/EGSD section. But we need the pointer to the
317 It has the correct value for referenced (undefined section) symbols
319 called from bfd_hash_traverse in vms_fixup_sections */
322 fill_section_ptr (entry
, sections
)
323 struct bfd_hash_entry
*entry
;
329 sym
= ((vms_symbol_entry
*)entry
)->symbol
;
333 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym
, sec
);
336 /* fill forward references (these contain section number, not section ptr). */
338 if ((unsigned int) sec
< priv_section_count
)
340 sec
= ((vms_symbol_entry
*)entry
)->symbol
->section
=
341 ((asection
**)sections
)[(int)sec
];
344 if (strcmp (sym
->name
, sec
->name
) == 0)
345 sym
->flags
|= BSF_SECTION_SYM
;
351 set up all pointers and arrays, counters and sizes are fixed now
353 we build a private sections vector for easy access since sections
354 are always referenced by an index number.
356 alloc PRIV(sections) according to abfd->section_count
357 copy abfd->sections to PRIV(sections) */
360 vms_fixup_sections (abfd
)
363 if (PRIV (fixup_done
))
367 * traverse symbol table and fill in all section pointers
370 /* can't provide section count as argument to fill_section_ptr(). */
371 priv_section_count
= PRIV (section_count
);
372 bfd_hash_traverse (PRIV (vms_symbol_table
), fill_section_ptr
,
373 (PTR
) (PRIV (sections
)));
375 PRIV (fixup_done
) = true;
380 /*===========================================================================*/
382 /* Check the format for a file being read.
383 Return a (bfd_target *) if it's an object file or zero if not. */
385 static const struct bfd_target
*
391 const struct bfd_target
*target_vector
= 0;
392 const bfd_arch_info_type
*arch
= 0;
395 vms_debug (1, "vms_object_p(%p)\n", abfd
);
398 if (!vms_initialize (abfd
))
400 fprintf (stderr
, "vms_initialize () failed !!\n");
404 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
406 bfd_set_error (bfd_error_file_truncated
);
415 vms_debug (7, "reading at %08lx\n", bfd_tell(abfd
));
417 if (_bfd_vms_next_record (abfd
) < 0)
420 vms_debug (2, "next_record failed\n");
422 bfd_set_error (bfd_error_wrong_format
);
426 if ((prev_type
== EOBJ_S_C_EGSD
)
427 && (PRIV (rec_type
) != EOBJ_S_C_EGSD
))
429 if (vms_fixup_sections (abfd
) == false)
432 vms_debug (2, "vms_fixup_sections failed\n");
434 bfd_set_error (bfd_error_wrong_format
);
439 prev_type
= PRIV (rec_type
);
441 if (target_vector
== 0)
443 if (prev_type
<= OBJ_S_C_MAXRECTYP
)
444 target_vector
= &vms_vax_vec
;
446 target_vector
= &vms_alpha_vec
;
453 err
= _bfd_vms_slurp_hdr (abfd
, prev_type
);
458 err
= _bfd_vms_slurp_eom (abfd
, prev_type
);
462 err
= _bfd_vms_slurp_gsd (abfd
, prev_type
);
466 err
= _bfd_vms_slurp_tir (abfd
, prev_type
);
470 err
= _bfd_vms_slurp_dbg (abfd
, prev_type
);
474 err
= _bfd_vms_slurp_tbt (abfd
, prev_type
);
477 err
= _bfd_vms_slurp_lnk (abfd
, prev_type
);
485 vms_debug (2, "slurp type %d failed with %d\n", prev_type
, err
);
487 bfd_set_error (bfd_error_wrong_format
);
491 while ((prev_type
!= EOBJ_S_C_EEOM
) && (prev_type
!= OBJ_S_C_EOM
) && (prev_type
!= OBJ_S_C_EOMW
));
493 if (target_vector
== &vms_vax_vec
)
495 if (vms_fixup_sections (abfd
) == false)
498 vms_debug (2, "vms_fixup_sections failed\n");
500 bfd_set_error (bfd_error_wrong_format
);
504 /* set arch_info to vax */
506 arch
= bfd_scan_arch ("vax");
509 vms_debug (2, "arch is vax\n");
512 else if (target_vector
== &vms_alpha_vec
)
514 /* set arch_info to alpha */
516 arch
= bfd_scan_arch ("alpha");
519 vms_debug (2, "arch is alpha\n");
526 vms_debug (2, "arch not found\n");
528 bfd_set_error (bfd_error_wrong_format
);
531 abfd
->arch_info
= arch
;
533 return target_vector
;
536 /* Check the format for a file being read.
537 Return a (bfd_target *) if it's an archive file or zero. */
539 static const struct bfd_target
*
541 bfd
*abfd ATTRIBUTE_UNUSED
;
544 vms_debug (1, "vms_archive_p(%p)\n", abfd
);
550 /* Set the format of a file being written. */
557 vms_debug (1, "vms_mkobject(%p)\n", abfd
);
560 if (!vms_initialize (abfd
))
562 fprintf (stderr
, "vms_initialize () failed !!\n");
568 const bfd_arch_info_type
*arch
= bfd_scan_arch ("vax");
570 const bfd_arch_info_type
*arch
= bfd_scan_arch ("alpha");
574 bfd_set_error(bfd_error_wrong_format
);
577 abfd
->arch_info
= arch
;
583 /* Write cached information into a file being written, at bfd_close. */
586 vms_write_object_contents (abfd
)
590 vms_debug (1, "vms_write_object_contents(%p)\n", abfd
);
593 if (abfd
->section_count
> 0) /* we have sections */
597 if (_bfd_vms_write_hdr (abfd
, OBJ_S_C_HDR
) != 0)
599 if (_bfd_vms_write_gsd (abfd
, OBJ_S_C_GSD
) != 0)
601 if (_bfd_vms_write_tir (abfd
, OBJ_S_C_TIR
) != 0)
603 if (_bfd_vms_write_tbt (abfd
, OBJ_S_C_TBT
) != 0)
605 if (_bfd_vms_write_dbg (abfd
, OBJ_S_C_DBG
) != 0)
607 if (abfd
->section_count
> 255)
609 if (_bfd_vms_write_eom (abfd
, OBJ_S_C_EOMW
) != 0)
614 if (_bfd_vms_write_eom (abfd
, OBJ_S_C_EOM
) != 0)
620 if (_bfd_vms_write_hdr (abfd
, EOBJ_S_C_EMH
) != 0)
622 if (_bfd_vms_write_gsd (abfd
, EOBJ_S_C_EGSD
) != 0)
624 if (_bfd_vms_write_tir (abfd
, EOBJ_S_C_ETIR
) != 0)
626 if (_bfd_vms_write_tbt (abfd
, EOBJ_S_C_ETBT
) != 0)
628 if (_bfd_vms_write_dbg (abfd
, EOBJ_S_C_EDBG
) != 0)
630 if (_bfd_vms_write_eom (abfd
, EOBJ_S_C_EEOM
) != 0)
637 /*-- 4.1, generic -----------------------------------------------------------*/
639 /* Called when the BFD is being closed to do any necessary cleanup. */
642 vms_close_and_cleanup (abfd
)
646 vms_section
*es
, *es1
;
650 vms_debug (1, "vms_close_and_cleanup(%p)\n", abfd
);
655 if (PRIV (vms_buf
) != NULL
)
657 free (PRIV (vms_buf
));
658 PRIV (vms_buf
) = NULL
;
662 if (PRIV (output_buf
) != 0)
664 free (PRIV (output_buf
));
665 PRIV (output_buf
) = 0;
668 sec
= abfd
->sections
;
672 free (sec
->contents
);
676 if (PRIV (sections
) != NULL
)
678 free (PRIV (sections
));
679 PRIV (sections
) = NULL
;
682 if (PRIV (vms_symbol_table
))
684 bfd_hash_table_free (PRIV (vms_symbol_table
));
685 PRIV (vms_symbol_table
) = 0;
694 if (PRIV (location_stack
))
696 free (PRIV (location_stack
));
697 PRIV (location_stack
) = 0;
700 for (i
= 0; i
< VMS_SECTION_COUNT
; i
++)
702 es
= PRIV (vms_section_table
)[i
];
709 PRIV (vms_section_table
)[i
] = NULL
;
712 free (abfd
->tdata
.any
);
713 abfd
->tdata
.any
= NULL
;
718 /* Ask the BFD to free all cached information. */
720 vms_bfd_free_cached_info (abfd
)
721 bfd
*abfd ATTRIBUTE_UNUSED
;
724 vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd
);
729 /* Called when a new section is created. */
732 vms_new_section_hook (abfd
, section
)
736 /* Count hasn't been incremented yet. */
737 unsigned int section_count
= abfd
->section_count
+ 1;
740 vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
741 abfd
, section
->index
, section
->name
, section_count
);
743 bfd_set_section_alignment (abfd
, section
, 4);
745 if (section_count
> PRIV (section_count
))
747 bfd_size_type amt
= section_count
;
748 amt
*= sizeof (asection
*);
749 PRIV (sections
) = (asection
**) bfd_realloc (PRIV (sections
), amt
);
750 if (PRIV (sections
) == 0)
752 PRIV (section_count
) = section_count
;
755 vms_debug (6, "section_count: %d\n", PRIV (section_count
));
757 PRIV (sections
)[section
->index
] = section
;
759 vms_debug (7, "%d: %s\n", section
->index
, section
->name
);
765 /* Read the contents of a section.
766 buf points to a buffer of buf_size bytes to be filled with
767 section data (starting at offset into section) */
770 vms_get_section_contents (abfd
, section
, buf
, offset
, buf_size
)
771 bfd
*abfd ATTRIBUTE_UNUSED
;
772 asection
*section ATTRIBUTE_UNUSED
;
773 PTR buf ATTRIBUTE_UNUSED
;
774 file_ptr offset ATTRIBUTE_UNUSED
;
775 bfd_size_type buf_size ATTRIBUTE_UNUSED
;
778 vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n",
779 abfd
, section
->name
, buf
, offset
, (int)buf_size
);
782 /* shouldn't be called, since all sections are IN_MEMORY */
787 /* Read the contents of a section.
788 buf points to a buffer of buf_size bytes to be filled with
789 section data (starting at offset into section) */
792 vms_get_section_contents_in_window (abfd
, section
, w
, offset
, count
)
793 bfd
*abfd ATTRIBUTE_UNUSED
;
794 asection
*section ATTRIBUTE_UNUSED
;
795 bfd_window
*w ATTRIBUTE_UNUSED
;
796 file_ptr offset ATTRIBUTE_UNUSED
;
797 bfd_size_type count ATTRIBUTE_UNUSED
;
800 vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n",
801 abfd
, section
->name
, w
, offset
, (int)count
);
804 /* shouldn't be called, since all sections are IN_MEMORY */
809 /*-- Part 4.2, copy private data --------------------------------------------*/
811 /* Called to copy BFD general private data from one object file
815 vms_bfd_copy_private_bfd_data (src
, dest
)
816 bfd
*src ATTRIBUTE_UNUSED
;
817 bfd
*dest ATTRIBUTE_UNUSED
;
820 vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src
, dest
);
825 /* Merge private BFD information from the BFD @var{ibfd} to the
826 the output file BFD @var{obfd} when linking. Return <<true>>
827 on success, <<false>> on error. Possible error returns are:
829 o <<bfd_error_no_memory>> -
830 Not enough memory exists to create private data for @var{obfd}. */
833 vms_bfd_merge_private_bfd_data (ibfd
, obfd
)
834 bfd
*ibfd ATTRIBUTE_UNUSED
;
835 bfd
*obfd ATTRIBUTE_UNUSED
;
838 vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd
, obfd
);
843 /* Set private BFD flag information in the BFD @var{abfd}.
844 Return <<true>> on success, <<false>> on error. Possible error
847 o <<bfd_error_no_memory>> -
848 Not enough memory exists to create private data for @var{obfd}. */
851 vms_bfd_set_private_flags (abfd
, flags
)
852 bfd
*abfd ATTRIBUTE_UNUSED
;
853 flagword flags ATTRIBUTE_UNUSED
;
856 vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd
, (long)flags
);
861 /* Called to copy BFD private section data from one object file
865 vms_bfd_copy_private_section_data (srcbfd
, srcsec
, dstbfd
, dstsec
)
866 bfd
*srcbfd ATTRIBUTE_UNUSED
;
867 asection
*srcsec ATTRIBUTE_UNUSED
;
868 bfd
*dstbfd ATTRIBUTE_UNUSED
;
869 asection
*dstsec ATTRIBUTE_UNUSED
;
872 vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n",
873 srcbfd
, srcsec
->name
, dstbfd
, dstsec
->name
);
878 /* Called to copy BFD private symbol data from one object file
882 vms_bfd_copy_private_symbol_data (ibfd
, isym
, obfd
, osym
)
883 bfd
*ibfd ATTRIBUTE_UNUSED
;
884 asymbol
*isym ATTRIBUTE_UNUSED
;
885 bfd
*obfd ATTRIBUTE_UNUSED
;
886 asymbol
*osym ATTRIBUTE_UNUSED
;
889 vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n",
890 ibfd
, isym
->name
, obfd
, osym
->name
);
895 /*-- Part 4.3, core file ----------------------------------------------------*/
897 /* Return a read-only string explaining which program was running
898 when it failed and produced the core file abfd. */
901 vms_core_file_failing_command (abfd
)
902 bfd
*abfd ATTRIBUTE_UNUSED
;
905 vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd
);
910 /* Returns the signal number which caused the core dump which
911 generated the file the BFD abfd is attached to. */
914 vms_core_file_failing_signal (abfd
)
915 bfd
*abfd ATTRIBUTE_UNUSED
;
918 vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd
);
923 /* Return true if the core file attached to core_bfd was generated
924 by a run of the executable file attached to exec_bfd, false otherwise. */
927 vms_core_file_matches_executable_p (abfd
, bbfd
)
928 bfd
*abfd ATTRIBUTE_UNUSED
;
929 bfd
*bbfd ATTRIBUTE_UNUSED
;
932 vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd
, bbfd
);
937 /*-- Part 4.4, archive ------------------------------------------------------*/
939 /* ??? do something with an archive map.
940 Return false on error, true otherwise. */
943 vms_slurp_armap (abfd
)
944 bfd
*abfd ATTRIBUTE_UNUSED
;
947 vms_debug (1, "vms_slurp_armap(%p)\n", abfd
);
952 /* ??? do something with an extended name table.
953 Return false on error, true otherwise. */
956 vms_slurp_extended_name_table (abfd
)
957 bfd
*abfd ATTRIBUTE_UNUSED
;
960 vms_debug (1, "vms_slurp_extended_name_table(%p)\n", abfd
);
965 /* ??? do something with an extended name table.
966 Return false on error, true otherwise. */
969 vms_construct_extended_name_table (abfd
, tabloc
, tablen
, name
)
970 bfd
*abfd ATTRIBUTE_UNUSED
;
971 char **tabloc ATTRIBUTE_UNUSED
;
972 bfd_size_type
*tablen ATTRIBUTE_UNUSED
;
973 const char **name ATTRIBUTE_UNUSED
;
976 vms_debug (1, "vms_construct_extended_name_table(%p)\n", abfd
);
981 /* Truncate the name of an archive to match system-dependent restrictions */
984 vms_truncate_arname (abfd
, pathname
, arhdr
)
985 bfd
*abfd ATTRIBUTE_UNUSED
;
986 const char *pathname ATTRIBUTE_UNUSED
;
987 char *arhdr ATTRIBUTE_UNUSED
;
990 vms_debug (1, "vms_truncate_arname(%p, %s, %s)\n", abfd
, pathname
, arhdr
);
995 /* ??? write archive map */
998 vms_write_armap (arch
, elength
, map
, orl_count
, stridx
)
999 bfd
*arch ATTRIBUTE_UNUSED
;
1000 unsigned int elength ATTRIBUTE_UNUSED
;
1001 struct orl
*map ATTRIBUTE_UNUSED
;
1002 unsigned int orl_count ATTRIBUTE_UNUSED
;
1003 int stridx ATTRIBUTE_UNUSED
;
1006 vms_debug (1, "vms_write_armap(%p, %d, %p, %d %d)\n",
1007 arch
, elength
, map
, orl_count
, stridx
);
1012 /* Read archive header ??? */
1015 vms_read_ar_hdr (abfd
)
1016 bfd
* abfd ATTRIBUTE_UNUSED
;
1019 vms_debug (1, "vms_read_ar_hdr(%p)\n", abfd
);
1024 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
1025 an input BFD on the first contained element and returns that.
1026 Subsequent calls should pass the archive and the previous return value
1027 to return a created BFD to the next contained element.
1028 NULL is returned when there are no more. */
1031 vms_openr_next_archived_file (arch
, prev
)
1032 bfd
*arch ATTRIBUTE_UNUSED
;
1033 bfd
*prev ATTRIBUTE_UNUSED
;
1036 vms_debug (1, "vms_openr_next_archived_file(%p, %p)\n", arch
, prev
);
1041 /* Return the BFD which is referenced by the symbol in ABFD indexed by
1042 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
1045 vms_get_elt_at_index (abfd
, index
)
1050 vms_debug (1, "vms_get_elt_at_index(%p, %p)\n", abfd
, index
);
1052 return _bfd_generic_get_elt_at_index(abfd
, index
);
1056 -> bfd_generic_stat_arch_elt */
1059 vms_generic_stat_arch_elt (abfd
, st
)
1064 vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd
, st
);
1066 return bfd_generic_stat_arch_elt (abfd
, st
);
1069 /* This is a new function in bfd 2.5 */
1072 vms_update_armap_timestamp (abfd
)
1073 bfd
*abfd ATTRIBUTE_UNUSED
;
1076 vms_debug (1, "vms_update_armap_timestamp(%p)\n", abfd
);
1081 /*-- Part 4.5, symbols --------------------------------------------------------*/
1083 /* Return the number of bytes required to store a vector of pointers
1084 to asymbols for all the symbols in the BFD abfd, including a
1085 terminal NULL pointer. If there are no symbols in the BFD,
1086 then return 0. If an error occurs, return -1. */
1089 vms_get_symtab_upper_bound (abfd
)
1093 vms_debug (1, "vms_get_symtab_upper_bound(%p), %d symbols\n", abfd
, PRIV (gsd_sym_count
));
1095 return (PRIV (gsd_sym_count
)+1) * sizeof (asymbol
*);
1098 /* Copy symbols from hash table to symbol vector
1100 called from bfd_hash_traverse in vms_get_symtab
1101 init counter to 0 if entry == 0 */
1104 copy_symbols (entry
, arg
)
1105 struct bfd_hash_entry
*entry
;
1108 bfd
*abfd
= (bfd
*) arg
;
1110 if (entry
== NULL
) /* init counter */
1112 else /* fill vector, inc counter */
1113 PRIV (symcache
)[PRIV (symnum
)++] = ((vms_symbol_entry
*)entry
)->symbol
;
1118 /* Read the symbols from the BFD abfd, and fills in the vector
1119 location with pointers to the symbols and a trailing NULL.
1121 return # of symbols read */
1124 vms_get_symtab (abfd
, symbols
)
1129 vms_debug (1, "vms_get_symtab(%p, <ret>)\n", abfd
);
1133 (void)copy_symbols((struct bfd_hash_entry
*)0, abfd
);
1135 /* traverse table and fill symbols vector */
1137 PRIV (symcache
) = symbols
;
1138 bfd_hash_traverse(PRIV (vms_symbol_table
), copy_symbols
, (PTR
)abfd
);
1140 symbols
[PRIV (gsd_sym_count
)] = NULL
;
1142 return PRIV (gsd_sym_count
);
1145 /* Create a new asymbol structure for the BFD abfd and return a pointer
1147 This routine is necessary because each back end has private information
1148 surrounding the asymbol. Building your own asymbol and pointing to it
1149 will not create the private information, and will cause problems later on. */
1152 _bfd_vms_make_empty_symbol (abfd
)
1157 symbol
= (asymbol
*) bfd_zalloc(abfd
, (bfd_size_type
) sizeof (asymbol
));
1160 vms_debug (1, "_bfd_vms_make_empty_symbol(%p)\n", abfd
);
1165 bfd_set_error (bfd_error_no_memory
);
1168 symbol
->the_bfd
= abfd
;
1173 /* Print symbol to file according to how. how is one of
1174 bfd_print_symbol_name just print the name
1175 bfd_print_symbol_more print more (???)
1176 bfd_print_symbol_all print all we know, which is not much right now :-) */
1179 vms_print_symbol (abfd
, file
, symbol
, how
)
1183 bfd_print_symbol_type how
;
1186 vms_debug (1, "vms_print_symbol(%p, %p, %p, %d)\n", abfd
, file
, symbol
, how
);
1191 case bfd_print_symbol_name
:
1192 case bfd_print_symbol_more
:
1193 fprintf ((FILE *)file
," %s", symbol
->name
);
1196 case bfd_print_symbol_all
:
1198 const char *section_name
= symbol
->section
->name
;
1200 bfd_print_symbol_vandf (abfd
, (PTR
)file
, symbol
);
1202 fprintf ((FILE *)file
," %-8s %s", section_name
, symbol
->name
);
1209 /* Return information about symbol in ret.
1211 fill type, value and name
1214 B bss segment symbol
1216 D data segment symbol
1218 t a static function symbol
1219 T text segment symbol
1224 vms_get_symbol_info (abfd
, symbol
, ret
)
1225 bfd
*abfd ATTRIBUTE_UNUSED
;
1232 vms_debug (1, "vms_get_symbol_info(%p, %p, %p)\n", abfd
, symbol
, ret
);
1235 sec
= symbol
->section
;
1240 if (bfd_is_com_section (sec
))
1242 else if (bfd_is_abs_section (sec
))
1244 else if (bfd_is_und_section (sec
))
1246 else if (bfd_is_ind_section (sec
))
1248 else if (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
)
1250 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
1252 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
1257 if (ret
->type
!= 'U')
1258 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
1261 ret
->name
= symbol
->name
;
1266 /* Return true if the given symbol sym in the BFD abfd is
1267 a compiler generated local label, else return false. */
1270 vms_bfd_is_local_label_name (abfd
, name
)
1271 bfd
*abfd ATTRIBUTE_UNUSED
;
1275 vms_debug (1, "vms_bfd_is_local_label_name(%p, %s)\n", abfd
, name
);
1277 return name
[0] == '$';
1280 /* Get source line number for symbol */
1283 vms_get_lineno (abfd
, symbol
)
1284 bfd
*abfd ATTRIBUTE_UNUSED
;
1285 asymbol
*symbol ATTRIBUTE_UNUSED
;
1288 vms_debug (1, "vms_get_lineno(%p, %p)\n", abfd
, symbol
);
1293 /* Provided a BFD, a section and an offset into the section, calculate and
1294 return the name of the source file and the line nearest to the wanted
1298 vms_find_nearest_line (abfd
, section
, symbols
, offset
, file
, func
, line
)
1299 bfd
*abfd ATTRIBUTE_UNUSED
;
1300 asection
*section ATTRIBUTE_UNUSED
;
1301 asymbol
**symbols ATTRIBUTE_UNUSED
;
1302 bfd_vma offset ATTRIBUTE_UNUSED
;
1303 const char **file ATTRIBUTE_UNUSED
;
1304 const char **func ATTRIBUTE_UNUSED
;
1305 unsigned int *line ATTRIBUTE_UNUSED
;
1308 vms_debug (1, "vms_find_nearest_line(%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
1309 abfd
, section
->name
, symbols
, (long int)offset
);
1314 /* Back-door to allow format-aware applications to create debug symbols
1315 while using BFD for everything else. Currently used by the assembler
1316 when creating COFF files. */
1319 vms_bfd_make_debug_symbol (abfd
, ptr
, size
)
1320 bfd
*abfd ATTRIBUTE_UNUSED
;
1321 void *ptr ATTRIBUTE_UNUSED
;
1322 unsigned long size ATTRIBUTE_UNUSED
;
1325 vms_debug (1, "vms_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd
, ptr
, size
);
1330 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1331 symbols. The minisymbol_to_symbol function translates these into
1332 BFD asymbol structures. */
1335 vms_read_minisymbols (abfd
, dynamic
, minisymsp
, sizep
)
1339 unsigned int *sizep
;
1342 vms_debug (1, "vms_read_minisymbols(%p, %d, %p, %d)\n", abfd
, dynamic
, minisymsp
, *sizep
);
1344 return _bfd_generic_read_minisymbols (abfd
, dynamic
, minisymsp
, sizep
);
1347 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1348 unmodified a.out symbol. The SYM argument is a structure returned
1349 by bfd_make_empty_symbol, which we fill in here. */
1352 vms_minisymbol_to_symbol (abfd
, dynamic
, minisym
, sym
)
1359 vms_debug (1, "vms_minisymbol_to_symbol(%p, %d, %p, %p)\n", abfd
, dynamic
, minisym
, sym
);
1361 return _bfd_generic_minisymbol_to_symbol (abfd
, dynamic
, minisym
, sym
);
1364 /*-- Part 4.6, relocations --------------------------------------------------*/
1366 /* Return the number of bytes required to store the relocation information
1367 associated with section sect attached to bfd abfd.
1368 If an error occurs, return -1. */
1371 vms_get_reloc_upper_bound (abfd
, section
)
1372 bfd
*abfd ATTRIBUTE_UNUSED
;
1373 asection
*section ATTRIBUTE_UNUSED
;
1376 vms_debug (1, "vms_get_reloc_upper_bound(%p, %s)\n", abfd
, section
->name
);
1381 /* Call the back end associated with the open BFD abfd and translate the
1382 external form of the relocation information attached to sec into the
1383 internal canonical form. Place the table into memory at loc, which has
1384 been preallocated, usually by a call to bfd_get_reloc_upper_bound.
1385 Returns the number of relocs, or -1 on error. */
1388 vms_canonicalize_reloc (abfd
, section
, location
, symbols
)
1389 bfd
*abfd ATTRIBUTE_UNUSED
;
1390 asection
*section ATTRIBUTE_UNUSED
;
1391 arelent
**location ATTRIBUTE_UNUSED
;
1392 asymbol
**symbols ATTRIBUTE_UNUSED
;
1395 vms_debug (1, "vms_canonicalize_reloc(%p, %s, <ret>, <ret>)\n", abfd
, section
->name
);
1400 /*---------------------------------------------------------------------------*/
1401 /* this is just copied from ecoff-alpha, needs to be fixed probably */
1403 /* How to process the various reloc types. */
1405 static bfd_reloc_status_type
1406 reloc_nil (abfd
, reloc
, sym
, data
, sec
, output_bfd
, error_message
)
1407 bfd
*abfd ATTRIBUTE_UNUSED
;
1408 arelent
*reloc ATTRIBUTE_UNUSED
;
1409 asymbol
*sym ATTRIBUTE_UNUSED
;
1410 PTR data ATTRIBUTE_UNUSED
;
1411 asection
*sec ATTRIBUTE_UNUSED
;
1412 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1413 char **error_message ATTRIBUTE_UNUSED
;
1416 vms_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
1417 vms_debug (2, "In section %s, symbol %s\n",
1418 sec
->name
, sym
->name
);
1419 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1420 reloc
->sym_ptr_ptr
[0]->name
,
1421 (unsigned long)reloc
->address
,
1422 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
1423 vms_debug (2, "data at %p\n", data
);
1424 /* _bfd_hexdump (2, data, bfd_get_reloc_size(reloc->howto),0); */
1427 return bfd_reloc_ok
;
1430 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1431 from smaller values. Start with zero, widen, *then* decrement. */
1432 #define MINUS_ONE (((bfd_vma)0) - 1)
1434 static reloc_howto_type alpha_howto_table
[] =
1436 HOWTO (ALPHA_R_IGNORE
, /* type */
1438 0, /* size (0 = byte, 1 = short, 2 = long) */
1440 true, /* pc_relative */
1442 complain_overflow_dont
, /* complain_on_overflow */
1443 reloc_nil
, /* special_function */
1444 "IGNORE", /* name */
1445 true, /* partial_inplace */
1448 true), /* pcrel_offset */
1450 /* A 64 bit reference to a symbol. */
1451 HOWTO (ALPHA_R_REFQUAD
, /* type */
1453 4, /* size (0 = byte, 1 = short, 2 = long) */
1455 false, /* pc_relative */
1457 complain_overflow_bitfield
, /* complain_on_overflow */
1458 reloc_nil
, /* special_function */
1459 "REFQUAD", /* name */
1460 true, /* partial_inplace */
1461 MINUS_ONE
, /* src_mask */
1462 MINUS_ONE
, /* dst_mask */
1463 false), /* pcrel_offset */
1465 /* A 21 bit branch. The native assembler generates these for
1466 branches within the text segment, and also fills in the PC
1467 relative offset in the instruction. */
1468 HOWTO (ALPHA_R_BRADDR
, /* type */
1470 2, /* size (0 = byte, 1 = short, 2 = long) */
1472 true, /* pc_relative */
1474 complain_overflow_signed
, /* complain_on_overflow */
1475 reloc_nil
, /* special_function */
1476 "BRADDR", /* name */
1477 true, /* partial_inplace */
1478 0x1fffff, /* src_mask */
1479 0x1fffff, /* dst_mask */
1480 false), /* pcrel_offset */
1482 /* A hint for a jump to a register. */
1483 HOWTO (ALPHA_R_HINT
, /* type */
1485 1, /* size (0 = byte, 1 = short, 2 = long) */
1487 true, /* pc_relative */
1489 complain_overflow_dont
, /* complain_on_overflow */
1490 reloc_nil
, /* special_function */
1492 true, /* partial_inplace */
1493 0x3fff, /* src_mask */
1494 0x3fff, /* dst_mask */
1495 false), /* pcrel_offset */
1497 /* 16 bit PC relative offset. */
1498 HOWTO (ALPHA_R_SREL16
, /* type */
1500 1, /* size (0 = byte, 1 = short, 2 = long) */
1502 true, /* pc_relative */
1504 complain_overflow_signed
, /* complain_on_overflow */
1505 reloc_nil
, /* special_function */
1506 "SREL16", /* name */
1507 true, /* partial_inplace */
1508 0xffff, /* src_mask */
1509 0xffff, /* dst_mask */
1510 false), /* pcrel_offset */
1512 /* 32 bit PC relative offset. */
1513 HOWTO (ALPHA_R_SREL32
, /* type */
1515 2, /* size (0 = byte, 1 = short, 2 = long) */
1517 true, /* pc_relative */
1519 complain_overflow_signed
, /* complain_on_overflow */
1520 reloc_nil
, /* special_function */
1521 "SREL32", /* name */
1522 true, /* partial_inplace */
1523 0xffffffff, /* src_mask */
1524 0xffffffff, /* dst_mask */
1525 false), /* pcrel_offset */
1527 /* A 64 bit PC relative offset. */
1528 HOWTO (ALPHA_R_SREL64
, /* type */
1530 4, /* size (0 = byte, 1 = short, 2 = long) */
1532 true, /* pc_relative */
1534 complain_overflow_signed
, /* complain_on_overflow */
1535 reloc_nil
, /* special_function */
1536 "SREL64", /* name */
1537 true, /* partial_inplace */
1538 MINUS_ONE
, /* src_mask */
1539 MINUS_ONE
, /* dst_mask */
1540 false), /* pcrel_offset */
1542 /* Push a value on the reloc evaluation stack. */
1543 HOWTO (ALPHA_R_OP_PUSH
, /* type */
1545 0, /* size (0 = byte, 1 = short, 2 = long) */
1547 false, /* pc_relative */
1549 complain_overflow_dont
, /* complain_on_overflow */
1550 reloc_nil
, /* special_function */
1551 "OP_PUSH", /* name */
1552 false, /* partial_inplace */
1555 false), /* pcrel_offset */
1557 /* Store the value from the stack at the given address. Store it in
1558 a bitfield of size r_size starting at bit position r_offset. */
1559 HOWTO (ALPHA_R_OP_STORE
, /* type */
1561 4, /* size (0 = byte, 1 = short, 2 = long) */
1563 false, /* pc_relative */
1565 complain_overflow_dont
, /* complain_on_overflow */
1566 reloc_nil
, /* special_function */
1567 "OP_STORE", /* name */
1568 false, /* partial_inplace */
1570 MINUS_ONE
, /* dst_mask */
1571 false), /* pcrel_offset */
1573 /* Subtract the reloc address from the value on the top of the
1574 relocation stack. */
1575 HOWTO (ALPHA_R_OP_PSUB
, /* type */
1577 0, /* size (0 = byte, 1 = short, 2 = long) */
1579 false, /* pc_relative */
1581 complain_overflow_dont
, /* complain_on_overflow */
1582 reloc_nil
, /* special_function */
1583 "OP_PSUB", /* name */
1584 false, /* partial_inplace */
1587 false), /* pcrel_offset */
1589 /* Shift the value on the top of the relocation stack right by the
1591 HOWTO (ALPHA_R_OP_PRSHIFT
, /* type */
1593 0, /* size (0 = byte, 1 = short, 2 = long) */
1595 false, /* pc_relative */
1597 complain_overflow_dont
, /* complain_on_overflow */
1598 reloc_nil
, /* special_function */
1599 "OP_PRSHIFT", /* name */
1600 false, /* partial_inplace */
1603 false), /* pcrel_offset */
1605 /* Hack. Linkage is done by linker. */
1606 HOWTO (ALPHA_R_LINKAGE
, /* type */
1608 8, /* size (0 = byte, 1 = short, 2 = long) */
1610 false, /* pc_relative */
1612 complain_overflow_dont
, /* complain_on_overflow */
1613 reloc_nil
, /* special_function */
1614 "LINKAGE", /* name */
1615 false, /* partial_inplace */
1618 false), /* pcrel_offset */
1620 /* A 32 bit reference to a symbol. */
1621 HOWTO (ALPHA_R_REFLONG
, /* type */
1623 2, /* size (0 = byte, 1 = short, 2 = long) */
1625 false, /* pc_relative */
1627 complain_overflow_bitfield
, /* complain_on_overflow */
1628 reloc_nil
, /* special_function */
1629 "REFLONG", /* name */
1630 true, /* partial_inplace */
1631 0xffffffff, /* src_mask */
1632 0xffffffff, /* dst_mask */
1633 false), /* pcrel_offset */
1635 /* A 64 bit reference to a procedure, written as 32 bit value. */
1636 HOWTO (ALPHA_R_CODEADDR
, /* type */
1638 4, /* size (0 = byte, 1 = short, 2 = long) */
1640 false, /* pc_relative */
1642 complain_overflow_signed
,/* complain_on_overflow */
1643 reloc_nil
, /* special_function */
1644 "CODEADDR", /* name */
1645 false, /* partial_inplace */
1646 0xffffffff, /* src_mask */
1647 0xffffffff, /* dst_mask */
1648 false), /* pcrel_offset */
1652 /* Return a pointer to a howto structure which, when invoked, will perform
1653 the relocation code on data from the architecture noted. */
1655 static const struct reloc_howto_struct
*
1656 vms_bfd_reloc_type_lookup (abfd
, code
)
1657 bfd
*abfd ATTRIBUTE_UNUSED
;
1658 bfd_reloc_code_real_type code
;
1663 vms_debug (1, "vms_bfd_reloc_type_lookup(%p, %d)\t", abfd
, code
);
1668 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
1669 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
1670 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
1671 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
1672 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
1673 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
1674 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
1675 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
1676 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
1677 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
1678 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
1680 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
1681 return (const struct reloc_howto_struct
*) NULL
;
1684 vms_debug (2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
);
1686 return &alpha_howto_table
[alpha_type
];
1689 /*-- Part 4.7, writing an object file ---------------------------------------*/
1691 /* Set the architecture and machine type in BFD abfd to arch and mach.
1692 Find the correct pointer to a structure and insert it into the arch_info
1696 vms_set_arch_mach (abfd
, arch
, mach
)
1698 enum bfd_architecture arch ATTRIBUTE_UNUSED
;
1699 unsigned long mach ATTRIBUTE_UNUSED
;
1702 vms_debug (1, "vms_set_arch_mach(%p, %d, %ld)\n", abfd
, arch
, mach
);
1704 abfd
->arch_info
= bfd_scan_arch("alpha");
1709 /* Sets the contents of the section section in BFD abfd to the data starting
1710 in memory at data. The data is written to the output section starting at
1711 offset offset for count bytes.
1713 Normally true is returned, else false. Possible error returns are:
1714 o bfd_error_no_contents - The output section does not have the
1715 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1716 o and some more too */
1719 vms_set_section_contents (abfd
, section
, location
, offset
, count
)
1724 bfd_size_type count
;
1727 vms_debug (1, "vms_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n",
1728 abfd
, section
->name
, location
, (long int)offset
, (int)count
);
1729 vms_debug (2, "secraw %d, seccooked %d\n", (int)section
->_raw_size
, (int)section
->_cooked_size
);
1731 return _bfd_save_vms_section(abfd
, section
, location
, offset
, count
);
1734 /*-- Part 4.8, linker -------------------------------------------------------*/
1736 /* Get the size of the section headers. */
1739 vms_sizeof_headers (abfd
, reloc
)
1740 bfd
*abfd ATTRIBUTE_UNUSED
;
1741 boolean reloc ATTRIBUTE_UNUSED
;
1744 vms_debug (1, "vms_sizeof_headers(%p, %s)\n", abfd
, (reloc
)?"True":"False");
1749 /* Provides default handling of relocation effort for back ends
1750 which can't be bothered to do it efficiently. */
1753 vms_bfd_get_relocated_section_contents (abfd
, link_info
, link_order
, data
,
1754 relocateable
, symbols
)
1755 bfd
*abfd ATTRIBUTE_UNUSED
;
1756 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1757 struct bfd_link_order
*link_order ATTRIBUTE_UNUSED
;
1758 bfd_byte
*data ATTRIBUTE_UNUSED
;
1759 boolean relocateable ATTRIBUTE_UNUSED
;
1760 asymbol
**symbols ATTRIBUTE_UNUSED
;
1763 vms_debug (1, "vms_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n",
1764 abfd
, link_info
, link_order
, data
, (relocateable
)?"True":"False", symbols
);
1772 vms_bfd_relax_section (abfd
, section
, link_info
, again
)
1773 bfd
*abfd ATTRIBUTE_UNUSED
;
1774 asection
*section ATTRIBUTE_UNUSED
;
1775 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1776 boolean
*again ATTRIBUTE_UNUSED
;
1779 vms_debug (1, "vms_bfd_relax_section(%p, %s, %p, <ret>)\n",
1780 abfd
, section
->name
, link_info
);
1786 vms_bfd_gc_sections (abfd
, link_info
)
1787 bfd
*abfd ATTRIBUTE_UNUSED
;
1788 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1791 vms_debug (1, "vms_bfd_gc_sections(%p, %p)\n", abfd
, link_info
);
1797 vms_bfd_merge_sections (abfd
, link_info
)
1798 bfd
*abfd ATTRIBUTE_UNUSED
;
1799 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1802 vms_debug (1, "vms_bfd_merge_sections(%p, %p)\n", abfd
, link_info
);
1807 /* Create a hash table for the linker. Different backends store
1808 different information in this table. */
1810 static struct bfd_link_hash_table
*
1811 vms_bfd_link_hash_table_create (abfd
)
1812 bfd
*abfd ATTRIBUTE_UNUSED
;
1815 vms_debug (1, "vms_bfd_link_hash_table_create(%p)\n", abfd
);
1820 /* Add symbols from this object file into the hash table. */
1823 vms_bfd_link_add_symbols (abfd
, link_info
)
1824 bfd
*abfd ATTRIBUTE_UNUSED
;
1825 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1828 vms_debug (1, "vms_bfd_link_add_symbols(%p, %p)\n", abfd
, link_info
);
1833 /* Do a link based on the link_order structures attached to each
1834 section of the BFD. */
1837 vms_bfd_final_link (abfd
, link_info
)
1838 bfd
*abfd ATTRIBUTE_UNUSED
;
1839 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1842 vms_debug (1, "vms_bfd_final_link(%p, %p)\n", abfd
, link_info
);
1847 /* Should this section be split up into smaller pieces during linking. */
1850 vms_bfd_link_split_section (abfd
, section
)
1851 bfd
*abfd ATTRIBUTE_UNUSED
;
1852 asection
*section ATTRIBUTE_UNUSED
;
1855 vms_debug (1, "vms_bfd_link_split_section(%p, %s)\n", abfd
, section
->name
);
1860 /*-- Part 4.9, dynamic symbols and relocations ------------------------------*/
1862 /* Get the amount of memory required to hold the dynamic symbols. */
1865 vms_get_dynamic_symtab_upper_bound (abfd
)
1866 bfd
*abfd ATTRIBUTE_UNUSED
;
1869 vms_debug (1, "vms_get_dynamic_symtab_upper_bound(%p)\n", abfd
);
1875 vms_bfd_print_private_bfd_data (abfd
, file
)
1876 bfd
*abfd ATTRIBUTE_UNUSED
;
1877 void *file ATTRIBUTE_UNUSED
;
1880 vms_debug (1, "vms_bfd_print_private_bfd_data(%p)\n", abfd
);
1885 /* Read in the dynamic symbols. */
1888 vms_canonicalize_dynamic_symtab (abfd
, symbols
)
1889 bfd
*abfd ATTRIBUTE_UNUSED
;
1890 asymbol
**symbols ATTRIBUTE_UNUSED
;
1893 vms_debug (1, "vms_canonicalize_dynamic_symtab(%p, <ret>)\n", abfd
);
1898 /* Get the amount of memory required to hold the dynamic relocs. */
1901 vms_get_dynamic_reloc_upper_bound (abfd
)
1902 bfd
*abfd ATTRIBUTE_UNUSED
;
1905 vms_debug (1, "vms_get_dynamic_reloc_upper_bound(%p)\n", abfd
);
1910 /* Read in the dynamic relocs. */
1913 vms_canonicalize_dynamic_reloc (abfd
, arel
, symbols
)
1914 bfd
*abfd ATTRIBUTE_UNUSED
;
1915 arelent
**arel ATTRIBUTE_UNUSED
;
1916 asymbol
**symbols ATTRIBUTE_UNUSED
;
1919 vms_debug (1, "vms_canonicalize_dynamic_reloc(%p)\n", abfd
);