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