Further wacking to make sanitize and "make gdb.tar.Z" agree.
[deliverable/binutils-gdb.git] / bfd / coff-i960.c
CommitLineData
fc723380
JG
1/* Intel 960 COFF support for BFD. */
2
4a81b561
DHW
3/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Diddler.
6
7BFD is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 1, or (at your option)
10any later version.
11
12BFD is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with BFD; see the file COPYING. If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21/* $Id$ */
22
23#define I960 1
fc723380
JG
24#define BADMAG(x) I960BADMAG(x)
25
4bf6219f 26#include <ansidecl.h>
7ed4093a 27#include <sysdep.h>
4a81b561
DHW
28#include "bfd.h"
29#include "libbfd.h"
9872a49c 30#include "obstack.h"
4cddd1c9 31#include "intel-coff.h"
4a81b561
DHW
32#include "libcoff.h" /* to allow easier abstraction-breaking */
33
34
4a81b561
DHW
35#define CALLS 0x66003800 /* Template for 'calls' instruction */
36#define BAL 0x0b000000 /* Template for 'bal' instruction */
37#define BAL_MASK 0x00ffffff
38
39static bfd_reloc_status_enum_type
40optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section)
41bfd *abfd;
42arelent *reloc_entry;
43asymbol *symbol_in;
44unsigned char *data;
45asection *ignore_input_section;
46{
47 /* This item has already been relocated correctly, but we may be
48 * able to patch in yet better code - done by digging out the
49 * correct info on this symbol */
50 bfd_reloc_status_enum_type result;
51 coff_symbol_type *cs = coffsymbol(symbol_in);
52
fc723380
JG
53 /* So the target symbol has to be of coff type, and the symbol
54 has to have the correct native information within it */
4a81b561 55 if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
e5b919b1 56 || (cs->native == (struct internal_syment *)NULL)) {
4a81b561
DHW
57 /* This is interesting, consider the case where we're outputting */
58 /* coff from a mix n match input, linking from coff to a symbol */
59 /* defined in a bout file will cause this match to be true. Should */
60 /* I complain ? - This will only work if the bout symbol is non */
61 /* leaf. */
62 result = bfd_reloc_dangerous;
4a81b561
DHW
63 }
64 else {
8e3c8f47 65 switch (cs->native->n_sclass)
4a81b561
DHW
66 {
67 case C_LEAFSTAT:
68 case C_LEAFEXT:
69 /* This is a call to a leaf procedure, replace instruction with a bal
70 to the correct location */
71 {
8e3c8f47 72 union internal_auxent *aux = (union internal_auxent *)(cs->native+2);
19b03b7a 73 int word = bfd_get_32(abfd, data + reloc_entry->address);
8e3c8f47
SC
74 int olf = (aux->x_bal.x_balntry - cs->native->n_value);
75 BFD_ASSERT(cs->native->n_numaux==2);
4a81b561
DHW
76 /* We replace the original call instruction with a bal to */
77 /* the bal entry point - the offset of which is described in the */
78 /* 2nd auxent of the original symbol. We keep the native sym and */
79 /* auxents untouched, so the delta between the two is the */
80 /* offset of the bal entry point */
8e3c8f47
SC
81
82 word = ((word + olf) & BAL_MASK) | BAL;
19b03b7a 83 bfd_put_32(abfd, word, data+reloc_entry->address);
4a81b561
DHW
84 }
85 result = bfd_reloc_ok;
86 break;
87 case C_SCALL:
88 {
89 /* This is a call to a system call, replace with a calls to # */
90 BFD_ASSERT(0);
91 }
92 break;
93 default:
94 result = bfd_reloc_ok;
95 break;
96 }
97 }
98 return result;
99}
100
101
102
103static reloc_howto_type howto_table[] =
104{
105 {0},
106 {1},
107 {2},
108 {3},
109 {4},
110 {5},
111 {6},
112 {7},
113 {8},
114 {9},
115 {10},
116 {11},
117 {12},
118 {13},
119 {14},
120 {15},
121 {16},
122
9872a49c
SC
123 { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true,
124 0,"rellong", true, 0xffffffff, 0xffffffff},
4a81b561
DHW
125 {18},
126 {19},
127 {20},
128 {21},
129 {22},
130 {23},
131 {24},
132
9872a49c
SC
133 { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true,
134 0x00ffffff, 0x00ffffff},
4a81b561
DHW
135 {26},
136
9872a49c
SC
137 { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback,
138 "optcall", true, 0x00ffffff, 0x00ffffff},
4a81b561
DHW
139
140};
141
924bbb38 142/* The real code is in coffcode.h */
4a81b561 143
7ed4093a 144#include "coffcode.h"
4a81b561 145
9872a49c 146bfd_target icoff_little_vec =
4a81b561 147{
9872a49c 148 "coff-Intel-little", /* name */
4a81b561
DHW
149 bfd_target_coff_flavour_enum,
150 false, /* data byte order is little */
9872a49c 151 false, /* header byte order is little */
4a81b561
DHW
152
153 (HAS_RELOC | EXEC_P | /* object flags */
154 HAS_LINENO | HAS_DEBUG |
155 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
156
157 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
4a81b561
DHW
158 '/', /* ar_pad_char */
159 15, /* ar_max_namelen */
4a81b561 160
19b03b7a
SC
161 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
162 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
4a81b561 163
19b03b7a
SC
164 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
165 bfd_generic_archive_p, _bfd_dummy_target},
166 {bfd_false, coff_mkobject, /* bfd_set_format */
167 _bfd_generic_mkarchive, bfd_false},
168 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
169 _bfd_write_archive_contents, bfd_false},
fc723380 170 JUMP_TABLE(coff)
19b03b7a 171 };
4a81b561
DHW
172
173
9872a49c 174bfd_target icoff_big_vec =
4a81b561 175{
9872a49c 176 "coff-Intel-big", /* name */
4a81b561
DHW
177 bfd_target_coff_flavour_enum,
178 false, /* data byte order is little */
9872a49c 179 true, /* header byte order is big */
4a81b561
DHW
180
181 (HAS_RELOC | EXEC_P | /* object flags */
182 HAS_LINENO | HAS_DEBUG |
183 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
184
185 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
4a81b561
DHW
186 '/', /* ar_pad_char */
187 15, /* ar_max_namelen */
4a81b561 188
19b03b7a
SC
189_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
190_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
4a81b561 191
2b1d8a50
JG
192 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
193 bfd_generic_archive_p, _bfd_dummy_target},
194 {bfd_false, coff_mkobject, /* bfd_set_format */
195 _bfd_generic_mkarchive, bfd_false},
196 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
197 _bfd_write_archive_contents, bfd_false},
9872a49c 198 JUMP_TABLE(coff)
fc723380 199};
This page took 0.03552 seconds and 4 git commands to generate.