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