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