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, |
157090f7 | 4 | 2006, 2007 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 |
7920ce38 | 431 | if (abfd == NULL) |
b34976b6 | 432 | return TRUE; |
252b5132 | 433 | |
8a0c27cd | 434 | if (PRIV (vms_buf) != NULL) |
487e54f2 | 435 | free (PRIV (vms_buf)); |
252b5132 | 436 | |
8a0c27cd | 437 | if (PRIV (sections) != NULL) |
487e54f2 | 438 | free (PRIV (sections)); |
252b5132 | 439 | |
8a0c27cd | 440 | if (PRIV (vms_symbol_table)) |
487e54f2 | 441 | bfd_hash_table_free (PRIV (vms_symbol_table)); |
252b5132 | 442 | |
487e54f2 | 443 | bfd_release (abfd, abfd->tdata.any); |
252b5132 RH |
444 | abfd->tdata.any = NULL; |
445 | ||
b34976b6 | 446 | return TRUE; |
252b5132 RH |
447 | } |
448 | ||
252b5132 | 449 | /* Ask the BFD to free all cached information. */ |
7920ce38 | 450 | |
b34976b6 | 451 | static bfd_boolean |
7920ce38 | 452 | vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
453 | { |
454 | #if VMS_DEBUG | |
7920ce38 | 455 | vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd); |
252b5132 | 456 | #endif |
b34976b6 | 457 | return TRUE; |
252b5132 RH |
458 | } |
459 | ||
252b5132 RH |
460 | /* Called when a new section is created. */ |
461 | ||
b34976b6 | 462 | static bfd_boolean |
7920ce38 | 463 | vms_new_section_hook (bfd * abfd, asection *section) |
252b5132 | 464 | { |
4e6bfe8a AM |
465 | /* Count hasn't been incremented yet. */ |
466 | unsigned int section_count = abfd->section_count + 1; | |
467 | ||
252b5132 | 468 | #if VMS_DEBUG |
4e6bfe8a AM |
469 | vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n", |
470 | abfd, section->index, section->name, section_count); | |
252b5132 | 471 | #endif |
4e6bfe8a | 472 | bfd_set_section_alignment (abfd, section, 4); |
252b5132 | 473 | |
4e6bfe8a | 474 | if (section_count > PRIV (section_count)) |
252b5132 | 475 | { |
4e6bfe8a | 476 | bfd_size_type amt = section_count; |
dc810e39 | 477 | amt *= sizeof (asection *); |
7920ce38 NC |
478 | PRIV (sections) = bfd_realloc (PRIV (sections), amt); |
479 | if (PRIV (sections) == NULL) | |
b34976b6 | 480 | return FALSE; |
4e6bfe8a | 481 | PRIV (section_count) = section_count; |
252b5132 RH |
482 | } |
483 | #if VMS_DEBUG | |
8a0c27cd | 484 | vms_debug (6, "section_count: %d\n", PRIV (section_count)); |
252b5132 | 485 | #endif |
8a0c27cd | 486 | PRIV (sections)[section->index] = section; |
252b5132 RH |
487 | #if VMS_DEBUG |
488 | vms_debug (7, "%d: %s\n", section->index, section->name); | |
489 | #endif | |
490 | ||
f592407e | 491 | return _bfd_generic_new_section_hook (abfd, section); |
252b5132 RH |
492 | } |
493 | ||
252b5132 RH |
494 | /* Read the contents of a section. |
495 | buf points to a buffer of buf_size bytes to be filled with | |
496 | section data (starting at offset into section) */ | |
497 | ||
b34976b6 | 498 | static bfd_boolean |
7920ce38 NC |
499 | vms_get_section_contents (bfd * abfd ATTRIBUTE_UNUSED, |
500 | asection *section ATTRIBUTE_UNUSED, | |
501 | void * buf ATTRIBUTE_UNUSED, | |
502 | file_ptr offset ATTRIBUTE_UNUSED, | |
503 | bfd_size_type buf_size ATTRIBUTE_UNUSED) | |
252b5132 RH |
504 | { |
505 | #if VMS_DEBUG | |
7920ce38 | 506 | vms_debug (1, "vms_get_section_contents (%p, %s, %p, off %ld, size %d)\n", |
252b5132 RH |
507 | abfd, section->name, buf, offset, (int)buf_size); |
508 | #endif | |
509 | ||
7920ce38 | 510 | /* Shouldn't be called, since all sections are IN_MEMORY. */ |
b34976b6 | 511 | return FALSE; |
252b5132 RH |
512 | } |
513 | ||
514 | /* Read the contents of a section. | |
515 | buf points to a buffer of buf_size bytes to be filled with | |
7920ce38 | 516 | section data (starting at offset into section). */ |
252b5132 | 517 | |
b34976b6 | 518 | static bfd_boolean |
7920ce38 NC |
519 | vms_get_section_contents_in_window (bfd * abfd ATTRIBUTE_UNUSED, |
520 | asection *section ATTRIBUTE_UNUSED, | |
521 | bfd_window *w ATTRIBUTE_UNUSED, | |
522 | file_ptr offset ATTRIBUTE_UNUSED, | |
523 | bfd_size_type count ATTRIBUTE_UNUSED) | |
252b5132 RH |
524 | { |
525 | #if VMS_DEBUG | |
7920ce38 | 526 | vms_debug (1, "vms_get_section_contents_in_window (%p, %s, %p, off %ld, count %d)\n", |
252b5132 RH |
527 | abfd, section->name, w, offset, (int)count); |
528 | #endif | |
529 | ||
7920ce38 | 530 | /* Shouldn't be called, since all sections are IN_MEMORY. */ |
b34976b6 | 531 | return FALSE; |
252b5132 RH |
532 | } |
533 | ||
7920ce38 | 534 | /* Part 4.2, copy private data. */ |
252b5132 RH |
535 | |
536 | /* Called to copy BFD general private data from one object file | |
537 | to another. */ | |
538 | ||
b34976b6 | 539 | static bfd_boolean |
7920ce38 NC |
540 | vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED, |
541 | bfd *dest ATTRIBUTE_UNUSED) | |
252b5132 RH |
542 | { |
543 | #if VMS_DEBUG | |
7920ce38 | 544 | vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest); |
252b5132 | 545 | #endif |
b34976b6 | 546 | return TRUE; |
252b5132 RH |
547 | } |
548 | ||
252b5132 | 549 | /* Merge private BFD information from the BFD @var{ibfd} to the |
b34976b6 AM |
550 | the output file BFD @var{obfd} when linking. Return <<TRUE>> |
551 | on success, <<FALSE>> on error. Possible error returns are: | |
252b5132 RH |
552 | |
553 | o <<bfd_error_no_memory>> - | |
554 | Not enough memory exists to create private data for @var{obfd}. */ | |
555 | ||
b34976b6 | 556 | static bfd_boolean |
7920ce38 NC |
557 | vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED, |
558 | bfd * obfd ATTRIBUTE_UNUSED) | |
252b5132 RH |
559 | { |
560 | #if VMS_DEBUG | |
7920ce38 | 561 | vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd); |
252b5132 | 562 | #endif |
b34976b6 | 563 | return TRUE; |
252b5132 RH |
564 | } |
565 | ||
252b5132 | 566 | /* Set private BFD flag information in the BFD @var{abfd}. |
b34976b6 | 567 | Return <<TRUE>> on success, <<FALSE>> on error. Possible error |
252b5132 RH |
568 | returns are: |
569 | ||
570 | o <<bfd_error_no_memory>> - | |
571 | Not enough memory exists to create private data for @var{obfd}. */ | |
572 | ||
b34976b6 | 573 | static bfd_boolean |
7920ce38 NC |
574 | vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED, |
575 | flagword flags ATTRIBUTE_UNUSED) | |
252b5132 RH |
576 | { |
577 | #if VMS_DEBUG | |
7920ce38 | 578 | vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags); |
252b5132 | 579 | #endif |
b34976b6 | 580 | return TRUE; |
252b5132 RH |
581 | } |
582 | ||
252b5132 RH |
583 | /* Called to copy BFD private section data from one object file |
584 | to another. */ | |
585 | ||
b34976b6 | 586 | static bfd_boolean |
7920ce38 NC |
587 | vms_bfd_copy_private_section_data (bfd *srcbfd ATTRIBUTE_UNUSED, |
588 | asection *srcsec ATTRIBUTE_UNUSED, | |
589 | bfd *dstbfd ATTRIBUTE_UNUSED, | |
590 | asection *dstsec ATTRIBUTE_UNUSED) | |
252b5132 RH |
591 | { |
592 | #if VMS_DEBUG | |
7920ce38 | 593 | vms_debug (1, "vms_bfd_copy_private_section_data (%p, %s, %p, %s)\n", |
252b5132 RH |
594 | srcbfd, srcsec->name, dstbfd, dstsec->name); |
595 | #endif | |
b34976b6 | 596 | return TRUE; |
252b5132 RH |
597 | } |
598 | ||
599 | /* Called to copy BFD private symbol data from one object file | |
600 | to another. */ | |
601 | ||
b34976b6 | 602 | static bfd_boolean |
7920ce38 NC |
603 | vms_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED, |
604 | asymbol *isym ATTRIBUTE_UNUSED, | |
605 | bfd *obfd ATTRIBUTE_UNUSED, | |
606 | asymbol *osym ATTRIBUTE_UNUSED) | |
252b5132 RH |
607 | { |
608 | #if VMS_DEBUG | |
7920ce38 | 609 | vms_debug (1, "vms_bfd_copy_private_symbol_data (%p, %s, %p, %s)\n", |
252b5132 RH |
610 | ibfd, isym->name, obfd, osym->name); |
611 | #endif | |
b34976b6 | 612 | return TRUE; |
252b5132 RH |
613 | } |
614 | ||
7920ce38 | 615 | /* Part 4.3, core file. */ |
252b5132 RH |
616 | |
617 | /* Return a read-only string explaining which program was running | |
618 | when it failed and produced the core file abfd. */ | |
619 | ||
620 | static char * | |
7920ce38 | 621 | vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
622 | { |
623 | #if VMS_DEBUG | |
7920ce38 | 624 | vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd); |
252b5132 | 625 | #endif |
7920ce38 | 626 | return NULL; |
252b5132 RH |
627 | } |
628 | ||
252b5132 RH |
629 | /* Returns the signal number which caused the core dump which |
630 | generated the file the BFD abfd is attached to. */ | |
631 | ||
632 | static int | |
7920ce38 | 633 | vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
634 | { |
635 | #if VMS_DEBUG | |
7920ce38 | 636 | vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd); |
252b5132 RH |
637 | #endif |
638 | return 0; | |
639 | } | |
640 | ||
b34976b6 AM |
641 | /* Return TRUE if the core file attached to core_bfd was generated |
642 | by a run of the executable file attached to exec_bfd, FALSE otherwise. */ | |
252b5132 | 643 | |
b34976b6 | 644 | static bfd_boolean |
7920ce38 NC |
645 | vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED, |
646 | bfd *bbfd ATTRIBUTE_UNUSED) | |
252b5132 RH |
647 | { |
648 | #if VMS_DEBUG | |
7920ce38 | 649 | vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd); |
252b5132 | 650 | #endif |
b34976b6 | 651 | return FALSE; |
252b5132 RH |
652 | } |
653 | ||
7920ce38 | 654 | /* Part 4.4, archive. */ |
252b5132 RH |
655 | |
656 | /* ??? do something with an archive map. | |
b34976b6 | 657 | Return FALSE on error, TRUE otherwise. */ |
252b5132 | 658 | |
b34976b6 | 659 | static bfd_boolean |
7920ce38 | 660 | vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
661 | { |
662 | #if VMS_DEBUG | |
7920ce38 | 663 | vms_debug (1, "vms_slurp_armap (%p)\n", abfd); |
252b5132 | 664 | #endif |
b34976b6 | 665 | return FALSE; |
252b5132 RH |
666 | } |
667 | ||
252b5132 | 668 | /* ??? do something with an extended name table. |
b34976b6 | 669 | Return FALSE on error, TRUE otherwise. */ |
252b5132 | 670 | |
b34976b6 | 671 | static bfd_boolean |
7920ce38 | 672 | vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
673 | { |
674 | #if VMS_DEBUG | |
7920ce38 | 675 | vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd); |
252b5132 | 676 | #endif |
b34976b6 | 677 | return FALSE; |
252b5132 RH |
678 | } |
679 | ||
252b5132 | 680 | /* ??? do something with an extended name table. |
b34976b6 | 681 | Return FALSE on error, TRUE otherwise. */ |
252b5132 | 682 | |
b34976b6 | 683 | static bfd_boolean |
7920ce38 NC |
684 | vms_construct_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED, |
685 | char **tabloc ATTRIBUTE_UNUSED, | |
686 | bfd_size_type *tablen ATTRIBUTE_UNUSED, | |
687 | const char **name ATTRIBUTE_UNUSED) | |
252b5132 RH |
688 | { |
689 | #if VMS_DEBUG | |
7920ce38 | 690 | vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd); |
252b5132 | 691 | #endif |
b34976b6 | 692 | return FALSE; |
252b5132 RH |
693 | } |
694 | ||
7920ce38 | 695 | /* Truncate the name of an archive to match system-dependent restrictions. */ |
252b5132 RH |
696 | |
697 | static void | |
7920ce38 NC |
698 | vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED, |
699 | const char *pathname ATTRIBUTE_UNUSED, | |
700 | char *arhdr ATTRIBUTE_UNUSED) | |
252b5132 RH |
701 | { |
702 | #if VMS_DEBUG | |
7920ce38 | 703 | vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr); |
252b5132 RH |
704 | #endif |
705 | return; | |
706 | } | |
707 | ||
7920ce38 | 708 | /* ??? write archive map. */ |
252b5132 | 709 | |
b34976b6 | 710 | static bfd_boolean |
7920ce38 NC |
711 | vms_write_armap (bfd *arch ATTRIBUTE_UNUSED, |
712 | unsigned int elength ATTRIBUTE_UNUSED, | |
713 | struct orl *map ATTRIBUTE_UNUSED, | |
714 | unsigned int orl_count ATTRIBUTE_UNUSED, | |
715 | int stridx ATTRIBUTE_UNUSED) | |
252b5132 RH |
716 | { |
717 | #if VMS_DEBUG | |
7920ce38 | 718 | vms_debug (1, "vms_write_armap (%p, %d, %p, %d %d)\n", |
252b5132 RH |
719 | arch, elength, map, orl_count, stridx); |
720 | #endif | |
b34976b6 | 721 | return TRUE; |
252b5132 RH |
722 | } |
723 | ||
724 | /* Read archive header ??? */ | |
725 | ||
7920ce38 NC |
726 | static void * |
727 | vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED) | |
252b5132 RH |
728 | { |
729 | #if VMS_DEBUG | |
7920ce38 | 730 | vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd); |
252b5132 | 731 | #endif |
7920ce38 | 732 | return NULL; |
252b5132 RH |
733 | } |
734 | ||
252b5132 RH |
735 | /* Provided a BFD, @var{archive}, containing an archive and NULL, open |
736 | an input BFD on the first contained element and returns that. | |
737 | Subsequent calls should pass the archive and the previous return value | |
738 | to return a created BFD to the next contained element. | |
739 | NULL is returned when there are no more. */ | |
740 | ||
741 | static bfd * | |
7920ce38 NC |
742 | vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED, |
743 | bfd *prev ATTRIBUTE_UNUSED) | |
252b5132 RH |
744 | { |
745 | #if VMS_DEBUG | |
7920ce38 | 746 | vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev); |
252b5132 | 747 | #endif |
01fff6e2 | 748 | return NULL; |
252b5132 RH |
749 | } |
750 | ||
252b5132 RH |
751 | /* Return the BFD which is referenced by the symbol in ABFD indexed by |
752 | INDEX. INDEX should have been returned by bfd_get_next_mapent. */ | |
753 | ||
754 | static bfd * | |
7920ce38 | 755 | vms_get_elt_at_index (bfd * abfd, symindex index) |
252b5132 RH |
756 | { |
757 | #if VMS_DEBUG | |
7920ce38 | 758 | vms_debug (1, "vms_get_elt_at_index (%p, %p)\n", abfd, index); |
252b5132 | 759 | #endif |
7920ce38 | 760 | return _bfd_generic_get_elt_at_index (abfd, index); |
252b5132 RH |
761 | } |
762 | ||
252b5132 | 763 | /* ??? |
7920ce38 | 764 | -> bfd_generic_stat_arch_elt. */ |
252b5132 RH |
765 | |
766 | static int | |
7920ce38 | 767 | vms_generic_stat_arch_elt (bfd * abfd, struct stat *st) |
252b5132 RH |
768 | { |
769 | #if VMS_DEBUG | |
7920ce38 | 770 | vms_debug (1, "vms_generic_stat_arch_elt (%p, %p)\n", abfd, st); |
252b5132 | 771 | #endif |
dc810e39 | 772 | return bfd_generic_stat_arch_elt (abfd, st); |
252b5132 RH |
773 | } |
774 | ||
7920ce38 | 775 | /* This is a new function in bfd 2.5. */ |
252b5132 | 776 | |
b34976b6 | 777 | static bfd_boolean |
7920ce38 | 778 | vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
779 | { |
780 | #if VMS_DEBUG | |
7920ce38 | 781 | vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd); |
252b5132 | 782 | #endif |
b34976b6 | 783 | return TRUE; |
252b5132 RH |
784 | } |
785 | ||
7920ce38 | 786 | /* Part 4.5, symbols. */ |
252b5132 RH |
787 | |
788 | /* Return the number of bytes required to store a vector of pointers | |
789 | to asymbols for all the symbols in the BFD abfd, including a | |
790 | terminal NULL pointer. If there are no symbols in the BFD, | |
791 | then return 0. If an error occurs, return -1. */ | |
792 | ||
793 | static long | |
7920ce38 | 794 | vms_get_symtab_upper_bound (bfd * abfd) |
252b5132 RH |
795 | { |
796 | #if VMS_DEBUG | |
7920ce38 | 797 | vms_debug (1, "vms_get_symtab_upper_bound (%p), %d symbols\n", abfd, PRIV (gsd_sym_count)); |
252b5132 | 798 | #endif |
7920ce38 | 799 | return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *); |
252b5132 RH |
800 | } |
801 | ||
252b5132 RH |
802 | /* Copy symbols from hash table to symbol vector |
803 | ||
6cee3f79 | 804 | called from bfd_hash_traverse in vms_canonicalize_symtab |
7920ce38 | 805 | init counter to 0 if entry == 0. */ |
252b5132 | 806 | |
b34976b6 | 807 | static bfd_boolean |
7920ce38 | 808 | copy_symbols (struct bfd_hash_entry *entry, void * arg) |
252b5132 | 809 | { |
7920ce38 | 810 | bfd * abfd = (bfd *) arg; |
252b5132 | 811 | |
7920ce38 | 812 | if (entry == NULL) /* Init counter. */ |
8a0c27cd | 813 | PRIV (symnum) = 0; |
7920ce38 | 814 | else /* Fill vector, inc counter. */ |
8a0c27cd | 815 | PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol; |
252b5132 | 816 | |
b34976b6 | 817 | return TRUE; |
252b5132 RH |
818 | } |
819 | ||
252b5132 RH |
820 | /* Read the symbols from the BFD abfd, and fills in the vector |
821 | location with pointers to the symbols and a trailing NULL. | |
822 | ||
7920ce38 | 823 | Return number of symbols read. */ |
252b5132 RH |
824 | |
825 | static long | |
7920ce38 | 826 | vms_canonicalize_symtab (bfd * abfd, asymbol **symbols) |
252b5132 RH |
827 | { |
828 | #if VMS_DEBUG | |
7920ce38 | 829 | vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd); |
252b5132 RH |
830 | #endif |
831 | ||
7920ce38 NC |
832 | /* Init counter. */ |
833 | copy_symbols (NULL, abfd); | |
252b5132 | 834 | |
7920ce38 | 835 | /* Traverse table and fill symbols vector. */ |
8a0c27cd | 836 | PRIV (symcache) = symbols; |
7920ce38 | 837 | bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd); |
252b5132 | 838 | |
8a0c27cd | 839 | symbols[PRIV (gsd_sym_count)] = NULL; |
252b5132 | 840 | |
8a0c27cd | 841 | return PRIV (gsd_sym_count); |
252b5132 RH |
842 | } |
843 | ||
252b5132 RH |
844 | /* Print symbol to file according to how. how is one of |
845 | bfd_print_symbol_name just print the name | |
846 | bfd_print_symbol_more print more (???) | |
7920ce38 | 847 | bfd_print_symbol_all print all we know, which is not much right now :-). */ |
252b5132 RH |
848 | |
849 | static void | |
7920ce38 NC |
850 | vms_print_symbol (bfd * abfd, |
851 | void * file, | |
852 | asymbol *symbol, | |
853 | bfd_print_symbol_type how) | |
252b5132 RH |
854 | { |
855 | #if VMS_DEBUG | |
7920ce38 | 856 | vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how); |
252b5132 RH |
857 | #endif |
858 | ||
859 | switch (how) | |
860 | { | |
861 | case bfd_print_symbol_name: | |
862 | case bfd_print_symbol_more: | |
55f2d5ed | 863 | fprintf ((FILE *)file," %s", symbol->name); |
252b5132 RH |
864 | break; |
865 | ||
252b5132 RH |
866 | case bfd_print_symbol_all: |
867 | { | |
dc810e39 | 868 | const char *section_name = symbol->section->name; |
252b5132 | 869 | |
7920ce38 | 870 | bfd_print_symbol_vandf (abfd, file, symbol); |
252b5132 | 871 | |
7920ce38 | 872 | fprintf ((FILE *) file," %-8s %s", section_name, symbol->name); |
252b5132 RH |
873 | } |
874 | break; | |
875 | } | |
252b5132 RH |
876 | } |
877 | ||
252b5132 RH |
878 | /* Return information about symbol in ret. |
879 | ||
880 | fill type, value and name | |
881 | type: | |
882 | A absolute | |
883 | B bss segment symbol | |
884 | C common symbol | |
885 | D data segment symbol | |
886 | f filename | |
887 | t a static function symbol | |
888 | T text segment symbol | |
889 | U undefined | |
7920ce38 | 890 | - debug. */ |
252b5132 RH |
891 | |
892 | static void | |
7920ce38 NC |
893 | vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED, |
894 | asymbol *symbol, | |
895 | symbol_info *ret) | |
252b5132 RH |
896 | { |
897 | asection *sec; | |
898 | ||
899 | #if VMS_DEBUG | |
7920ce38 | 900 | vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret); |
252b5132 RH |
901 | #endif |
902 | ||
903 | sec = symbol->section; | |
904 | ||
7920ce38 | 905 | if (ret == NULL) |
252b5132 RH |
906 | return; |
907 | ||
908 | if (bfd_is_com_section (sec)) | |
909 | ret->type = 'C'; | |
910 | else if (bfd_is_abs_section (sec)) | |
911 | ret->type = 'A'; | |
912 | else if (bfd_is_und_section (sec)) | |
913 | ret->type = 'U'; | |
914 | else if (bfd_is_ind_section (sec)) | |
915 | ret->type = 'I'; | |
916 | else if (bfd_get_section_flags (abfd, sec) & SEC_CODE) | |
917 | ret->type = 'T'; | |
918 | else if (bfd_get_section_flags (abfd, sec) & SEC_DATA) | |
919 | ret->type = 'D'; | |
920 | else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC) | |
921 | ret->type = 'B'; | |
922 | else | |
923 | ret->type = '-'; | |
924 | ||
925 | if (ret->type != 'U') | |
926 | ret->value = symbol->value + symbol->section->vma; | |
927 | else | |
928 | ret->value = 0; | |
929 | ret->name = symbol->name; | |
252b5132 RH |
930 | } |
931 | ||
b34976b6 AM |
932 | /* Return TRUE if the given symbol sym in the BFD abfd is |
933 | a compiler generated local label, else return FALSE. */ | |
252b5132 | 934 | |
b34976b6 | 935 | static bfd_boolean |
7920ce38 NC |
936 | vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED, |
937 | const char *name) | |
252b5132 RH |
938 | { |
939 | #if VMS_DEBUG | |
7920ce38 | 940 | vms_debug (1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name); |
252b5132 RH |
941 | #endif |
942 | return name[0] == '$'; | |
943 | } | |
944 | ||
7920ce38 | 945 | /* Get source line number for symbol. */ |
252b5132 RH |
946 | |
947 | static alent * | |
7920ce38 NC |
948 | vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED, |
949 | asymbol *symbol ATTRIBUTE_UNUSED) | |
252b5132 RH |
950 | { |
951 | #if VMS_DEBUG | |
7920ce38 | 952 | vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol); |
252b5132 | 953 | #endif |
7920ce38 | 954 | return NULL; |
252b5132 RH |
955 | } |
956 | ||
252b5132 RH |
957 | /* Provided a BFD, a section and an offset into the section, calculate and |
958 | return the name of the source file and the line nearest to the wanted | |
959 | location. */ | |
960 | ||
b34976b6 | 961 | static bfd_boolean |
7920ce38 NC |
962 | vms_find_nearest_line (bfd * abfd ATTRIBUTE_UNUSED, |
963 | asection *section ATTRIBUTE_UNUSED, | |
964 | asymbol **symbols ATTRIBUTE_UNUSED, | |
965 | bfd_vma offset ATTRIBUTE_UNUSED, | |
966 | const char **file ATTRIBUTE_UNUSED, | |
967 | const char **func ATTRIBUTE_UNUSED, | |
968 | unsigned int *line ATTRIBUTE_UNUSED) | |
252b5132 RH |
969 | { |
970 | #if VMS_DEBUG | |
7920ce38 | 971 | vms_debug (1, "vms_find_nearest_line (%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n", |
252b5132 RH |
972 | abfd, section->name, symbols, (long int)offset); |
973 | #endif | |
b34976b6 | 974 | return FALSE; |
252b5132 RH |
975 | } |
976 | ||
4ab527b0 FF |
977 | static bfd_boolean |
978 | vms_find_inliner_info (bfd * abfd ATTRIBUTE_UNUSED, | |
979 | const char **file ATTRIBUTE_UNUSED, | |
980 | const char **func ATTRIBUTE_UNUSED, | |
981 | unsigned int *line ATTRIBUTE_UNUSED) | |
982 | { | |
983 | #if VMS_DEBUG | |
984 | vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n", | |
985 | abfd); | |
986 | #endif | |
987 | return FALSE; | |
988 | } | |
989 | ||
252b5132 RH |
990 | /* Back-door to allow format-aware applications to create debug symbols |
991 | while using BFD for everything else. Currently used by the assembler | |
992 | when creating COFF files. */ | |
993 | ||
994 | static asymbol * | |
7920ce38 NC |
995 | vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED, |
996 | void *ptr ATTRIBUTE_UNUSED, | |
997 | unsigned long size ATTRIBUTE_UNUSED) | |
252b5132 RH |
998 | { |
999 | #if VMS_DEBUG | |
7920ce38 | 1000 | vms_debug (1, "vms_bfd_make_debug_symbol (%p, %p, %ld)\n", abfd, ptr, size); |
252b5132 | 1001 | #endif |
7920ce38 | 1002 | return NULL; |
252b5132 RH |
1003 | } |
1004 | ||
252b5132 RH |
1005 | /* Read minisymbols. For minisymbols, we use the unmodified a.out |
1006 | symbols. The minisymbol_to_symbol function translates these into | |
1007 | BFD asymbol structures. */ | |
1008 | ||
1009 | static long | |
7920ce38 NC |
1010 | vms_read_minisymbols (bfd * abfd, |
1011 | bfd_boolean dynamic, | |
1012 | void * *minisymsp, | |
1013 | unsigned int *sizep) | |
252b5132 RH |
1014 | { |
1015 | #if VMS_DEBUG | |
7920ce38 | 1016 | vms_debug (1, "vms_read_minisymbols (%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep); |
252b5132 RH |
1017 | #endif |
1018 | return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep); | |
1019 | } | |
1020 | ||
1021 | /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an | |
1022 | unmodified a.out symbol. The SYM argument is a structure returned | |
1023 | by bfd_make_empty_symbol, which we fill in here. */ | |
1024 | ||
1025 | static asymbol * | |
7920ce38 NC |
1026 | vms_minisymbol_to_symbol (bfd * abfd, |
1027 | bfd_boolean dynamic, | |
1028 | const void * minisym, | |
1029 | asymbol *sym) | |
252b5132 RH |
1030 | { |
1031 | #if VMS_DEBUG | |
7920ce38 | 1032 | vms_debug (1, "vms_minisymbol_to_symbol (%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym); |
252b5132 RH |
1033 | #endif |
1034 | return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym); | |
1035 | } | |
1036 | ||
7920ce38 | 1037 | /* Part 4.6, relocations. */ |
252b5132 RH |
1038 | |
1039 | /* Return the number of bytes required to store the relocation information | |
1040 | associated with section sect attached to bfd abfd. | |
1041 | If an error occurs, return -1. */ | |
1042 | ||
1043 | static long | |
7920ce38 NC |
1044 | vms_get_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED, |
1045 | asection *section ATTRIBUTE_UNUSED) | |
252b5132 RH |
1046 | { |
1047 | #if VMS_DEBUG | |
7920ce38 | 1048 | vms_debug (1, "vms_get_reloc_upper_bound (%p, %s)\n", abfd, section->name); |
252b5132 RH |
1049 | #endif |
1050 | return -1L; | |
1051 | } | |
1052 | ||
252b5132 RH |
1053 | /* Call the back end associated with the open BFD abfd and translate the |
1054 | external form of the relocation information attached to sec into the | |
1055 | internal canonical form. Place the table into memory at loc, which has | |
1056 | been preallocated, usually by a call to bfd_get_reloc_upper_bound. | |
1057 | Returns the number of relocs, or -1 on error. */ | |
1058 | ||
1059 | static long | |
7920ce38 NC |
1060 | vms_canonicalize_reloc (bfd * abfd ATTRIBUTE_UNUSED, |
1061 | asection *section ATTRIBUTE_UNUSED, | |
1062 | arelent **location ATTRIBUTE_UNUSED, | |
1063 | asymbol **symbols ATTRIBUTE_UNUSED) | |
252b5132 RH |
1064 | { |
1065 | #if VMS_DEBUG | |
7920ce38 | 1066 | vms_debug (1, "vms_canonicalize_reloc (%p, %s, <ret>, <ret>)\n", abfd, section->name); |
252b5132 | 1067 | #endif |
b34976b6 | 1068 | return FALSE; |
252b5132 | 1069 | } |
7920ce38 NC |
1070 | \f |
1071 | /* This is just copied from ecoff-alpha, needs to be fixed probably. */ | |
252b5132 RH |
1072 | |
1073 | /* How to process the various reloc types. */ | |
1074 | ||
1075 | static bfd_reloc_status_type | |
7920ce38 NC |
1076 | reloc_nil (bfd * abfd ATTRIBUTE_UNUSED, |
1077 | arelent *reloc ATTRIBUTE_UNUSED, | |
1078 | asymbol *sym ATTRIBUTE_UNUSED, | |
1079 | void * data ATTRIBUTE_UNUSED, | |
1080 | asection *sec ATTRIBUTE_UNUSED, | |
1081 | bfd *output_bfd ATTRIBUTE_UNUSED, | |
1082 | char **error_message ATTRIBUTE_UNUSED) | |
252b5132 RH |
1083 | { |
1084 | #if VMS_DEBUG | |
7920ce38 | 1085 | vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd); |
252b5132 RH |
1086 | vms_debug (2, "In section %s, symbol %s\n", |
1087 | sec->name, sym->name); | |
1088 | vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n", | |
1089 | reloc->sym_ptr_ptr[0]->name, | |
1090 | (unsigned long)reloc->address, | |
1091 | (unsigned long)reloc->addend, reloc->howto->name); | |
1092 | vms_debug (2, "data at %p\n", data); | |
7920ce38 | 1093 | /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */ |
252b5132 RH |
1094 | #endif |
1095 | ||
1096 | return bfd_reloc_ok; | |
1097 | } | |
1098 | ||
1099 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value | |
1100 | from smaller values. Start with zero, widen, *then* decrement. */ | |
1101 | #define MINUS_ONE (((bfd_vma)0) - 1) | |
1102 | ||
1103 | static reloc_howto_type alpha_howto_table[] = | |
1104 | { | |
7920ce38 NC |
1105 | HOWTO (ALPHA_R_IGNORE, /* Type. */ |
1106 | 0, /* Rightshift. */ | |
1107 | 0, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1108 | 8, /* Bitsize. */ | |
1109 | TRUE, /* PC relative. */ | |
1110 | 0, /* Bitpos. */ | |
1111 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1112 | reloc_nil, /* Special_function. */ | |
1113 | "IGNORE", /* Name. */ | |
1114 | TRUE, /* Partial_inplace. */ | |
1115 | 0, /* Source mask */ | |
1116 | 0, /* Dest mask. */ | |
1117 | TRUE), /* PC rel offset. */ | |
252b5132 RH |
1118 | |
1119 | /* A 64 bit reference to a symbol. */ | |
7920ce38 NC |
1120 | HOWTO (ALPHA_R_REFQUAD, /* Type. */ |
1121 | 0, /* Rightshift. */ | |
1122 | 4, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1123 | 64, /* Bitsize. */ | |
1124 | FALSE, /* PC relative. */ | |
1125 | 0, /* Bitpos. */ | |
1126 | complain_overflow_bitfield, /* Complain_on_overflow. */ | |
1127 | reloc_nil, /* Special_function. */ | |
1128 | "REFQUAD", /* Name. */ | |
1129 | TRUE, /* Partial_inplace. */ | |
1130 | MINUS_ONE, /* Source mask. */ | |
1131 | MINUS_ONE, /* Dest mask. */ | |
1132 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1133 | |
1134 | /* A 21 bit branch. The native assembler generates these for | |
1135 | branches within the text segment, and also fills in the PC | |
1136 | relative offset in the instruction. */ | |
7920ce38 NC |
1137 | HOWTO (ALPHA_R_BRADDR, /* Type. */ |
1138 | 2, /* Rightshift. */ | |
1139 | 2, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1140 | 21, /* Bitsize. */ | |
1141 | TRUE, /* PC relative. */ | |
1142 | 0, /* Bitpos. */ | |
1143 | complain_overflow_signed, /* Complain_on_overflow. */ | |
1144 | reloc_nil, /* Special_function. */ | |
1145 | "BRADDR", /* Name. */ | |
1146 | TRUE, /* Partial_inplace. */ | |
1147 | 0x1fffff, /* Source mask. */ | |
1148 | 0x1fffff, /* Dest mask. */ | |
1149 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1150 | |
1151 | /* A hint for a jump to a register. */ | |
7920ce38 NC |
1152 | HOWTO (ALPHA_R_HINT, /* Type. */ |
1153 | 2, /* Rightshift. */ | |
1154 | 1, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1155 | 14, /* Bitsize. */ | |
1156 | TRUE, /* PC relative. */ | |
1157 | 0, /* Bitpos. */ | |
1158 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1159 | reloc_nil, /* Special_function. */ | |
1160 | "HINT", /* Name. */ | |
1161 | TRUE, /* Partial_inplace. */ | |
1162 | 0x3fff, /* Source mask. */ | |
1163 | 0x3fff, /* Dest mask. */ | |
1164 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1165 | |
1166 | /* 16 bit PC relative offset. */ | |
7920ce38 NC |
1167 | HOWTO (ALPHA_R_SREL16, /* Type. */ |
1168 | 0, /* Rightshift. */ | |
1169 | 1, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1170 | 16, /* Bitsize. */ | |
1171 | TRUE, /* PC relative. */ | |
1172 | 0, /* Bitpos. */ | |
1173 | complain_overflow_signed, /* Complain_on_overflow. */ | |
1174 | reloc_nil, /* Special_function. */ | |
1175 | "SREL16", /* Name. */ | |
1176 | TRUE, /* Partial_inplace. */ | |
1177 | 0xffff, /* Source mask. */ | |
1178 | 0xffff, /* Dest mask. */ | |
1179 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1180 | |
1181 | /* 32 bit PC relative offset. */ | |
7920ce38 NC |
1182 | HOWTO (ALPHA_R_SREL32, /* Type. */ |
1183 | 0, /* Rightshift. */ | |
1184 | 2, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1185 | 32, /* Bitsize. */ | |
1186 | TRUE, /* PC relative. */ | |
1187 | 0, /* Bitpos. */ | |
1188 | complain_overflow_signed, /* Complain_on_overflow. */ | |
1189 | reloc_nil, /* Special_function. */ | |
1190 | "SREL32", /* Name. */ | |
1191 | TRUE, /* Partial_inplace. */ | |
1192 | 0xffffffff, /* Source mask. */ | |
1193 | 0xffffffff, /* Dest mask. */ | |
1194 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1195 | |
1196 | /* A 64 bit PC relative offset. */ | |
7920ce38 NC |
1197 | HOWTO (ALPHA_R_SREL64, /* Type. */ |
1198 | 0, /* Rightshift. */ | |
1199 | 4, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1200 | 64, /* Bitsize. */ | |
1201 | TRUE, /* PC relative. */ | |
1202 | 0, /* Bitpos. */ | |
1203 | complain_overflow_signed, /* Complain_on_overflow. */ | |
1204 | reloc_nil, /* Special_function. */ | |
1205 | "SREL64", /* Name. */ | |
1206 | TRUE, /* Partial_inplace. */ | |
1207 | MINUS_ONE, /* Source mask. */ | |
1208 | MINUS_ONE, /* Dest mask. */ | |
1209 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1210 | |
1211 | /* Push a value on the reloc evaluation stack. */ | |
7920ce38 NC |
1212 | HOWTO (ALPHA_R_OP_PUSH, /* Type. */ |
1213 | 0, /* Rightshift. */ | |
1214 | 0, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1215 | 0, /* Bitsize. */ | |
1216 | FALSE, /* PC relative. */ | |
1217 | 0, /* Bitpos. */ | |
1218 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1219 | reloc_nil, /* Special_function. */ | |
1220 | "OP_PUSH", /* Name. */ | |
1221 | FALSE, /* Partial_inplace. */ | |
1222 | 0, /* Source mask. */ | |
1223 | 0, /* Dest mask. */ | |
1224 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1225 | |
1226 | /* Store the value from the stack at the given address. Store it in | |
1227 | a bitfield of size r_size starting at bit position r_offset. */ | |
7920ce38 NC |
1228 | HOWTO (ALPHA_R_OP_STORE, /* Type. */ |
1229 | 0, /* Rightshift. */ | |
1230 | 4, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1231 | 64, /* Bitsize. */ | |
1232 | FALSE, /* PC relative. */ | |
1233 | 0, /* Bitpos. */ | |
1234 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1235 | reloc_nil, /* Special_function. */ | |
1236 | "OP_STORE", /* Name. */ | |
1237 | FALSE, /* Partial_inplace. */ | |
1238 | 0, /* Source mask. */ | |
1239 | MINUS_ONE, /* Dest mask. */ | |
1240 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1241 | |
1242 | /* Subtract the reloc address from the value on the top of the | |
1243 | relocation stack. */ | |
7920ce38 NC |
1244 | HOWTO (ALPHA_R_OP_PSUB, /* Type. */ |
1245 | 0, /* Rightshift. */ | |
1246 | 0, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1247 | 0, /* Bitsize. */ | |
1248 | FALSE, /* PC relative. */ | |
1249 | 0, /* Bitpos. */ | |
1250 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1251 | reloc_nil, /* Special_function. */ | |
1252 | "OP_PSUB", /* Name. */ | |
1253 | FALSE, /* Partial_inplace. */ | |
1254 | 0, /* Source mask. */ | |
1255 | 0, /* Dest mask. */ | |
1256 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1257 | |
1258 | /* Shift the value on the top of the relocation stack right by the | |
1259 | given value. */ | |
7920ce38 NC |
1260 | HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */ |
1261 | 0, /* Rightshift. */ | |
1262 | 0, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1263 | 0, /* Bitsize. */ | |
1264 | FALSE, /* PC relative. */ | |
1265 | 0, /* Bitpos. */ | |
1266 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1267 | reloc_nil, /* Special_function. */ | |
1268 | "OP_PRSHIFT", /* Name. */ | |
1269 | FALSE, /* Partial_inplace. */ | |
1270 | 0, /* Source mask. */ | |
1271 | 0, /* Dest mask. */ | |
1272 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1273 | |
1274 | /* Hack. Linkage is done by linker. */ | |
7920ce38 NC |
1275 | HOWTO (ALPHA_R_LINKAGE, /* Type. */ |
1276 | 0, /* Rightshift. */ | |
1277 | 8, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1278 | 256, /* Bitsize. */ | |
1279 | FALSE, /* PC relative. */ | |
1280 | 0, /* Bitpos. */ | |
1281 | complain_overflow_dont,/* Complain_on_overflow. */ | |
1282 | reloc_nil, /* Special_function. */ | |
1283 | "LINKAGE", /* Name. */ | |
1284 | FALSE, /* Partial_inplace. */ | |
1285 | 0, /* Source mask. */ | |
1286 | 0, /* Dest mask. */ | |
1287 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1288 | |
1289 | /* A 32 bit reference to a symbol. */ | |
7920ce38 NC |
1290 | HOWTO (ALPHA_R_REFLONG, /* Type. */ |
1291 | 0, /* Rightshift. */ | |
1292 | 2, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1293 | 32, /* Bitsize. */ | |
1294 | FALSE, /* PC relative. */ | |
1295 | 0, /* Bitpos. */ | |
1296 | complain_overflow_bitfield, /* Complain_on_overflow. */ | |
1297 | reloc_nil, /* Special_function. */ | |
1298 | "REFLONG", /* Name. */ | |
1299 | TRUE, /* Partial_inplace. */ | |
1300 | 0xffffffff, /* Source mask. */ | |
1301 | 0xffffffff, /* Dest mask. */ | |
1302 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1303 | |
1304 | /* A 64 bit reference to a procedure, written as 32 bit value. */ | |
7920ce38 NC |
1305 | HOWTO (ALPHA_R_CODEADDR, /* Type. */ |
1306 | 0, /* Rightshift. */ | |
1307 | 4, /* Size (0 = byte, 1 = short, 2 = long). */ | |
1308 | 64, /* Bitsize. */ | |
1309 | FALSE, /* PC relative. */ | |
1310 | 0, /* Bitpos. */ | |
1311 | complain_overflow_signed,/* Complain_on_overflow. */ | |
1312 | reloc_nil, /* Special_function. */ | |
1313 | "CODEADDR", /* Name. */ | |
1314 | FALSE, /* Partial_inplace. */ | |
1315 | 0xffffffff, /* Source mask. */ | |
1316 | 0xffffffff, /* Dest mask. */ | |
1317 | FALSE), /* PC rel offset. */ | |
252b5132 RH |
1318 | |
1319 | }; | |
1320 | ||
1321 | /* Return a pointer to a howto structure which, when invoked, will perform | |
1322 | the relocation code on data from the architecture noted. */ | |
1323 | ||
1324 | static const struct reloc_howto_struct * | |
7920ce38 NC |
1325 | vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, |
1326 | bfd_reloc_code_real_type code) | |
252b5132 RH |
1327 | { |
1328 | int alpha_type; | |
1329 | ||
1330 | #if VMS_DEBUG | |
7920ce38 | 1331 | vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code); |
252b5132 RH |
1332 | #endif |
1333 | ||
1334 | switch (code) | |
1335 | { | |
1336 | case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break; | |
1337 | case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break; | |
1338 | case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break; | |
1339 | case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break; | |
1340 | case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break; | |
1341 | case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break; | |
1342 | case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break; | |
1343 | case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break; | |
1344 | case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break; | |
1345 | case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break; | |
1346 | case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break; | |
1347 | default: | |
1348 | (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code); | |
7920ce38 | 1349 | return NULL; |
252b5132 RH |
1350 | } |
1351 | #if VMS_DEBUG | |
1352 | vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name); | |
1353 | #endif | |
7920ce38 | 1354 | return & alpha_howto_table[alpha_type]; |
252b5132 RH |
1355 | } |
1356 | ||
157090f7 AM |
1357 | static reloc_howto_type * |
1358 | vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, | |
1359 | const char *r_name) | |
1360 | { | |
1361 | unsigned int i; | |
1362 | ||
1363 | for (i = 0; | |
1364 | i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]); | |
1365 | i++) | |
1366 | if (alpha_howto_table[i].name != NULL | |
1367 | && strcasecmp (alpha_howto_table[i].name, r_name) == 0) | |
1368 | return &alpha_howto_table[i]; | |
1369 | ||
1370 | return NULL; | |
1371 | } | |
1372 | ||
7920ce38 | 1373 | /* Part 4.7, writing an object file. */ |
252b5132 RH |
1374 | |
1375 | /* Set the architecture and machine type in BFD abfd to arch and mach. | |
1376 | Find the correct pointer to a structure and insert it into the arch_info | |
1377 | pointer. */ | |
1378 | ||
b34976b6 | 1379 | static bfd_boolean |
7920ce38 NC |
1380 | vms_set_arch_mach (bfd * abfd, |
1381 | enum bfd_architecture arch ATTRIBUTE_UNUSED, | |
1382 | unsigned long mach ATTRIBUTE_UNUSED) | |
252b5132 RH |
1383 | { |
1384 | #if VMS_DEBUG | |
7920ce38 | 1385 | vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach); |
252b5132 | 1386 | #endif |
7920ce38 | 1387 | abfd->arch_info = bfd_scan_arch ("alpha"); |
252b5132 | 1388 | |
b34976b6 | 1389 | return TRUE; |
252b5132 RH |
1390 | } |
1391 | ||
252b5132 RH |
1392 | /* Sets the contents of the section section in BFD abfd to the data starting |
1393 | in memory at data. The data is written to the output section starting at | |
1394 | offset offset for count bytes. | |
1395 | ||
b34976b6 | 1396 | Normally TRUE is returned, else FALSE. Possible error returns are: |
252b5132 RH |
1397 | o bfd_error_no_contents - The output section does not have the |
1398 | SEC_HAS_CONTENTS attribute, so nothing can be written to it. | |
1399 | o and some more too */ | |
1400 | ||
b34976b6 | 1401 | static bfd_boolean |
7920ce38 NC |
1402 | vms_set_section_contents (bfd * abfd, |
1403 | asection *section, | |
1404 | const void * location, | |
1405 | file_ptr offset, | |
1406 | bfd_size_type count) | |
252b5132 RH |
1407 | { |
1408 | #if VMS_DEBUG | |
7920ce38 NC |
1409 | vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n", |
1410 | abfd, section->name, location, (long int)offset, (int)count); | |
eea6121a | 1411 | vms_debug (2, "size %d\n", (int) section->size); |
252b5132 | 1412 | #endif |
7920ce38 | 1413 | return _bfd_save_vms_section (abfd, section, location, offset, count); |
252b5132 RH |
1414 | } |
1415 | ||
7920ce38 | 1416 | /* Part 4.8, linker. */ |
252b5132 RH |
1417 | |
1418 | /* Get the size of the section headers. */ | |
1419 | ||
1420 | static int | |
7920ce38 | 1421 | vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED, |
a6b96beb | 1422 | struct bfd_link_info *info ATTRIBUTE_UNUSED) |
252b5132 RH |
1423 | { |
1424 | #if VMS_DEBUG | |
7920ce38 | 1425 | vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False"); |
252b5132 RH |
1426 | #endif |
1427 | return 0; | |
1428 | } | |
1429 | ||
252b5132 RH |
1430 | /* Provides default handling of relocation effort for back ends |
1431 | which can't be bothered to do it efficiently. */ | |
1432 | ||
1433 | static bfd_byte * | |
7920ce38 NC |
1434 | vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED, |
1435 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED, | |
1436 | struct bfd_link_order *link_order ATTRIBUTE_UNUSED, | |
1437 | bfd_byte *data ATTRIBUTE_UNUSED, | |
1438 | bfd_boolean relocatable ATTRIBUTE_UNUSED, | |
1439 | asymbol **symbols ATTRIBUTE_UNUSED) | |
252b5132 RH |
1440 | { |
1441 | #if VMS_DEBUG | |
7920ce38 NC |
1442 | vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n", |
1443 | abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols); | |
252b5132 | 1444 | #endif |
7920ce38 | 1445 | return NULL; |
252b5132 RH |
1446 | } |
1447 | ||
252b5132 RH |
1448 | /* ??? */ |
1449 | ||
b34976b6 | 1450 | static bfd_boolean |
7920ce38 NC |
1451 | vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED, |
1452 | asection *section ATTRIBUTE_UNUSED, | |
1453 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED, | |
1454 | bfd_boolean *again ATTRIBUTE_UNUSED) | |
252b5132 RH |
1455 | { |
1456 | #if VMS_DEBUG | |
7920ce38 NC |
1457 | vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n", |
1458 | abfd, section->name, link_info); | |
252b5132 | 1459 | #endif |
b34976b6 | 1460 | return TRUE; |
252b5132 RH |
1461 | } |
1462 | ||
b34976b6 | 1463 | static bfd_boolean |
7920ce38 NC |
1464 | vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED, |
1465 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED) | |
252b5132 RH |
1466 | { |
1467 | #if VMS_DEBUG | |
7920ce38 | 1468 | vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info); |
252b5132 | 1469 | #endif |
b34976b6 | 1470 | return TRUE; |
252b5132 RH |
1471 | } |
1472 | ||
b34976b6 | 1473 | static bfd_boolean |
7920ce38 NC |
1474 | vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED, |
1475 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED) | |
8550eb6e JJ |
1476 | { |
1477 | #if VMS_DEBUG | |
7920ce38 | 1478 | vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info); |
8550eb6e | 1479 | #endif |
b34976b6 | 1480 | return TRUE; |
8550eb6e JJ |
1481 | } |
1482 | ||
252b5132 RH |
1483 | /* Create a hash table for the linker. Different backends store |
1484 | different information in this table. */ | |
1485 | ||
1486 | static struct bfd_link_hash_table * | |
7920ce38 | 1487 | vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
1488 | { |
1489 | #if VMS_DEBUG | |
7920ce38 | 1490 | vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd); |
252b5132 | 1491 | #endif |
7920ce38 | 1492 | return NULL; |
252b5132 RH |
1493 | } |
1494 | ||
e2d34d7d DJ |
1495 | /* Free a linker hash table. */ |
1496 | ||
1497 | static void | |
7920ce38 | 1498 | vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED) |
e2d34d7d DJ |
1499 | { |
1500 | #if VMS_DEBUG | |
7920ce38 | 1501 | vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd); |
e2d34d7d DJ |
1502 | #endif |
1503 | } | |
1504 | ||
252b5132 RH |
1505 | /* Add symbols from this object file into the hash table. */ |
1506 | ||
b34976b6 | 1507 | static bfd_boolean |
7920ce38 NC |
1508 | vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED, |
1509 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED) | |
252b5132 RH |
1510 | { |
1511 | #if VMS_DEBUG | |
7920ce38 | 1512 | vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info); |
252b5132 | 1513 | #endif |
b34976b6 | 1514 | return FALSE; |
252b5132 RH |
1515 | } |
1516 | ||
252b5132 RH |
1517 | /* Do a link based on the link_order structures attached to each |
1518 | section of the BFD. */ | |
1519 | ||
b34976b6 | 1520 | static bfd_boolean |
7920ce38 NC |
1521 | vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED, |
1522 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED) | |
252b5132 RH |
1523 | { |
1524 | #if VMS_DEBUG | |
7920ce38 | 1525 | vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info); |
252b5132 | 1526 | #endif |
b34976b6 | 1527 | return TRUE; |
252b5132 RH |
1528 | } |
1529 | ||
1530 | /* Should this section be split up into smaller pieces during linking. */ | |
1531 | ||
b34976b6 | 1532 | static bfd_boolean |
7920ce38 NC |
1533 | vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED, |
1534 | asection *section ATTRIBUTE_UNUSED) | |
252b5132 RH |
1535 | { |
1536 | #if VMS_DEBUG | |
7920ce38 | 1537 | vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name); |
252b5132 | 1538 | #endif |
b34976b6 | 1539 | return FALSE; |
252b5132 RH |
1540 | } |
1541 | ||
7920ce38 | 1542 | /* Part 4.9, dynamic symbols and relocations. */ |
252b5132 RH |
1543 | |
1544 | /* Get the amount of memory required to hold the dynamic symbols. */ | |
1545 | ||
1546 | static long | |
7920ce38 | 1547 | vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
1548 | { |
1549 | #if VMS_DEBUG | |
7920ce38 | 1550 | vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd); |
252b5132 RH |
1551 | #endif |
1552 | return 0; | |
1553 | } | |
1554 | ||
b34976b6 | 1555 | static bfd_boolean |
7920ce38 NC |
1556 | vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED, |
1557 | void *file ATTRIBUTE_UNUSED) | |
252b5132 RH |
1558 | { |
1559 | #if VMS_DEBUG | |
7920ce38 | 1560 | vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd); |
252b5132 | 1561 | #endif |
7920ce38 | 1562 | return FALSE; |
252b5132 RH |
1563 | } |
1564 | ||
252b5132 RH |
1565 | /* Read in the dynamic symbols. */ |
1566 | ||
1567 | static long | |
7920ce38 NC |
1568 | vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED, |
1569 | asymbol **symbols ATTRIBUTE_UNUSED) | |
252b5132 RH |
1570 | { |
1571 | #if VMS_DEBUG | |
7920ce38 | 1572 | vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd); |
252b5132 RH |
1573 | #endif |
1574 | return 0L; | |
1575 | } | |
1576 | ||
252b5132 RH |
1577 | /* Get the amount of memory required to hold the dynamic relocs. */ |
1578 | ||
1579 | static long | |
7920ce38 | 1580 | vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED) |
252b5132 RH |
1581 | { |
1582 | #if VMS_DEBUG | |
7920ce38 | 1583 | vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd); |
252b5132 RH |
1584 | #endif |
1585 | return 0L; | |
1586 | } | |
1587 | ||
252b5132 RH |
1588 | /* Read in the dynamic relocs. */ |
1589 | ||
1590 | static long | |
7920ce38 NC |
1591 | vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED, |
1592 | arelent **arel ATTRIBUTE_UNUSED, | |
1593 | asymbol **symbols ATTRIBUTE_UNUSED) | |
252b5132 RH |
1594 | { |
1595 | #if VMS_DEBUG | |
7920ce38 | 1596 | vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd); |
252b5132 RH |
1597 | #endif |
1598 | return 0L; | |
1599 | } | |
7920ce38 NC |
1600 | \f |
1601 | const bfd_target vms_alpha_vec = | |
1602 | { | |
1603 | "vms-alpha", /* Name. */ | |
1604 | bfd_target_evax_flavour, | |
1605 | BFD_ENDIAN_LITTLE, /* Data byte order is little. */ | |
1606 | BFD_ENDIAN_LITTLE, /* Header byte order is little. */ | |
1607 | ||
1608 | (HAS_RELOC | HAS_SYMS | |
1609 | | WP_TEXT | D_PAGED), /* Object flags. */ | |
1610 | (SEC_ALLOC | SEC_LOAD | SEC_RELOC | |
1611 | | SEC_READONLY | SEC_CODE | SEC_DATA | |
1612 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */ | |
1613 | 0, /* Symbol_leading_char. */ | |
1614 | ' ', /* AR_pad_char. */ | |
1615 | 15, /* AR_max_namelen. */ | |
1616 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
1617 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
1618 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, | |
1619 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
1620 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
1621 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, | |
1622 | ||
1623 | {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */ | |
1624 | vms_archive_p, _bfd_dummy_target}, | |
1625 | {bfd_false, vms_mkobject, /* bfd_set_format. */ | |
1626 | _bfd_generic_mkarchive, bfd_false}, | |
1627 | {bfd_false, vms_write_object_contents, /* bfd_write_contents. */ | |
1628 | _bfd_write_archive_contents, bfd_false}, | |
1629 | ||
1630 | BFD_JUMP_TABLE_GENERIC (vms), | |
1631 | BFD_JUMP_TABLE_COPY (vms), | |
1632 | BFD_JUMP_TABLE_CORE (vms), | |
1633 | BFD_JUMP_TABLE_ARCHIVE (vms), | |
1634 | BFD_JUMP_TABLE_SYMBOLS (vms), | |
1635 | BFD_JUMP_TABLE_RELOCS (vms), | |
1636 | BFD_JUMP_TABLE_WRITE (vms), | |
1637 | BFD_JUMP_TABLE_LINK (vms), | |
1638 | BFD_JUMP_TABLE_DYNAMIC (vms), | |
1639 | ||
1640 | NULL, | |
1641 | ||
1642 | NULL | |
1643 | }; | |
1644 | ||
1645 | const bfd_target vms_vax_vec = | |
1646 | { | |
1647 | "vms-vax", /* Name. */ | |
1648 | bfd_target_ovax_flavour, | |
1649 | BFD_ENDIAN_LITTLE, /* Data byte order is little. */ | |
1650 | BFD_ENDIAN_LITTLE, /* Header byte order is little. */ | |
1651 | ||
1652 | (HAS_RELOC | HAS_SYMS /* Object flags. */ | |
1653 | | WP_TEXT | D_PAGED | |
1654 | | HAS_LINENO | HAS_DEBUG | HAS_LOCALS), | |
1655 | ||
1656 | (SEC_ALLOC | SEC_LOAD | SEC_RELOC | |
1657 | | SEC_READONLY | SEC_CODE | SEC_DATA | |
1658 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */ | |
1659 | 0, /* Symbol_leading_char. */ | |
1660 | ' ', /* AR_pad_char. */ | |
1661 | 15, /* AR_max_namelen. */ | |
1662 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
1663 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
1664 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */ | |
1665 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
1666 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
1667 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */ | |
1668 | ||
1669 | {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */ | |
1670 | vms_archive_p, _bfd_dummy_target}, | |
1671 | {bfd_false, vms_mkobject, /* bfd_set_format. */ | |
1672 | _bfd_generic_mkarchive, bfd_false}, | |
1673 | {bfd_false, vms_write_object_contents, /* bfd_write_contents. */ | |
1674 | _bfd_write_archive_contents, bfd_false}, | |
1675 | ||
1676 | BFD_JUMP_TABLE_GENERIC (vms), | |
1677 | BFD_JUMP_TABLE_COPY (vms), | |
1678 | BFD_JUMP_TABLE_CORE (vms), | |
1679 | BFD_JUMP_TABLE_ARCHIVE (vms), | |
1680 | BFD_JUMP_TABLE_SYMBOLS (vms), | |
1681 | BFD_JUMP_TABLE_RELOCS (vms), | |
1682 | BFD_JUMP_TABLE_WRITE (vms), | |
1683 | BFD_JUMP_TABLE_LINK (vms), | |
1684 | BFD_JUMP_TABLE_DYNAMIC (vms), | |
1685 | ||
1686 | NULL, | |
1687 | ||
1688 | NULL | |
1689 | }; |