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