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