Enable dosrel for special dos installation (appending of .exe to
[deliverable/binutils-gdb.git] / bfd / evax-alpha.c
1 /* evax-alpha.c -- BFD back-end for ALPHA EVAX (openVMS/AXP) files.
2 Copyright 1996 Free Software Foundation, Inc.
3 Written by Klaus Kämpf (kkaempf@progis.de)
4 of proGIS Softwareentwicklung, Aachen, Germany
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20
21 #include <stdio.h>
22
23 #include "bfd.h"
24 #include "sysdep.h"
25 #include "bfdlink.h"
26 #include "libbfd.h"
27
28 #include "evax.h"
29
30 static boolean evax_initialize PARAMS ((bfd *));
31 static boolean fill_section_ptr PARAMS ((struct bfd_hash_entry *, PTR));
32 static boolean evax_fixup_sections PARAMS ((bfd *));
33 static boolean copy_symbols PARAMS ((struct bfd_hash_entry *, PTR));
34 static bfd_reloc_status_type reloc_nil
35 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
36 static const struct bfd_target *evax_object_p PARAMS ((bfd *abfd));
37 static const struct bfd_target *evax_archive_p PARAMS ((bfd *abfd));
38 static boolean evax_mkobject PARAMS ((bfd *abfd));
39 static boolean evax_write_object_contents PARAMS ((bfd *abfd));
40 static boolean evax_close_and_cleanup PARAMS ((bfd *abfd));
41 static boolean evax_bfd_free_cached_info PARAMS ((bfd *abfd));
42 static boolean evax_new_section_hook PARAMS ((bfd *abfd, asection *section));
43 static boolean evax_get_section_contents
44 PARAMS ((bfd *abfd, asection *section, PTR x1, file_ptr x2,
45 bfd_size_type x3));
46 static boolean evax_get_section_contents_in_window
47 PARAMS ((bfd *abfd, asection *section, bfd_window *w, file_ptr offset,
48 bfd_size_type count));
49 static boolean evax_bfd_copy_private_bfd_data PARAMS ((bfd *src, bfd *dest));
50 static boolean evax_bfd_copy_private_section_data
51 PARAMS ((bfd *srcbfd, asection *srcsec, bfd *dstbfd, asection *dstsec));
52 static boolean evax_bfd_copy_private_symbol_data
53 PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
54 static boolean evax_bfd_print_private_bfd_data
55 PARAMS ((bfd *abfd, void *file));
56 static char *evax_core_file_failing_command PARAMS ((bfd *abfd));
57 static int evax_core_file_failing_signal PARAMS ((bfd *abfd));
58 static boolean evax_core_file_matches_executable_p
59 PARAMS ((bfd *abfd, bfd *bbfd));
60 static boolean evax_slurp_armap PARAMS ((bfd *abfd));
61 static boolean evax_slurp_extended_name_table PARAMS ((bfd *abfd));
62 static boolean evax_construct_extended_name_table
63 PARAMS ((bfd *abfd, char **tabloc, bfd_size_type *tablen,
64 const char **name));
65 static void evax_truncate_arname
66 PARAMS ((bfd *abfd, CONST char *pathname, char *arhdr));
67 static boolean evax_write_armap
68 PARAMS ((bfd *arch, unsigned int elength, struct orl *map,
69 unsigned int orl_count, int stridx));
70 static PTR evax_read_ar_hdr PARAMS ((bfd *abfd));
71 static bfd *evax_get_elt_at_index PARAMS ((bfd *abfd, symindex index));
72 static bfd *evax_openr_next_archived_file PARAMS ((bfd *arch, bfd *prev));
73 static boolean evax_update_armap_timestamp PARAMS ((bfd *abfd));
74 static int evax_generic_stat_arch_elt PARAMS ((bfd *abfd, struct stat *stat));
75 static long evax_get_symtab_upper_bound PARAMS ((bfd *abfd));
76 static long evax_get_symtab PARAMS ((bfd *abfd, asymbol **symbols));
77 static void evax_print_symbol
78 PARAMS ((bfd *abfd, PTR file, asymbol *symbol, bfd_print_symbol_type how));
79 static void evax_get_symbol_info
80 PARAMS ((bfd *abfd, asymbol *symbol, symbol_info *ret));
81 static boolean evax_bfd_is_local_label PARAMS ((bfd *abfd, asymbol *symbol));
82 static alent *evax_get_lineno PARAMS ((bfd *abfd, asymbol *symbol));
83 static boolean evax_find_nearest_line
84 PARAMS ((bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset,
85 const char **file, const char **func, unsigned int *line));
86 static asymbol *evax_bfd_make_debug_symbol
87 PARAMS ((bfd *abfd, void *ptr, unsigned long size));
88 static long evax_read_minisymbols
89 PARAMS ((bfd *abfd, boolean dynamic, PTR *minisymsp, unsigned int *sizep));
90 static asymbol *evax_minisymbol_to_symbol
91 PARAMS ((bfd *abfd, boolean dynamic, const PTR minisym, asymbol *sym));
92 static long evax_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
93 static long evax_canonicalize_reloc
94 PARAMS ((bfd *abfd, asection *srcsec, arelent **location,
95 asymbol **symbols));
96 static const struct reloc_howto_struct *evax_bfd_reloc_type_lookup
97 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
98 static boolean evax_set_arch_mach
99 PARAMS ((bfd *abfd, enum bfd_architecture arch, unsigned long mach));
100 static boolean evax_set_section_contents
101 PARAMS ((bfd *abfd, asection *section, PTR location, file_ptr offset,
102 bfd_size_type count));
103 static int evax_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
104 static bfd_byte *evax_bfd_get_relocated_section_contents
105 PARAMS ((bfd *abfd, struct bfd_link_info *link_info,
106 struct bfd_link_order *link_order, bfd_byte *data,
107 boolean relocateable, asymbol **symbols));
108 static boolean evax_bfd_relax_section
109 PARAMS ((bfd *abfd, asection *section, struct bfd_link_info *link_info,
110 boolean *again));
111 static struct bfd_link_hash_table *evax_bfd_link_hash_table_create
112 PARAMS ((bfd *abfd));
113 static boolean evax_bfd_link_add_symbols
114 PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
115 static boolean evax_bfd_final_link
116 PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
117 static boolean evax_bfd_link_split_section
118 PARAMS ((bfd *abfd, asection *section));
119 static long evax_get_dynamic_symtab_upper_bound PARAMS ((bfd *abfd));
120 static long evax_canonicalize_dynamic_symtab
121 PARAMS ((bfd *abfd, asymbol **symbols));
122 static long evax_get_dynamic_reloc_upper_bound PARAMS ((bfd *abfd));
123 static long evax_canonicalize_dynamic_reloc
124 PARAMS ((bfd *abfd, arelent **arel, asymbol **symbols));
125 static boolean evax_bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
126 static boolean evax_bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
127
128 #define evax_make_empty_symbol _bfd_evax_make_empty_symbol
129 \f
130 /*===========================================================================*/
131
132 const bfd_target evax_alpha_vec =
133 {
134
135 "evax-alpha", /* name */
136 bfd_target_evax_flavour,
137 false, /* data byte order is little */
138 false, /* header byte order is little */
139
140 (HAS_RELOC | /* object flags */
141 HAS_LINENO | HAS_DEBUG |
142 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
143
144 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */
145 0, /* symbol_leading_char */
146 ' ', /* ar_pad_char */
147 15, /* ar_max_namelen */
148 bfd_getl64, /* bfd_getx64 */
149 bfd_getl_signed_64, /* bfd_getx_signed_64 */
150 bfd_putl64, /* bfd_putx64 */
151 bfd_getl32, /* bfd_getx32 */
152 bfd_getl_signed_32, /* bfd_getx_signed_32 */
153 bfd_putl32, /* bfd_putx32 */
154 bfd_getl16, /* bfd_getx16 */
155 bfd_getl_signed_16, /* bfd_getx_signed_16 */
156 bfd_putl16, /* bfd_putx16 */
157 bfd_getl64, /* bfd_h_getx64 */
158 bfd_getl_signed_64, /* bfd_h_getx_signed_64 */
159 bfd_putl64, /* bfd_h_putx64 */
160 bfd_getl32, /* bfd_h_getx32 */
161 bfd_getl_signed_32, /* bfd_h_getx_signed_32 */
162 bfd_putl32, /* bfd_h_putx32 */
163 bfd_getl16, /* bfd_h_getx16 */
164 bfd_getl_signed_16, /* bfd_h_getx_signed_16 */
165 bfd_putl16, /* bfd_h_putx16 */
166
167 {_bfd_dummy_target, evax_object_p, /* bfd_check_format */
168 evax_archive_p, _bfd_dummy_target},
169 {bfd_false, evax_mkobject, /* bfd_set_format */
170 _bfd_generic_mkarchive, bfd_false},
171 {bfd_false, evax_write_object_contents, /* bfd_write_contents */
172 _bfd_write_archive_contents, bfd_false},
173
174 BFD_JUMP_TABLE_GENERIC (evax),
175 BFD_JUMP_TABLE_COPY (evax),
176 BFD_JUMP_TABLE_CORE (evax),
177 BFD_JUMP_TABLE_ARCHIVE (evax),
178 BFD_JUMP_TABLE_SYMBOLS (evax),
179 BFD_JUMP_TABLE_RELOCS (evax),
180 BFD_JUMP_TABLE_WRITE (evax),
181 BFD_JUMP_TABLE_LINK (evax),
182 BFD_JUMP_TABLE_DYNAMIC (evax),
183
184 (PTR) 0
185 };
186
187 \f
188 /*===========================================================================*/
189
190 /* Initialize private data */
191
192 static boolean
193 evax_initialize (abfd)
194 bfd *abfd;
195 {
196 int i;
197
198 if (abfd->tdata.any != 0)
199 return true;
200
201 bfd_set_start_address (abfd, (bfd_vma)-1);
202
203 abfd->tdata.any = ((struct evax_private_data_struct*)
204 bfd_malloc (sizeof (struct evax_private_data_struct)));
205 if (abfd->tdata.any == 0)
206 return false;
207 PRIV(evax_buf) = 0;
208 PRIV(buf_size) = 0;
209 PRIV(rec_length) = 0;
210 PRIV(file_format) = FF_UNKNOWN;
211 PRIV(filename) = NULL;
212 PRIV(fixup_done) = false;
213 PRIV(sections) = NULL;
214
215 PRIV(stack) = ((struct stack_struct *)
216 bfd_malloc (sizeof (struct stack_struct) * STACKSIZE));
217 if (PRIV(stack) == 0)
218 {
219 evax_init_no_mem1:
220 free (abfd->tdata.any);
221 abfd->tdata.any = 0;
222 return false;
223 }
224 PRIV(stackptr) = 0;
225
226 PRIV(evax_symbol_table) = ((struct bfd_hash_table *)
227 bfd_malloc (sizeof (struct bfd_hash_table)));
228 if (PRIV(evax_symbol_table) == 0)
229 {
230 evax_init_no_mem2:
231 free (PRIV(stack));
232 PRIV(stack) = 0;
233 goto evax_init_no_mem1;
234 }
235
236 if (!bfd_hash_table_init (PRIV(evax_symbol_table), _bfd_evax_hash_newfunc))
237 return false;
238
239 PRIV(location_stack) = ((struct location_struct *)
240 bfd_malloc (sizeof (struct location_struct)
241 * LOCATION_SAVE_SIZE));
242 if (PRIV(location_stack) == 0)
243 {
244 evax_init_no_mem3:
245 free (PRIV(evax_symbol_table));
246 PRIV(evax_symbol_table) = 0;
247 goto evax_init_no_mem2;
248 }
249
250 for (i=0; i<EVAX_SECTION_COUNT; i++)
251 {
252 PRIV(evax_section_table)[i] = NULL;
253 PRIV(evax_reloc_table)[i] = NULL;
254 }
255
256 PRIV(output_buf) = (unsigned char *) malloc (MAX_OUTREC_SIZE);
257 if (PRIV(output_buf) == 0)
258 {
259 free (PRIV(location_stack));
260 PRIV(location_stack) = 0;
261 goto evax_init_no_mem3;
262 }
263 PRIV(push_level) = 0;
264 PRIV(pushed_size) = 0;
265 PRIV(length_pos) = 2;
266 PRIV(output_size) = 0;
267 PRIV(output_alignment) = 1;
268
269 return true;
270 }
271
272
273 /* Fill symbol->section with section ptr
274 symbol->section is filled with the section index for defined symbols
275 during reading the EGSD section. But we need the pointer to the
276 bfd section later.
277
278 It has the correct value for referenced (undefined section) symbols
279
280 called from bfd_hash_traverse in evax_fixup_sections */
281
282 static boolean
283 fill_section_ptr (entry, sections)
284 struct bfd_hash_entry *entry;
285 PTR sections;
286 {
287 asection *sec;
288 asymbol *sym;
289
290 sym = ((evax_symbol_entry *)entry)->symbol;
291 sec = sym->section;
292
293 if (!bfd_is_und_section (sec))
294 {
295 sec = ((evax_symbol_entry *)entry)->symbol->section =
296 ((asection **)sections)[(int)sec];
297 }
298
299 if (strcmp (sym->name, sec->name) == 0)
300 sym->flags |= BSF_SECTION_SYM;
301
302 return true;
303 }
304
305
306 /* Fixup sections
307 set up all pointers and arrays, counters and sizes are fixed now
308
309 we build a private sections vector for easy access since sections
310 are always referenced by an index number.
311
312 alloc PRIV(sections) according to abfd->section_count
313 copy abfd->sections to PRIV(sections) */
314
315 static boolean
316 evax_fixup_sections (abfd)
317 bfd *abfd;
318 {
319 asection *s;
320
321 if (PRIV(fixup_done))
322 return true;
323
324 PRIV(sections) = ((asection **)
325 bfd_malloc (abfd->section_count * sizeof (asection *)));
326 if (PRIV(sections) == 0)
327 return false;
328 PRIV(egsd_sec_count) = abfd->section_count;
329 s = abfd->sections;
330 while (s)
331 {
332 PRIV(sections)[s->index] = s;
333 s = s->next;
334 }
335
336 /*
337 * traverse symbol table and fill in all section pointers
338 */
339
340 bfd_hash_traverse (PRIV(evax_symbol_table), fill_section_ptr,
341 (PTR)(PRIV(sections)));
342
343 PRIV(fixup_done) = true;
344
345 return true;
346 }
347
348 /*===========================================================================*/
349
350 /* Check the format for a file being read.
351 Return a (bfd_target *) if it's an object file or zero if not. */
352
353 static const struct bfd_target *
354 evax_object_p (abfd)
355 bfd *abfd;
356 {
357 int err = 0;
358 int prev_type;
359 #if EVAX_DEBUG
360 evax_debug (1, "evax_object_p(%p)\n", abfd);
361 #endif
362 if (bfd_seek (abfd, 0L, SEEK_SET))
363 {
364 bfd_set_error (bfd_error_file_truncated);
365 return 0;
366 }
367
368 prev_type = -1;
369
370 do
371 {
372 #if EVAX_DEBUG
373 evax_debug (3, "reading at %08lx\n", bfd_tell(abfd));
374 #endif
375 if (_bfd_evax_next_record (abfd) < 0)
376 {
377 #if EVAX_DEBUG
378 evax_debug (2, "next_record failed\n");
379 #endif
380 bfd_set_error (bfd_error_wrong_format);
381 return 0;
382 }
383
384 if ((prev_type == EOBJ_S_C_EGSD) && (PRIV(rec_type) != EOBJ_S_C_EGSD))
385 {
386 if (evax_fixup_sections (abfd) == false)
387 {
388 #if EVAX_DEBUG
389 evax_debug (2, "evax_fixup_sections failed\n");
390 #endif
391 bfd_set_error (bfd_error_wrong_format);
392 return 0;
393 }
394 }
395
396 prev_type = PRIV(rec_type);
397
398 switch (PRIV(rec_type))
399 {
400 case EOBJ_S_C_EMH:
401 err = _bfd_evax_slurp_emh (abfd);
402 break;
403 case EOBJ_S_C_EEOM:
404 err = _bfd_evax_slurp_eeom (abfd);
405 break;
406 case EOBJ_S_C_EGSD:
407 err = _bfd_evax_slurp_egsd (abfd);
408 break;
409 case EOBJ_S_C_ETIR:
410 err = _bfd_evax_slurp_etir (abfd);
411 break;
412 case EOBJ_S_C_EDBG:
413 err = _bfd_evax_slurp_edbg (abfd);
414 break;
415 case EOBJ_S_C_ETBT:
416 err = _bfd_evax_slurp_etbt (abfd);
417 break;
418 default:
419 err = -1;
420 }
421 if (err != 0)
422 {
423 #if EVAX_DEBUG
424 evax_debug (2, "slurp type %d failed with %d\n", PRIV(rec_type), err);
425 #endif
426 bfd_set_error (bfd_error_wrong_format);
427 return 0;
428 }
429 }
430 while (prev_type != EOBJ_S_C_EEOM);
431
432 /* set arch_info to alpha */
433
434 {
435 const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
436 if (arch == 0)
437 {
438 #if EVAX_DEBUG
439 evax_debug (2, "arch not found\n");
440 #endif
441 bfd_set_error (bfd_error_wrong_format);
442 return 0;
443 }
444 abfd->arch_info = arch;
445 }
446
447 return &evax_alpha_vec;
448 }
449
450
451 /* Check the format for a file being read.
452 Return a (bfd_target *) if it's an archive file or zero. */
453
454 static const struct bfd_target *
455 evax_archive_p (abfd)
456 bfd *abfd;
457 {
458 #if EVAX_DEBUG
459 evax_debug (1, "evax_archive_p(%p)\n", abfd);
460 #endif
461
462 if (!evax_initialize (abfd))
463 return 0;
464
465 return 0;
466 }
467
468
469 /* Set the format of a file being written. */
470
471 static boolean
472 evax_mkobject (abfd)
473 bfd *abfd;
474 {
475 #if EVAX_DEBUG
476 evax_debug (1, "evax_mkobject(%p)\n", abfd);
477 #endif
478
479 if (!evax_initialize (abfd))
480 return 0;
481
482 {
483 const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
484 if (arch == 0)
485 {
486 bfd_set_error(bfd_error_wrong_format);
487 return 0;
488 }
489 abfd->arch_info = arch;
490 }
491
492 return true;
493 }
494
495
496 /* Write cached information into a file being written, at bfd_close. */
497
498 static boolean
499 evax_write_object_contents (abfd)
500 bfd *abfd;
501 {
502 #if EVAX_DEBUG
503 evax_debug (1, "evax_write_object_contents(%p)\n", abfd);
504 #endif
505
506 if (abfd->section_count > 0) /* we have sections */
507 {
508 if (_bfd_evax_write_emh (abfd) != 0)
509 return false;
510 if (_bfd_evax_write_egsd (abfd) != 0)
511 return false;
512 if (_bfd_evax_write_etir (abfd) != 0)
513 return false;
514 if (_bfd_evax_write_etbt (abfd) != 0)
515 return false;
516 if (_bfd_evax_write_eeom (abfd) != 0)
517 return false;
518 }
519 return true;
520 }
521
522 /*-- 4.1, generic -----------------------------------------------------------*/
523
524 /* Called when the BFD is being closed to do any necessary cleanup. */
525
526 static boolean
527 evax_close_and_cleanup (abfd)
528 bfd *abfd;
529 {
530 asection *sec;
531 evax_section *es, *es1;
532 evax_reloc *er, *er1;
533 int i;
534
535 #if EVAX_DEBUG
536 evax_debug (1, "evax_close_and_cleanup(%p)\n", abfd);
537 #endif
538 if (abfd == 0)
539 return true;
540
541 if (PRIV(evax_buf) != NULL)
542 {
543 free (PRIV(evax_buf));
544 PRIV(evax_buf) = NULL;
545 }
546 PRIV(buf_size) = 0;
547
548 if (PRIV(filename) != NULL)
549 {
550 free (PRIV(filename));
551 PRIV(filename) = NULL;
552 }
553
554 if (PRIV(output_buf) != 0)
555 {
556 free (PRIV(output_buf));
557 PRIV(output_buf) = 0;
558 }
559
560 sec = abfd->sections;
561 while (sec != NULL)
562 {
563 if (sec->contents)
564 free (sec->contents);
565 sec = sec->next;
566 }
567
568 if (PRIV(sections) != NULL)
569 {
570 free (PRIV(sections));
571 PRIV(sections) = NULL;
572 }
573
574 if (PRIV(evax_symbol_table))
575 {
576 bfd_hash_table_free (PRIV(evax_symbol_table));
577 PRIV(evax_symbol_table) = 0;
578 }
579
580 if (PRIV(stack))
581 {
582 free (PRIV(stack));
583 PRIV(stack) = 0;
584 }
585
586 if (PRIV(location_stack))
587 {
588 free (PRIV(location_stack));
589 PRIV(location_stack) = 0;
590 }
591
592 for (i = 0; i < EVAX_SECTION_COUNT; i++)
593 {
594 es = PRIV(evax_section_table)[i];
595 while (es != NULL)
596 {
597 es1 = es->next;
598 free (es);
599 es = es1;
600 }
601 PRIV(evax_section_table)[i] = NULL;
602
603 er = PRIV(evax_reloc_table)[i];
604 while (er != NULL)
605 {
606 er1 = er->next;
607 free (er);
608 er = er1;
609 }
610 PRIV(evax_reloc_table)[i] = NULL;
611 }
612
613 free (abfd->tdata.any);
614 abfd->tdata.any = NULL;
615
616 return true;
617 }
618
619
620 /* Ask the BFD to free all cached information. */
621 static boolean
622 evax_bfd_free_cached_info (abfd)
623 bfd *abfd;
624 {
625 #if EVAX_DEBUG
626 evax_debug (1, "evax_bfd_free_cached_info(%p)\n", abfd);
627 #endif
628 return true;
629 }
630
631
632 /* Called when a new section is created. */
633
634 static boolean
635 evax_new_section_hook (abfd, section)
636 bfd *abfd;
637 asection *section;
638 {
639 #if EVAX_DEBUG
640 evax_debug (1, "evax_new_section_hook(%p, %s)\n", abfd, section->name);
641 #endif
642 bfd_set_section_alignment(abfd, section, 4);
643 return true;
644 }
645
646
647 /* Read the contents of a section.
648 buf points to a buffer of buf_size bytes to be filled with
649 section data (starting at offset into section) */
650
651 static boolean
652 evax_get_section_contents (abfd, section, buf, offset, buf_size)
653 bfd *abfd;
654 asection *section;
655 PTR buf;
656 file_ptr offset;
657 bfd_size_type buf_size;
658 {
659 #if EVAX_DEBUG
660 evax_debug (1, "evax_get_section_contents(%p, %s, %p, off %ld, size %d)\n",
661 abfd, section->name, buf, offset, (int)buf_size);
662 #endif
663
664 /* shouldn't be called, since all sections are IN_MEMORY */
665
666 return false;
667 }
668
669 /* Read the contents of a section.
670 buf points to a buffer of buf_size bytes to be filled with
671 section data (starting at offset into section) */
672
673 static boolean
674 evax_get_section_contents_in_window (abfd, section, w, offset, count)
675 bfd *abfd;
676 asection *section;
677 bfd_window *w;
678 file_ptr offset;
679 bfd_size_type count;
680 {
681 #if EVAX_DEBUG
682 evax_debug (1, "evax_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n",
683 abfd, section->name, w, offset, (int)count);
684 #endif
685
686 /* shouldn't be called, since all sections are IN_MEMORY */
687
688 return false;
689 }
690
691 /*-- Part 4.2, copy private data --------------------------------------------*/
692
693 /* Called to copy BFD general private data from one object file
694 to another. */
695
696 static boolean
697 evax_bfd_copy_private_bfd_data (src, dest)
698 bfd *src;
699 bfd *dest;
700 {
701 #if EVAX_DEBUG
702 evax_debug (1, "evax_bfd_copy_private_bfd_data(%p, %p)\n", src, dest);
703 #endif
704 return true;
705 }
706
707
708 /* Merge private BFD information from the BFD @var{ibfd} to the
709 the output file BFD @var{obfd} when linking. Return <<true>>
710 on success, <<false>> on error. Possible error returns are:
711
712 o <<bfd_error_no_memory>> -
713 Not enough memory exists to create private data for @var{obfd}. */
714
715 static boolean
716 evax_bfd_merge_private_bfd_data (ibfd, obfd)
717 bfd *ibfd;
718 bfd *obfd;
719 {
720 #if EVAX_DEBUG
721 evax_debug (1,"evax_bfd_merge_private_bfd_data(%p, %p)\n", ibfd, obfd);
722 #endif
723 return true;
724 }
725
726
727 /* Set private BFD flag information in the BFD @var{abfd}.
728 Return <<true>> on success, <<false>> on error. Possible error
729 returns are:
730
731 o <<bfd_error_no_memory>> -
732 Not enough memory exists to create private data for @var{obfd}. */
733
734 static boolean
735 evax_bfd_set_private_flags (abfd, flags)
736 bfd *abfd;
737 flagword flags;
738 {
739 #if EVAX_DEBUG
740 evax_debug (1,"evax_bfd_set_private_flags(%p, %lx)\n", abfd, (long)flags);
741 #endif
742 return true;
743 }
744
745
746 /* Called to copy BFD private section data from one object file
747 to another. */
748
749 static boolean
750 evax_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec)
751 bfd *srcbfd;
752 asection *srcsec;
753 bfd *dstbfd;
754 asection *dstsec;
755 {
756 #if EVAX_DEBUG
757 evax_debug (1, "evax_bfd_copy_private_section_data(%p, %s, %p, %s)\n",
758 srcbfd, srcsec->name, dstbfd, dstsec->name);
759 #endif
760 return true;
761 }
762
763 /* Called to copy BFD private symbol data from one object file
764 to another. */
765
766 static boolean
767 evax_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym)
768 bfd *ibfd;
769 asymbol *isym;
770 bfd *obfd;
771 asymbol *osym;
772 {
773 #if EVAX_DEBUG
774 evax_debug (1, "evax_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n",
775 ibfd, isym->name, obfd, osym->name);
776 #endif
777 return true;
778 }
779
780 /*-- Part 4.3, core file ----------------------------------------------------*/
781
782 /* Return a read-only string explaining which program was running
783 when it failed and produced the core file abfd. */
784
785 static char *
786 evax_core_file_failing_command (abfd)
787 bfd *abfd;
788 {
789 #if EVAX_DEBUG
790 evax_debug (1, "evax_core_file_failing_command(%p)\n", abfd);
791 #endif
792 return 0;
793 }
794
795
796 /* Returns the signal number which caused the core dump which
797 generated the file the BFD abfd is attached to. */
798
799 static int
800 evax_core_file_failing_signal (abfd)
801 bfd *abfd;
802 {
803 #if EVAX_DEBUG
804 evax_debug (1, "evax_core_file_failing_signal(%p)\n", abfd);
805 #endif
806 return 0;
807 }
808
809
810 /* Return true if the core file attached to core_bfd was generated
811 by a run of the executable file attached to exec_bfd, false otherwise. */
812
813 static boolean
814 evax_core_file_matches_executable_p (abfd, bbfd)
815 bfd *abfd;
816 bfd *bbfd;
817 {
818 #if EVAX_DEBUG
819 evax_debug (1, "evax_core_file_matches_executable_p(%p, %p)\n", abfd, bbfd);
820 #endif
821 return false;
822 }
823
824 /*-- Part 4.4, archive ------------------------------------------------------*/
825
826 /* ??? do something with an archive map.
827 Return false on error, true otherwise. */
828
829 static boolean
830 evax_slurp_armap (abfd)
831 bfd *abfd;
832 {
833 #if EVAX_DEBUG
834 evax_debug (1, "evax_slurp_armap(%p)\n", abfd);
835 #endif
836 return false;
837 }
838
839
840 /* ??? do something with an extended name table.
841 Return false on error, true otherwise. */
842
843 static boolean
844 evax_slurp_extended_name_table (abfd)
845 bfd *abfd;
846 {
847 #if EVAX_DEBUG
848 evax_debug (1, "evax_slurp_extended_name_table(%p)\n", abfd);
849 #endif
850 return false;
851 }
852
853
854 /* ??? do something with an extended name table.
855 Return false on error, true otherwise. */
856
857 static boolean
858 evax_construct_extended_name_table (abfd, tabloc, tablen, name)
859 bfd *abfd;
860 char **tabloc;
861 bfd_size_type *tablen;
862 const char **name;
863 {
864 #if EVAX_DEBUG
865 evax_debug (1, "evax_construct_extended_name_table(%p)\n", abfd);
866 #endif
867 return false;
868 }
869
870
871 /* Truncate the name of an archive to match system-dependent restrictions */
872
873 static void
874 evax_truncate_arname (abfd, pathname, arhdr)
875 bfd *abfd;
876 CONST char *pathname;
877 char *arhdr;
878 {
879 #if EVAX_DEBUG
880 evax_debug (1, "evax_truncate_arname(%p, %s, %s)\n", abfd, pathname, arhdr);
881 #endif
882 return;
883 }
884
885
886 /* ??? write archive map */
887
888 static boolean
889 evax_write_armap (arch, elength, map, orl_count, stridx)
890 bfd *arch;
891 unsigned int elength;
892 struct orl *map;
893 unsigned int orl_count;
894 int stridx;
895 {
896 #if EVAX_DEBUG
897 evax_debug (1, "evax_write_armap(%p, %d, %p, %d %d)\n",
898 arch, elength, map, orl_count, stridx);
899 #endif
900 return true;
901 }
902
903 /* Read archive header ??? */
904
905 static PTR
906 evax_read_ar_hdr (abfd)
907 bfd * abfd;
908 {
909 #if EVAX_DEBUG
910 evax_debug (1, "evax_read_ar_hdr(%p)\n", abfd);
911 #endif
912 return (PTR)0;
913 }
914
915
916 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
917 an input BFD on the first contained element and returns that.
918 Subsequent calls should pass the archive and the previous return value
919 to return a created BFD to the next contained element.
920 NULL is returned when there are no more. */
921
922 static bfd *
923 evax_openr_next_archived_file (arch, prev)
924 bfd *arch;
925 bfd *prev;
926 {
927 #if EVAX_DEBUG
928 evax_debug (1, "evax_openr_next_archived_file(%p, %p)\n", arch, prev);
929 #endif
930 return false;
931 }
932
933
934 /* Return the BFD which is referenced by the symbol in ABFD indexed by
935 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
936
937 static bfd *
938 evax_get_elt_at_index (abfd, index)
939 bfd *abfd;
940 symindex index;
941 {
942 #if EVAX_DEBUG
943 evax_debug (1, "evax_get_elt_at_index(%p, %p)\n", abfd, index);
944 #endif
945 return _bfd_generic_get_elt_at_index(abfd, index);
946 }
947
948
949 /* ???
950 -> bfd_generic_stat_arch_elt */
951
952 static int
953 evax_generic_stat_arch_elt (abfd, stat)
954 bfd *abfd;
955 struct stat *stat;
956 {
957 #if EVAX_DEBUG
958 evax_debug (1, "evax_generic_stat_arch_elt(%p, %p)\n", abfd, stat);
959 #endif
960 return bfd_generic_stat_arch_elt(abfd, stat);
961 }
962
963
964 /* This is a new function in bfd 2.5 */
965
966 static boolean
967 evax_update_armap_timestamp (abfd)
968 bfd *abfd;
969 {
970 #if EVAX_DEBUG
971 evax_debug (1, "evax_update_armap_timestamp(%p)\n", abfd);
972 #endif
973 return true;
974 }
975
976 /*-- Part 4.5, symbols --------------------------------------------------------*/
977
978 /* Return the number of bytes required to store a vector of pointers
979 to asymbols for all the symbols in the BFD abfd, including a
980 terminal NULL pointer. If there are no symbols in the BFD,
981 then return 0. If an error occurs, return -1. */
982
983 static long
984 evax_get_symtab_upper_bound (abfd)
985 bfd *abfd;
986 {
987 #if EVAX_DEBUG
988 evax_debug (1, "evax_get_symtab_upper_bound(%p), %d symbols\n", abfd, PRIV(egsd_sym_count));
989 #endif
990 return (PRIV(egsd_sym_count)+1) * sizeof(asymbol *);
991 }
992
993
994 /* Copy symbols from hash table to symbol vector
995
996 called from bfd_hash_traverse in evax_get_symtab
997 init counter to 0 if entry == 0 */
998
999 static boolean
1000 copy_symbols (entry, arg)
1001 struct bfd_hash_entry *entry;
1002 PTR arg;
1003 {
1004 bfd *abfd = (bfd *) arg;
1005
1006 if (entry == NULL) /* init counter */
1007 PRIV(symnum) = 0;
1008 else /* fill vector, inc counter */
1009 PRIV(symcache)[PRIV(symnum)++] = ((evax_symbol_entry *)entry)->symbol;
1010
1011 return true;
1012 }
1013
1014
1015 /* Read the symbols from the BFD abfd, and fills in the vector
1016 location with pointers to the symbols and a trailing NULL.
1017
1018 return # of symbols read */
1019
1020 static long
1021 evax_get_symtab (abfd, symbols)
1022 bfd *abfd;
1023 asymbol **symbols;
1024 {
1025 #if EVAX_DEBUG
1026 evax_debug (1, "evax_get_symtab(%p, <ret>)\n", abfd);
1027 #endif
1028
1029 /* init counter */
1030 (void)copy_symbols((struct bfd_hash_entry *)0, abfd);
1031
1032 /* traverse table and fill symbols vector */
1033
1034 PRIV(symcache) = symbols;
1035 bfd_hash_traverse(PRIV(evax_symbol_table), copy_symbols, (PTR)abfd);
1036
1037 symbols[bfd_get_symcount(abfd)] = NULL;
1038
1039 return bfd_get_symcount(abfd);
1040 }
1041
1042
1043 /* Create a new asymbol structure for the BFD abfd and return a pointer
1044 to it.
1045 This routine is necessary because each back end has private information
1046 surrounding the asymbol. Building your own asymbol and pointing to it
1047 will not create the private information, and will cause problems later on. */
1048
1049 asymbol *
1050 _bfd_evax_make_empty_symbol (abfd)
1051 bfd *abfd;
1052 {
1053 asymbol *symbol = (asymbol *)bfd_zalloc(abfd, sizeof(asymbol));
1054
1055 #if EVAX_DEBUG
1056 evax_debug (1, "_bfd_evax_make_empty_symbol(%p)\n", abfd);
1057 #endif
1058
1059 if (symbol == 0)
1060 {
1061 bfd_set_error (bfd_error_no_memory);
1062 return 0;
1063 }
1064 symbol->the_bfd = abfd;
1065
1066 return symbol;
1067 }
1068
1069
1070 /* Print symbol to file according to how. how is one of
1071 bfd_print_symbol_name just print the name
1072 bfd_print_symbol_more print more (???)
1073 bfd_print_symbol_all print all we know, which is not much right now :-) */
1074
1075 static void
1076 evax_print_symbol (abfd, file, symbol, how)
1077 bfd *abfd;
1078 PTR file;
1079 asymbol *symbol;
1080 bfd_print_symbol_type how;
1081 {
1082 #if EVAX_DEBUG
1083 evax_debug (1, "evax_print_symbol(%p, %p, %p, %d)\n", abfd, file, symbol, how);
1084 #endif
1085
1086 switch (how)
1087 {
1088 case bfd_print_symbol_name:
1089 case bfd_print_symbol_more:
1090 fprintf((FILE *)file," %s", symbol->name);
1091 break;
1092
1093 break;
1094
1095 case bfd_print_symbol_all:
1096 {
1097 CONST char *section_name = symbol->section->name;
1098
1099 bfd_print_symbol_vandf((PTR)file,symbol);
1100
1101 fprintf((FILE *)file," %-8s %s", section_name, symbol->name);
1102 }
1103 break;
1104 }
1105 return;
1106 }
1107
1108
1109 /* Return information about symbol in ret.
1110
1111 fill type, value and name
1112 type:
1113 A absolute
1114 B bss segment symbol
1115 C common symbol
1116 D data segment symbol
1117 f filename
1118 t a static function symbol
1119 T text segment symbol
1120 U undefined
1121 - debug */
1122
1123 static void
1124 evax_get_symbol_info (abfd, symbol, ret)
1125 bfd *abfd;
1126 asymbol *symbol;
1127 symbol_info *ret;
1128 {
1129 asection *sec;
1130
1131 #if EVAX_DEBUG
1132 evax_debug (1, "evax_get_symbol_info(%p, %p, <ret>)\n", abfd, symbol);
1133 #endif
1134
1135 sec = symbol->section;
1136
1137 if (bfd_is_com_section (sec))
1138 ret->type = 'C';
1139 else if (bfd_is_abs_section (sec))
1140 ret->type = 'A';
1141 else if (bfd_is_und_section (sec))
1142 ret->type = 'U';
1143 else if (bfd_is_abs_section (sec))
1144 ret->type = 'A';
1145 else if (bfd_is_ind_section (sec))
1146 ret->type = 'I';
1147 else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
1148 ret->type = 'T';
1149 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
1150 ret->type = 'D';
1151 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
1152 ret->type = 'B';
1153 else
1154 ret->type = '-';
1155
1156 if (ret->type != 'U')
1157 ret->value = symbol->value + symbol->section->vma;
1158 else
1159 ret->value = 0;
1160 ret->name = symbol->name;
1161
1162 return;
1163 }
1164
1165
1166 /* Return true if the given symbol sym in the BFD abfd is
1167 a compiler generated local label, else return false. */
1168
1169 static boolean
1170 evax_bfd_is_local_label (abfd, symbol)
1171 bfd *abfd;
1172 asymbol *symbol;
1173 {
1174 #if EVAX_DEBUG
1175 evax_debug (1, "evax_bfd_is_local_label(%p, %p)\n", abfd, symbol);
1176 #endif
1177 return false;
1178 }
1179
1180
1181 /* Get source line number for symbol */
1182
1183 static alent *
1184 evax_get_lineno (abfd, symbol)
1185 bfd *abfd;
1186 asymbol *symbol;
1187 {
1188 #if EVAX_DEBUG
1189 evax_debug (1, "evax_get_lineno(%p, %p)\n", abfd, symbol);
1190 #endif
1191 return 0;
1192 }
1193
1194
1195 /* Provided a BFD, a section and an offset into the section, calculate and
1196 return the name of the source file and the line nearest to the wanted
1197 location. */
1198
1199 static boolean
1200 evax_find_nearest_line (abfd, section, symbols, offset, file, func, line)
1201 bfd *abfd;
1202 asection *section;
1203 asymbol **symbols;
1204 bfd_vma offset;
1205 CONST char **file;
1206 CONST char **func;
1207 unsigned int *line;
1208 {
1209 #if EVAX_DEBUG
1210 evax_debug (1, "evax_find_nearest_line(%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
1211 abfd, section->name, symbols, (long int)offset);
1212 #endif
1213 return false;
1214 }
1215
1216
1217 /* Back-door to allow format-aware applications to create debug symbols
1218 while using BFD for everything else. Currently used by the assembler
1219 when creating COFF files. */
1220
1221 static asymbol *
1222 evax_bfd_make_debug_symbol (abfd, ptr, size)
1223 bfd *abfd;
1224 void *ptr;
1225 unsigned long size;
1226 {
1227 #if EVAX_DEBUG
1228 evax_debug (1, "evax_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd, ptr, size);
1229 #endif
1230 return 0;
1231 }
1232
1233
1234 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1235 symbols. The minisymbol_to_symbol function translates these into
1236 BFD asymbol structures. */
1237
1238 static long
1239 evax_read_minisymbols (abfd, dynamic, minisymsp, sizep)
1240 bfd *abfd;
1241 boolean dynamic;
1242 PTR *minisymsp;
1243 unsigned int *sizep;
1244 {
1245 #if EVAX_DEBUG
1246 evax_debug (1, "evax_read_minisymbols(%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
1247 #endif
1248 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
1249 }
1250
1251 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1252 unmodified a.out symbol. The SYM argument is a structure returned
1253 by bfd_make_empty_symbol, which we fill in here. */
1254
1255 static asymbol *
1256 evax_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
1257 bfd *abfd;
1258 boolean dynamic;
1259 const PTR minisym;
1260 asymbol *sym;
1261 {
1262 #if EVAX_DEBUG
1263 evax_debug (1, "evax_minisymbol_to_symbol(%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
1264 #endif
1265 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
1266 }
1267
1268 /*-- Part 4.6, relocations --------------------------------------------------*/
1269
1270 /* Return the number of bytes required to store the relocation information
1271 associated with section sect attached to bfd abfd.
1272 If an error occurs, return -1. */
1273
1274 static long
1275 evax_get_reloc_upper_bound (abfd, section)
1276 bfd *abfd;
1277 asection *section;
1278 {
1279 #if EVAX_DEBUG
1280 evax_debug (1, "evax_get_reloc_upper_bound(%p, %s)\n", abfd, section->name);
1281 #endif
1282 return -1L;
1283 }
1284
1285
1286 /* Call the back end associated with the open BFD abfd and translate the
1287 external form of the relocation information attached to sec into the
1288 internal canonical form. Place the table into memory at loc, which has
1289 been preallocated, usually by a call to bfd_get_reloc_upper_bound.
1290 Returns the number of relocs, or -1 on error. */
1291
1292 static long
1293 evax_canonicalize_reloc (abfd, section, location, symbols)
1294 bfd *abfd;
1295 asection *section;
1296 arelent **location;
1297 asymbol **symbols;
1298 {
1299 #if EVAX_DEBUG
1300 evax_debug (1, "evax_canonicalize_reloc(%p, %s, <ret>, <ret>)\n", abfd, section->name);
1301 #endif
1302 return false;
1303 }
1304
1305 /*---------------------------------------------------------------------------*/
1306 /* this is just copied from ecoff-alpha, needs to be fixed probably */
1307
1308 /* How to process the various reloc types. */
1309
1310 static bfd_reloc_status_type
1311 reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
1312 bfd *abfd;
1313 arelent *reloc;
1314 asymbol *sym;
1315 PTR data;
1316 asection *sec;
1317 bfd *output_bfd;
1318 char **error_message;
1319 {
1320 evax_reloc *er;
1321
1322 #if EVAX_DEBUG
1323 evax_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd, output_bfd);
1324 evax_debug (2, "In section %s, symbol %s\n",
1325 sec->name, sym->name);
1326 evax_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1327 reloc->sym_ptr_ptr[0]->name,
1328 (unsigned long)reloc->address,
1329 (unsigned long)reloc->addend, reloc->howto->name);
1330 evax_debug (2, "data at %p\n", data);
1331 /* _bfd_hexdump (2, data, bfd_get_reloc_size(reloc->howto),0); */
1332 #endif
1333
1334 er = (evax_reloc *)malloc (sizeof(evax_reloc));
1335 if (er == NULL)
1336 {
1337 bfd_set_error (bfd_error_no_memory);
1338 return bfd_reloc_notsupported; /* FIXME */
1339 }
1340 er->section = sec;
1341 er->reloc = reloc;
1342 er->next = NULL;
1343 if (PRIV(evax_reloc_table)[sec->index] == NULL)
1344 {
1345 PRIV(evax_reloc_table)[sec->index] = er;
1346 }
1347 else
1348 {
1349 er->next = PRIV(evax_reloc_table)[sec->index];
1350 }
1351 return bfd_reloc_ok;
1352 }
1353
1354 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1355 from smaller values. Start with zero, widen, *then* decrement. */
1356 #define MINUS_ONE (((bfd_vma)0) - 1)
1357
1358 static reloc_howto_type alpha_howto_table[] =
1359 {
1360 HOWTO (ALPHA_R_IGNORE, /* type */
1361 0, /* rightshift */
1362 0, /* size (0 = byte, 1 = short, 2 = long) */
1363 8, /* bitsize */
1364 true, /* pc_relative */
1365 0, /* bitpos */
1366 complain_overflow_dont, /* complain_on_overflow */
1367 reloc_nil, /* special_function */
1368 "IGNORE", /* name */
1369 true, /* partial_inplace */
1370 0, /* src_mask */
1371 0, /* dst_mask */
1372 true), /* pcrel_offset */
1373
1374 /* A 64 bit reference to a symbol. */
1375 HOWTO (ALPHA_R_REFQUAD, /* type */
1376 0, /* rightshift */
1377 4, /* size (0 = byte, 1 = short, 2 = long) */
1378 64, /* bitsize */
1379 false, /* pc_relative */
1380 0, /* bitpos */
1381 complain_overflow_bitfield, /* complain_on_overflow */
1382 reloc_nil, /* special_function */
1383 "REFQUAD", /* name */
1384 true, /* partial_inplace */
1385 MINUS_ONE, /* src_mask */
1386 MINUS_ONE, /* dst_mask */
1387 false), /* pcrel_offset */
1388
1389 /* A 21 bit branch. The native assembler generates these for
1390 branches within the text segment, and also fills in the PC
1391 relative offset in the instruction. */
1392 HOWTO (ALPHA_R_BRADDR, /* type */
1393 2, /* rightshift */
1394 2, /* size (0 = byte, 1 = short, 2 = long) */
1395 21, /* bitsize */
1396 true, /* pc_relative */
1397 0, /* bitpos */
1398 complain_overflow_signed, /* complain_on_overflow */
1399 reloc_nil, /* special_function */
1400 "BRADDR", /* name */
1401 true, /* partial_inplace */
1402 0x1fffff, /* src_mask */
1403 0x1fffff, /* dst_mask */
1404 false), /* pcrel_offset */
1405
1406 /* A hint for a jump to a register. */
1407 HOWTO (ALPHA_R_HINT, /* type */
1408 2, /* rightshift */
1409 1, /* size (0 = byte, 1 = short, 2 = long) */
1410 14, /* bitsize */
1411 true, /* pc_relative */
1412 0, /* bitpos */
1413 complain_overflow_dont, /* complain_on_overflow */
1414 reloc_nil, /* special_function */
1415 "HINT", /* name */
1416 true, /* partial_inplace */
1417 0x3fff, /* src_mask */
1418 0x3fff, /* dst_mask */
1419 false), /* pcrel_offset */
1420
1421 /* 16 bit PC relative offset. */
1422 HOWTO (ALPHA_R_SREL16, /* type */
1423 0, /* rightshift */
1424 1, /* size (0 = byte, 1 = short, 2 = long) */
1425 16, /* bitsize */
1426 true, /* pc_relative */
1427 0, /* bitpos */
1428 complain_overflow_signed, /* complain_on_overflow */
1429 reloc_nil, /* special_function */
1430 "SREL16", /* name */
1431 true, /* partial_inplace */
1432 0xffff, /* src_mask */
1433 0xffff, /* dst_mask */
1434 false), /* pcrel_offset */
1435
1436 /* 32 bit PC relative offset. */
1437 HOWTO (ALPHA_R_SREL32, /* type */
1438 0, /* rightshift */
1439 2, /* size (0 = byte, 1 = short, 2 = long) */
1440 32, /* bitsize */
1441 true, /* pc_relative */
1442 0, /* bitpos */
1443 complain_overflow_signed, /* complain_on_overflow */
1444 reloc_nil, /* special_function */
1445 "SREL32", /* name */
1446 true, /* partial_inplace */
1447 0xffffffff, /* src_mask */
1448 0xffffffff, /* dst_mask */
1449 false), /* pcrel_offset */
1450
1451 /* A 64 bit PC relative offset. */
1452 HOWTO (ALPHA_R_SREL64, /* type */
1453 0, /* rightshift */
1454 4, /* size (0 = byte, 1 = short, 2 = long) */
1455 64, /* bitsize */
1456 true, /* pc_relative */
1457 0, /* bitpos */
1458 complain_overflow_signed, /* complain_on_overflow */
1459 reloc_nil, /* special_function */
1460 "SREL64", /* name */
1461 true, /* partial_inplace */
1462 MINUS_ONE, /* src_mask */
1463 MINUS_ONE, /* dst_mask */
1464 false), /* pcrel_offset */
1465
1466 /* Push a value on the reloc evaluation stack. */
1467 HOWTO (ALPHA_R_OP_PUSH, /* type */
1468 0, /* rightshift */
1469 0, /* size (0 = byte, 1 = short, 2 = long) */
1470 0, /* bitsize */
1471 false, /* pc_relative */
1472 0, /* bitpos */
1473 complain_overflow_dont, /* complain_on_overflow */
1474 reloc_nil, /* special_function */
1475 "OP_PUSH", /* name */
1476 false, /* partial_inplace */
1477 0, /* src_mask */
1478 0, /* dst_mask */
1479 false), /* pcrel_offset */
1480
1481 /* Store the value from the stack at the given address. Store it in
1482 a bitfield of size r_size starting at bit position r_offset. */
1483 HOWTO (ALPHA_R_OP_STORE, /* type */
1484 0, /* rightshift */
1485 4, /* size (0 = byte, 1 = short, 2 = long) */
1486 64, /* bitsize */
1487 false, /* pc_relative */
1488 0, /* bitpos */
1489 complain_overflow_dont, /* complain_on_overflow */
1490 reloc_nil, /* special_function */
1491 "OP_STORE", /* name */
1492 false, /* partial_inplace */
1493 0, /* src_mask */
1494 MINUS_ONE, /* dst_mask */
1495 false), /* pcrel_offset */
1496
1497 /* Subtract the reloc address from the value on the top of the
1498 relocation stack. */
1499 HOWTO (ALPHA_R_OP_PSUB, /* type */
1500 0, /* rightshift */
1501 0, /* size (0 = byte, 1 = short, 2 = long) */
1502 0, /* bitsize */
1503 false, /* pc_relative */
1504 0, /* bitpos */
1505 complain_overflow_dont, /* complain_on_overflow */
1506 reloc_nil, /* special_function */
1507 "OP_PSUB", /* name */
1508 false, /* partial_inplace */
1509 0, /* src_mask */
1510 0, /* dst_mask */
1511 false), /* pcrel_offset */
1512
1513 /* Shift the value on the top of the relocation stack right by the
1514 given value. */
1515 HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
1516 0, /* rightshift */
1517 0, /* size (0 = byte, 1 = short, 2 = long) */
1518 0, /* bitsize */
1519 false, /* pc_relative */
1520 0, /* bitpos */
1521 complain_overflow_dont, /* complain_on_overflow */
1522 reloc_nil, /* special_function */
1523 "OP_PRSHIFT", /* name */
1524 false, /* partial_inplace */
1525 0, /* src_mask */
1526 0, /* dst_mask */
1527 false), /* pcrel_offset */
1528
1529 /* Hack. Linkage is done by linker. */
1530 HOWTO (ALPHA_R_LINKAGE, /* type */
1531 0, /* rightshift */
1532 8, /* size (0 = byte, 1 = short, 2 = long) */
1533 256, /* bitsize */
1534 false, /* pc_relative */
1535 0, /* bitpos */
1536 complain_overflow_dont, /* complain_on_overflow */
1537 reloc_nil, /* special_function */
1538 "LINKAGE", /* name */
1539 false, /* partial_inplace */
1540 0, /* src_mask */
1541 0, /* dst_mask */
1542 false), /* pcrel_offset */
1543
1544 /* Switch table, 32bit relocation. */
1545 HOWTO (ALPHA_R_SWREL32, /* type */
1546 0, /* rightshift */
1547 2, /* size (0 = byte, 1 = short, 2 = long) */
1548 32, /* bitsize */
1549 false, /* pc_relative */
1550 0, /* bitpos */
1551 complain_overflow_dont, /* complain_on_overflow */
1552 reloc_nil, /* special_function */
1553 "SWREL32", /* name */
1554 false, /* partial_inplace */
1555 0xffffffff, /* src_mask */
1556 0xffffffff, /* dst_mask */
1557 false), /* pcrel_offset */
1558
1559 /* Switch table, 64bit relocation. */
1560 HOWTO (ALPHA_R_SWREL64, /* type */
1561 0, /* rightshift */
1562 4, /* size (0 = byte, 1 = short, 2 = long) */
1563 64, /* bitsize */
1564 false, /* pc_relative */
1565 0, /* bitpos */
1566 complain_overflow_dont, /* complain_on_overflow */
1567 reloc_nil, /* special_function */
1568 "SWREL64", /* name */
1569 false, /* partial_inplace */
1570 MINUS_ONE, /* src_mask */
1571 MINUS_ONE, /* dst_mask */
1572 false), /* pcrel_offset */
1573
1574 /* A 32 bit reference to a symbol. */
1575 HOWTO (ALPHA_R_REFLONG, /* type */
1576 0, /* rightshift */
1577 2, /* size (0 = byte, 1 = short, 2 = long) */
1578 32, /* bitsize */
1579 false, /* pc_relative */
1580 0, /* bitpos */
1581 complain_overflow_bitfield, /* complain_on_overflow */
1582 reloc_nil, /* special_function */
1583 "REFLONG", /* name */
1584 true, /* partial_inplace */
1585 0xffffffff, /* src_mask */
1586 0xffffffff, /* dst_mask */
1587 false), /* pcrel_offset */
1588
1589 };
1590
1591 /* Return a pointer to a howto structure which, when invoked, will perform
1592 the relocation code on data from the architecture noted. */
1593
1594 static const struct reloc_howto_struct *
1595 evax_bfd_reloc_type_lookup (abfd, code)
1596 bfd *abfd;
1597 bfd_reloc_code_real_type code;
1598 {
1599 int alpha_type;
1600
1601 #if EVAX_DEBUG
1602 evax_debug (1, "evax_bfd_reloc_type_lookup(%p, %d)\t", abfd, code);
1603 #endif
1604
1605 switch (code)
1606 {
1607 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
1608 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
1609 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
1610 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
1611 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
1612 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
1613 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
1614 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
1615 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
1616 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
1617 case BFD_RELOC_SWREL32: alpha_type = ALPHA_R_SWREL32; break;
1618 case BFD_RELOC_SWREL64: alpha_type = ALPHA_R_SWREL64; break;
1619 #if 0
1620 case ???: alpha_type = ALPHA_R_OP_PUSH; break;
1621 case ???: alpha_type = ALPHA_R_OP_STORE; break;
1622 case ???: alpha_type = ALPHA_R_OP_PSUB; break;
1623 case ???: alpha_type = ALPHA_R_OP_PRSHIFT;break;
1624 case ???: alpha_type = ALPHA_R_GPVALUE; break;
1625 #endif
1626 default:
1627 (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
1628 return (const struct reloc_howto_struct *) NULL;
1629 }
1630 #if EVAX_DEBUG
1631 evax_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
1632 #endif
1633 return &alpha_howto_table[alpha_type];
1634 }
1635
1636
1637 /*-- Part 4.7, writing an object file ---------------------------------------*/
1638
1639 /* Set the architecture and machine type in BFD abfd to arch and mach.
1640 Find the correct pointer to a structure and insert it into the arch_info
1641 pointer. */
1642
1643 static boolean
1644 evax_set_arch_mach (abfd, arch, mach)
1645 bfd *abfd;
1646 enum bfd_architecture arch;
1647 unsigned long mach;
1648 {
1649 #if EVAX_DEBUG
1650 evax_debug (1, "evax_set_arch_mach(%p, %d, %ld)\n", abfd, arch, mach);
1651 #endif
1652 abfd->arch_info = bfd_scan_arch("alpha");
1653
1654 return true;
1655 }
1656
1657
1658 /* Sets the contents of the section section in BFD abfd to the data starting
1659 in memory at data. The data is written to the output section starting at
1660 offset offset for count bytes.
1661
1662 Normally true is returned, else false. Possible error returns are:
1663 o bfd_error_no_contents - The output section does not have the
1664 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1665 o and some more too */
1666
1667 static boolean
1668 evax_set_section_contents (abfd, section, location, offset, count)
1669 bfd *abfd;
1670 asection *section;
1671 PTR location;
1672 file_ptr offset;
1673 bfd_size_type count;
1674 {
1675 #if EVAX_DEBUG
1676 evax_debug (1, "evax_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n",
1677 abfd, section->name, location, (long int)offset, (int)count);
1678 #endif
1679 return _bfd_save_evax_section(abfd, section, location, offset, count);
1680 }
1681
1682
1683 /*-- Part 4.8, linker -------------------------------------------------------*/
1684
1685 /* Get the size of the section headers. */
1686
1687 static int
1688 evax_sizeof_headers (abfd, reloc)
1689 bfd *abfd;
1690 boolean reloc;
1691 {
1692 #if EVAX_DEBUG
1693 evax_debug (1, "evax_sizeof_headers(%p, %s)\n", abfd, (reloc)?"True":"False");
1694 #endif
1695 return 0;
1696 }
1697
1698
1699 /* Provides default handling of relocation effort for back ends
1700 which can't be bothered to do it efficiently. */
1701
1702 static bfd_byte *
1703 evax_bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
1704 relocateable, symbols)
1705 bfd *abfd;
1706 struct bfd_link_info *link_info;
1707 struct bfd_link_order *link_order;
1708 bfd_byte *data;
1709 boolean relocateable;
1710 asymbol **symbols;
1711 {
1712 #if EVAX_DEBUG
1713 evax_debug (1, "evax_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n",
1714 abfd, link_info, link_order, data, (relocateable)?"True":"False", symbols);
1715 #endif
1716 return 0;
1717 }
1718
1719
1720 /* ??? */
1721
1722 static boolean
1723 evax_bfd_relax_section (abfd, section, link_info, again)
1724 bfd *abfd;
1725 asection *section;
1726 struct bfd_link_info *link_info;
1727 boolean *again;
1728 {
1729 #if EVAX_DEBUG
1730 evax_debug (1, "evax_bfd_relax_section(%p, %s, %p, <ret>)\n",
1731 abfd, section->name, link_info);
1732 #endif
1733 return true;
1734 }
1735
1736
1737 /* Create a hash table for the linker. Different backends store
1738 different information in this table. */
1739
1740 static struct bfd_link_hash_table *
1741 evax_bfd_link_hash_table_create (abfd)
1742 bfd *abfd;
1743 {
1744 #if EVAX_DEBUG
1745 evax_debug (1, "evax_bfd_link_hash_table_create(%p)\n", abfd);
1746 #endif
1747 return 0;
1748 }
1749
1750
1751 /* Add symbols from this object file into the hash table. */
1752
1753 static boolean
1754 evax_bfd_link_add_symbols (abfd, link_info)
1755 bfd *abfd;
1756 struct bfd_link_info *link_info;
1757 {
1758 #if EVAX_DEBUG
1759 evax_debug (1, "evax_bfd_link_add_symbols(%p, %p)\n", abfd, link_info);
1760 #endif
1761 return false;
1762 }
1763
1764
1765 /* Do a link based on the link_order structures attached to each
1766 section of the BFD. */
1767
1768 static boolean
1769 evax_bfd_final_link (abfd, link_info)
1770 bfd *abfd;
1771 struct bfd_link_info *link_info;
1772 {
1773 #if EVAX_DEBUG
1774 evax_debug (1, "evax_bfd_final_link(%p, %p)\n", abfd, link_info);
1775 #endif
1776 return true;
1777 }
1778
1779 /* Should this section be split up into smaller pieces during linking. */
1780
1781 static boolean
1782 evax_bfd_link_split_section (abfd, section)
1783 bfd *abfd;
1784 asection *section;
1785 {
1786 #if EVAX_DEBUG
1787 evax_debug (1, "evax_bfd_link_split_section(%p, %s)\n", abfd, section->name);
1788 #endif
1789 return false;
1790 }
1791
1792 /*-- Part 4.9, dynamic symbols and relocations ------------------------------*/
1793
1794 /* Get the amount of memory required to hold the dynamic symbols. */
1795
1796 static long
1797 evax_get_dynamic_symtab_upper_bound (abfd)
1798 bfd *abfd;
1799 {
1800 #if EVAX_DEBUG
1801 evax_debug (1, "evax_get_dynamic_symtab_upper_bound(%p)\n", abfd);
1802 #endif
1803 return 0;
1804 }
1805
1806 static boolean
1807 evax_bfd_print_private_bfd_data (abfd, file)
1808 bfd *abfd;
1809 void *file;
1810 {
1811 #if EVAX_DEBUG
1812 evax_debug (1, "evax_bfd_print_private_bfd_data(%p)\n", abfd);
1813 #endif
1814 return 0;
1815 }
1816
1817
1818 /* Read in the dynamic symbols. */
1819
1820 static long
1821 evax_canonicalize_dynamic_symtab (abfd, symbols)
1822 bfd *abfd;
1823 asymbol **symbols;
1824 {
1825 #if EVAX_DEBUG
1826 evax_debug (1, "evax_canonicalize_dynamic_symtab(%p, <ret>)\n", abfd);
1827 #endif
1828 return 0L;
1829 }
1830
1831
1832 /* Get the amount of memory required to hold the dynamic relocs. */
1833
1834 static long
1835 evax_get_dynamic_reloc_upper_bound (abfd)
1836 bfd *abfd;
1837 {
1838 #if EVAX_DEBUG
1839 evax_debug (1, "evax_get_dynamic_reloc_upper_bound(%p)\n", abfd);
1840 #endif
1841 return 0L;
1842 }
1843
1844
1845 /* Read in the dynamic relocs. */
1846
1847 static long
1848 evax_canonicalize_dynamic_reloc (abfd, arel, symbols)
1849 bfd *abfd;
1850 arelent **arel;
1851 asymbol **symbols;
1852 {
1853 #if EVAX_DEBUG
1854 evax_debug (1, "evax_canonicalize_dynamic_reloc(%p)\n", abfd);
1855 #endif
1856 return 0L;
1857 }
This page took 0.066713 seconds and 4 git commands to generate.