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