1 | /* BFD back-end for ALPHA Extended-Coff files.
|
---|
2 | Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
---|
3 | Free Software Foundation, Inc.
|
---|
4 | Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
|
---|
5 | Ian Lance Taylor <ian@cygnus.com>.
|
---|
6 |
|
---|
7 | This file is part of BFD, the Binary File Descriptor library.
|
---|
8 |
|
---|
9 | This program is free software; you can redistribute it and/or modify
|
---|
10 | it under the terms of the GNU General Public License as published by
|
---|
11 | the Free Software Foundation; either version 2 of the License, or
|
---|
12 | (at your option) any later version.
|
---|
13 |
|
---|
14 | This program is distributed in the hope that it will be useful,
|
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | GNU General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU General Public License
|
---|
20 | along with this program; if not, write to the Free Software
|
---|
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
---|
22 |
|
---|
23 | #include "bfd.h"
|
---|
24 | #include "sysdep.h"
|
---|
25 | #include "bfdlink.h"
|
---|
26 | #include "libbfd.h"
|
---|
27 | #include "coff/internal.h"
|
---|
28 | #include "coff/sym.h"
|
---|
29 | #include "coff/symconst.h"
|
---|
30 | #include "coff/ecoff.h"
|
---|
31 | #include "coff/alpha.h"
|
---|
32 | #include "aout/ar.h"
|
---|
33 | #include "libcoff.h"
|
---|
34 | #include "libecoff.h"
|
---|
35 | |
---|
36 |
|
---|
37 | /* Prototypes for static functions. */
|
---|
38 |
|
---|
39 | static const bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
|
---|
40 | static boolean alpha_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
|
---|
41 | static PTR alpha_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
|
---|
42 | static void alpha_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
|
---|
43 | struct internal_reloc *));
|
---|
44 | static void alpha_ecoff_swap_reloc_out PARAMS ((bfd *,
|
---|
45 | const struct internal_reloc *,
|
---|
46 | PTR));
|
---|
47 | static void alpha_adjust_reloc_in PARAMS ((bfd *,
|
---|
48 | const struct internal_reloc *,
|
---|
49 | arelent *));
|
---|
50 | static void alpha_adjust_reloc_out PARAMS ((bfd *, const arelent *,
|
---|
51 | struct internal_reloc *));
|
---|
52 | static reloc_howto_type *alpha_bfd_reloc_type_lookup
|
---|
53 | PARAMS ((bfd *, bfd_reloc_code_real_type));
|
---|
54 | static bfd_byte *alpha_ecoff_get_relocated_section_contents
|
---|
55 | PARAMS ((bfd *abfd, struct bfd_link_info *, struct bfd_link_order *,
|
---|
56 | bfd_byte *data, boolean relocateable, asymbol **symbols));
|
---|
57 | static bfd_vma alpha_convert_external_reloc
|
---|
58 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, struct external_reloc *,
|
---|
59 | struct ecoff_link_hash_entry *));
|
---|
60 | static boolean alpha_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
|
---|
61 | bfd *, asection *,
|
---|
62 | bfd_byte *, PTR));
|
---|
63 | static boolean alpha_adjust_headers
|
---|
64 | PARAMS ((bfd *, struct internal_filehdr *, struct internal_aouthdr *));
|
---|
65 | static PTR alpha_ecoff_read_ar_hdr PARAMS ((bfd *));
|
---|
66 | static bfd *alpha_ecoff_get_elt_at_filepos PARAMS ((bfd *, file_ptr));
|
---|
67 | static bfd *alpha_ecoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
|
---|
68 | static bfd *alpha_ecoff_get_elt_at_index PARAMS ((bfd *, symindex));
|
---|
69 | |
---|
70 |
|
---|
71 | /* ECOFF has COFF sections, but the debugging information is stored in
|
---|
72 | a completely different format. ECOFF targets use some of the
|
---|
73 | swapping routines from coffswap.h, and some of the generic COFF
|
---|
74 | routines in coffgen.c, but, unlike the real COFF targets, do not
|
---|
75 | use coffcode.h itself.
|
---|
76 |
|
---|
77 | Get the generic COFF swapping routines, except for the reloc,
|
---|
78 | symbol, and lineno ones. Give them ecoff names. Define some
|
---|
79 | accessor macros for the large sizes used for Alpha ECOFF. */
|
---|
80 |
|
---|
81 | #define GET_FILEHDR_SYMPTR bfd_h_get_64
|
---|
82 | #define PUT_FILEHDR_SYMPTR bfd_h_put_64
|
---|
83 | #define GET_AOUTHDR_TSIZE bfd_h_get_64
|
---|
84 | #define PUT_AOUTHDR_TSIZE bfd_h_put_64
|
---|
85 | #define GET_AOUTHDR_DSIZE bfd_h_get_64
|
---|
86 | #define PUT_AOUTHDR_DSIZE bfd_h_put_64
|
---|
87 | #define GET_AOUTHDR_BSIZE bfd_h_get_64
|
---|
88 | #define PUT_AOUTHDR_BSIZE bfd_h_put_64
|
---|
89 | #define GET_AOUTHDR_ENTRY bfd_h_get_64
|
---|
90 | #define PUT_AOUTHDR_ENTRY bfd_h_put_64
|
---|
91 | #define GET_AOUTHDR_TEXT_START bfd_h_get_64
|
---|
92 | #define PUT_AOUTHDR_TEXT_START bfd_h_put_64
|
---|
93 | #define GET_AOUTHDR_DATA_START bfd_h_get_64
|
---|
94 | #define PUT_AOUTHDR_DATA_START bfd_h_put_64
|
---|
95 | #define GET_SCNHDR_PADDR bfd_h_get_64
|
---|
96 | #define PUT_SCNHDR_PADDR bfd_h_put_64
|
---|
97 | #define GET_SCNHDR_VADDR bfd_h_get_64
|
---|
98 | #define PUT_SCNHDR_VADDR bfd_h_put_64
|
---|
99 | #define GET_SCNHDR_SIZE bfd_h_get_64
|
---|
100 | #define PUT_SCNHDR_SIZE bfd_h_put_64
|
---|
101 | #define GET_SCNHDR_SCNPTR bfd_h_get_64
|
---|
102 | #define PUT_SCNHDR_SCNPTR bfd_h_put_64
|
---|
103 | #define GET_SCNHDR_RELPTR bfd_h_get_64
|
---|
104 | #define PUT_SCNHDR_RELPTR bfd_h_put_64
|
---|
105 | #define GET_SCNHDR_LNNOPTR bfd_h_get_64
|
---|
106 | #define PUT_SCNHDR_LNNOPTR bfd_h_put_64
|
---|
107 |
|
---|
108 | #define ALPHAECOFF
|
---|
109 |
|
---|
110 | #define NO_COFF_RELOCS
|
---|
111 | #define NO_COFF_SYMBOLS
|
---|
112 | #define NO_COFF_LINENOS
|
---|
113 | #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
|
---|
114 | #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
|
---|
115 | #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
|
---|
116 | #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
|
---|
117 | #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
|
---|
118 | #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
|
---|
119 | #include "coffswap.h"
|
---|
120 |
|
---|
121 | /* Get the ECOFF swapping routines. */
|
---|
122 | #define ECOFF_64
|
---|
123 | #include "ecoffswap.h"
|
---|
124 | |
---|
125 |
|
---|
126 | /* How to process the various reloc types. */
|
---|
127 |
|
---|
128 | static bfd_reloc_status_type
|
---|
129 | reloc_nil PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
---|
130 | asection *, bfd *, char **));
|
---|
131 |
|
---|
132 | static bfd_reloc_status_type
|
---|
133 | reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
|
---|
134 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
135 | arelent *reloc ATTRIBUTE_UNUSED;
|
---|
136 | asymbol *sym ATTRIBUTE_UNUSED;
|
---|
137 | PTR data ATTRIBUTE_UNUSED;
|
---|
138 | asection *sec ATTRIBUTE_UNUSED;
|
---|
139 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
---|
140 | char **error_message ATTRIBUTE_UNUSED;
|
---|
141 | {
|
---|
142 | return bfd_reloc_ok;
|
---|
143 | }
|
---|
144 |
|
---|
145 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
---|
146 | from smaller values. Start with zero, widen, *then* decrement. */
|
---|
147 | #define MINUS_ONE (((bfd_vma)0) - 1)
|
---|
148 |
|
---|
149 | static reloc_howto_type alpha_howto_table[] =
|
---|
150 | {
|
---|
151 | /* Reloc type 0 is ignored by itself. However, it appears after a
|
---|
152 | GPDISP reloc to identify the location where the low order 16 bits
|
---|
153 | of the gp register are loaded. */
|
---|
154 | HOWTO (ALPHA_R_IGNORE, /* type */
|
---|
155 | 0, /* rightshift */
|
---|
156 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
157 | 8, /* bitsize */
|
---|
158 | true, /* pc_relative */
|
---|
159 | 0, /* bitpos */
|
---|
160 | complain_overflow_dont, /* complain_on_overflow */
|
---|
161 | reloc_nil, /* special_function */
|
---|
162 | "IGNORE", /* name */
|
---|
163 | true, /* partial_inplace */
|
---|
164 | 0, /* src_mask */
|
---|
165 | 0, /* dst_mask */
|
---|
166 | true), /* pcrel_offset */
|
---|
167 |
|
---|
168 | /* A 32 bit reference to a symbol. */
|
---|
169 | HOWTO (ALPHA_R_REFLONG, /* type */
|
---|
170 | 0, /* rightshift */
|
---|
171 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
172 | 32, /* bitsize */
|
---|
173 | false, /* pc_relative */
|
---|
174 | 0, /* bitpos */
|
---|
175 | complain_overflow_bitfield, /* complain_on_overflow */
|
---|
176 | 0, /* special_function */
|
---|
177 | "REFLONG", /* name */
|
---|
178 | true, /* partial_inplace */
|
---|
179 | 0xffffffff, /* src_mask */
|
---|
180 | 0xffffffff, /* dst_mask */
|
---|
181 | false), /* pcrel_offset */
|
---|
182 |
|
---|
183 | /* A 64 bit reference to a symbol. */
|
---|
184 | HOWTO (ALPHA_R_REFQUAD, /* type */
|
---|
185 | 0, /* rightshift */
|
---|
186 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
187 | 64, /* bitsize */
|
---|
188 | false, /* pc_relative */
|
---|
189 | 0, /* bitpos */
|
---|
190 | complain_overflow_bitfield, /* complain_on_overflow */
|
---|
191 | 0, /* special_function */
|
---|
192 | "REFQUAD", /* name */
|
---|
193 | true, /* partial_inplace */
|
---|
194 | MINUS_ONE, /* src_mask */
|
---|
195 | MINUS_ONE, /* dst_mask */
|
---|
196 | false), /* pcrel_offset */
|
---|
197 |
|
---|
198 | /* A 32 bit GP relative offset. This is just like REFLONG except
|
---|
199 | that when the value is used the value of the gp register will be
|
---|
200 | added in. */
|
---|
201 | HOWTO (ALPHA_R_GPREL32, /* type */
|
---|
202 | 0, /* rightshift */
|
---|
203 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
204 | 32, /* bitsize */
|
---|
205 | false, /* pc_relative */
|
---|
206 | 0, /* bitpos */
|
---|
207 | complain_overflow_bitfield, /* complain_on_overflow */
|
---|
208 | 0, /* special_function */
|
---|
209 | "GPREL32", /* name */
|
---|
210 | true, /* partial_inplace */
|
---|
211 | 0xffffffff, /* src_mask */
|
---|
212 | 0xffffffff, /* dst_mask */
|
---|
213 | false), /* pcrel_offset */
|
---|
214 |
|
---|
215 | /* Used for an instruction that refers to memory off the GP
|
---|
216 | register. The offset is 16 bits of the 32 bit instruction. This
|
---|
217 | reloc always seems to be against the .lita section. */
|
---|
218 | HOWTO (ALPHA_R_LITERAL, /* type */
|
---|
219 | 0, /* rightshift */
|
---|
220 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
221 | 16, /* bitsize */
|
---|
222 | false, /* pc_relative */
|
---|
223 | 0, /* bitpos */
|
---|
224 | complain_overflow_signed, /* complain_on_overflow */
|
---|
225 | 0, /* special_function */
|
---|
226 | "LITERAL", /* name */
|
---|
227 | true, /* partial_inplace */
|
---|
228 | 0xffff, /* src_mask */
|
---|
229 | 0xffff, /* dst_mask */
|
---|
230 | false), /* pcrel_offset */
|
---|
231 |
|
---|
232 | /* This reloc only appears immediately following a LITERAL reloc.
|
---|
233 | It identifies a use of the literal. It seems that the linker can
|
---|
234 | use this to eliminate a portion of the .lita section. The symbol
|
---|
235 | index is special: 1 means the literal address is in the base
|
---|
236 | register of a memory format instruction; 2 means the literal
|
---|
237 | address is in the byte offset register of a byte-manipulation
|
---|
238 | instruction; 3 means the literal address is in the target
|
---|
239 | register of a jsr instruction. This does not actually do any
|
---|
240 | relocation. */
|
---|
241 | HOWTO (ALPHA_R_LITUSE, /* type */
|
---|
242 | 0, /* rightshift */
|
---|
243 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
244 | 32, /* bitsize */
|
---|
245 | false, /* pc_relative */
|
---|
246 | 0, /* bitpos */
|
---|
247 | complain_overflow_dont, /* complain_on_overflow */
|
---|
248 | reloc_nil, /* special_function */
|
---|
249 | "LITUSE", /* name */
|
---|
250 | false, /* partial_inplace */
|
---|
251 | 0, /* src_mask */
|
---|
252 | 0, /* dst_mask */
|
---|
253 | false), /* pcrel_offset */
|
---|
254 |
|
---|
255 | /* Load the gp register. This is always used for a ldah instruction
|
---|
256 | which loads the upper 16 bits of the gp register. The next reloc
|
---|
257 | will be an IGNORE reloc which identifies the location of the lda
|
---|
258 | instruction which loads the lower 16 bits. The symbol index of
|
---|
259 | the GPDISP instruction appears to actually be the number of bytes
|
---|
260 | between the ldah and lda instructions. This gives two different
|
---|
261 | ways to determine where the lda instruction is; I don't know why
|
---|
262 | both are used. The value to use for the relocation is the
|
---|
263 | difference between the GP value and the current location; the
|
---|
264 | load will always be done against a register holding the current
|
---|
265 | address. */
|
---|
266 | HOWTO (ALPHA_R_GPDISP, /* type */
|
---|
267 | 16, /* rightshift */
|
---|
268 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
269 | 16, /* bitsize */
|
---|
270 | true, /* pc_relative */
|
---|
271 | 0, /* bitpos */
|
---|
272 | complain_overflow_dont, /* complain_on_overflow */
|
---|
273 | reloc_nil, /* special_function */
|
---|
274 | "GPDISP", /* name */
|
---|
275 | true, /* partial_inplace */
|
---|
276 | 0xffff, /* src_mask */
|
---|
277 | 0xffff, /* dst_mask */
|
---|
278 | true), /* pcrel_offset */
|
---|
279 |
|
---|
280 | /* A 21 bit branch. The native assembler generates these for
|
---|
281 | branches within the text segment, and also fills in the PC
|
---|
282 | relative offset in the instruction. */
|
---|
283 | HOWTO (ALPHA_R_BRADDR, /* type */
|
---|
284 | 2, /* rightshift */
|
---|
285 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
286 | 21, /* bitsize */
|
---|
287 | true, /* pc_relative */
|
---|
288 | 0, /* bitpos */
|
---|
289 | complain_overflow_signed, /* complain_on_overflow */
|
---|
290 | 0, /* special_function */
|
---|
291 | "BRADDR", /* name */
|
---|
292 | true, /* partial_inplace */
|
---|
293 | 0x1fffff, /* src_mask */
|
---|
294 | 0x1fffff, /* dst_mask */
|
---|
295 | false), /* pcrel_offset */
|
---|
296 |
|
---|
297 | /* A hint for a jump to a register. */
|
---|
298 | HOWTO (ALPHA_R_HINT, /* type */
|
---|
299 | 2, /* rightshift */
|
---|
300 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
301 | 14, /* bitsize */
|
---|
302 | true, /* pc_relative */
|
---|
303 | 0, /* bitpos */
|
---|
304 | complain_overflow_dont, /* complain_on_overflow */
|
---|
305 | 0, /* special_function */
|
---|
306 | "HINT", /* name */
|
---|
307 | true, /* partial_inplace */
|
---|
308 | 0x3fff, /* src_mask */
|
---|
309 | 0x3fff, /* dst_mask */
|
---|
310 | false), /* pcrel_offset */
|
---|
311 |
|
---|
312 | /* 16 bit PC relative offset. */
|
---|
313 | HOWTO (ALPHA_R_SREL16, /* type */
|
---|
314 | 0, /* rightshift */
|
---|
315 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
316 | 16, /* bitsize */
|
---|
317 | true, /* pc_relative */
|
---|
318 | 0, /* bitpos */
|
---|
319 | complain_overflow_signed, /* complain_on_overflow */
|
---|
320 | 0, /* special_function */
|
---|
321 | "SREL16", /* name */
|
---|
322 | true, /* partial_inplace */
|
---|
323 | 0xffff, /* src_mask */
|
---|
324 | 0xffff, /* dst_mask */
|
---|
325 | false), /* pcrel_offset */
|
---|
326 |
|
---|
327 | /* 32 bit PC relative offset. */
|
---|
328 | HOWTO (ALPHA_R_SREL32, /* type */
|
---|
329 | 0, /* rightshift */
|
---|
330 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
331 | 32, /* bitsize */
|
---|
332 | true, /* pc_relative */
|
---|
333 | 0, /* bitpos */
|
---|
334 | complain_overflow_signed, /* complain_on_overflow */
|
---|
335 | 0, /* special_function */
|
---|
336 | "SREL32", /* name */
|
---|
337 | true, /* partial_inplace */
|
---|
338 | 0xffffffff, /* src_mask */
|
---|
339 | 0xffffffff, /* dst_mask */
|
---|
340 | false), /* pcrel_offset */
|
---|
341 |
|
---|
342 | /* A 64 bit PC relative offset. */
|
---|
343 | HOWTO (ALPHA_R_SREL64, /* type */
|
---|
344 | 0, /* rightshift */
|
---|
345 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
346 | 64, /* bitsize */
|
---|
347 | true, /* pc_relative */
|
---|
348 | 0, /* bitpos */
|
---|
349 | complain_overflow_signed, /* complain_on_overflow */
|
---|
350 | 0, /* special_function */
|
---|
351 | "SREL64", /* name */
|
---|
352 | true, /* partial_inplace */
|
---|
353 | MINUS_ONE, /* src_mask */
|
---|
354 | MINUS_ONE, /* dst_mask */
|
---|
355 | false), /* pcrel_offset */
|
---|
356 |
|
---|
357 | /* Push a value on the reloc evaluation stack. */
|
---|
358 | HOWTO (ALPHA_R_OP_PUSH, /* type */
|
---|
359 | 0, /* rightshift */
|
---|
360 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
361 | 0, /* bitsize */
|
---|
362 | false, /* pc_relative */
|
---|
363 | 0, /* bitpos */
|
---|
364 | complain_overflow_dont, /* complain_on_overflow */
|
---|
365 | 0, /* special_function */
|
---|
366 | "OP_PUSH", /* name */
|
---|
367 | false, /* partial_inplace */
|
---|
368 | 0, /* src_mask */
|
---|
369 | 0, /* dst_mask */
|
---|
370 | false), /* pcrel_offset */
|
---|
371 |
|
---|
372 | /* Store the value from the stack at the given address. Store it in
|
---|
373 | a bitfield of size r_size starting at bit position r_offset. */
|
---|
374 | HOWTO (ALPHA_R_OP_STORE, /* type */
|
---|
375 | 0, /* rightshift */
|
---|
376 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
377 | 64, /* bitsize */
|
---|
378 | false, /* pc_relative */
|
---|
379 | 0, /* bitpos */
|
---|
380 | complain_overflow_dont, /* complain_on_overflow */
|
---|
381 | 0, /* special_function */
|
---|
382 | "OP_STORE", /* name */
|
---|
383 | false, /* partial_inplace */
|
---|
384 | 0, /* src_mask */
|
---|
385 | MINUS_ONE, /* dst_mask */
|
---|
386 | false), /* pcrel_offset */
|
---|
387 |
|
---|
388 | /* Subtract the reloc address from the value on the top of the
|
---|
389 | relocation stack. */
|
---|
390 | HOWTO (ALPHA_R_OP_PSUB, /* type */
|
---|
391 | 0, /* rightshift */
|
---|
392 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
393 | 0, /* bitsize */
|
---|
394 | false, /* pc_relative */
|
---|
395 | 0, /* bitpos */
|
---|
396 | complain_overflow_dont, /* complain_on_overflow */
|
---|
397 | 0, /* special_function */
|
---|
398 | "OP_PSUB", /* name */
|
---|
399 | false, /* partial_inplace */
|
---|
400 | 0, /* src_mask */
|
---|
401 | 0, /* dst_mask */
|
---|
402 | false), /* pcrel_offset */
|
---|
403 |
|
---|
404 | /* Shift the value on the top of the relocation stack right by the
|
---|
405 | given value. */
|
---|
406 | HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
|
---|
407 | 0, /* rightshift */
|
---|
408 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
409 | 0, /* bitsize */
|
---|
410 | false, /* pc_relative */
|
---|
411 | 0, /* bitpos */
|
---|
412 | complain_overflow_dont, /* complain_on_overflow */
|
---|
413 | 0, /* special_function */
|
---|
414 | "OP_PRSHIFT", /* name */
|
---|
415 | false, /* partial_inplace */
|
---|
416 | 0, /* src_mask */
|
---|
417 | 0, /* dst_mask */
|
---|
418 | false), /* pcrel_offset */
|
---|
419 |
|
---|
420 | /* Adjust the GP value for a new range in the object file. */
|
---|
421 | HOWTO (ALPHA_R_GPVALUE, /* type */
|
---|
422 | 0, /* rightshift */
|
---|
423 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
424 | 0, /* bitsize */
|
---|
425 | false, /* pc_relative */
|
---|
426 | 0, /* bitpos */
|
---|
427 | complain_overflow_dont, /* complain_on_overflow */
|
---|
428 | 0, /* special_function */
|
---|
429 | "GPVALUE", /* name */
|
---|
430 | false, /* partial_inplace */
|
---|
431 | 0, /* src_mask */
|
---|
432 | 0, /* dst_mask */
|
---|
433 | false) /* pcrel_offset */
|
---|
434 | };
|
---|
435 | |
---|
436 |
|
---|
437 | /* Recognize an Alpha ECOFF file. */
|
---|
438 |
|
---|
439 | static const bfd_target *
|
---|
440 | alpha_ecoff_object_p (abfd)
|
---|
441 | bfd *abfd;
|
---|
442 | {
|
---|
443 | static const bfd_target *ret;
|
---|
444 |
|
---|
445 | ret = coff_object_p (abfd);
|
---|
446 |
|
---|
447 | if (ret != NULL)
|
---|
448 | {
|
---|
449 | asection *sec;
|
---|
450 |
|
---|
451 | /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
|
---|
452 | .pdata section is the number of entries it contains. Each
|
---|
453 | entry takes up 8 bytes. The number of entries is required
|
---|
454 | since the section is aligned to a 16 byte boundary. When we
|
---|
455 | link .pdata sections together, we do not want to include the
|
---|
456 | alignment bytes. We handle this on input by faking the size
|
---|
457 | of the .pdata section to remove the unwanted alignment bytes.
|
---|
458 | On output we will set the lnnoptr field and force the
|
---|
459 | alignment. */
|
---|
460 | sec = bfd_get_section_by_name (abfd, _PDATA);
|
---|
461 | if (sec != (asection *) NULL)
|
---|
462 | {
|
---|
463 | bfd_size_type size;
|
---|
464 |
|
---|
465 | size = sec->line_filepos * 8;
|
---|
466 | BFD_ASSERT (size == bfd_section_size (abfd, sec)
|
---|
467 | || size + 8 == bfd_section_size (abfd, sec));
|
---|
468 | if (! bfd_set_section_size (abfd, sec, size))
|
---|
469 | return NULL;
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 | return ret;
|
---|
474 | }
|
---|
475 |
|
---|
476 | /* See whether the magic number matches. */
|
---|
477 |
|
---|
478 | static boolean
|
---|
479 | alpha_ecoff_bad_format_hook (abfd, filehdr)
|
---|
480 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
481 | PTR filehdr;
|
---|
482 | {
|
---|
483 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
|
---|
484 |
|
---|
485 | if (ALPHA_ECOFF_BADMAG (*internal_f))
|
---|
486 | return false;
|
---|
487 |
|
---|
488 | return true;
|
---|
489 | }
|
---|
490 |
|
---|
491 | /* This is a hook called by coff_real_object_p to create any backend
|
---|
492 | specific information. */
|
---|
493 |
|
---|
494 | static PTR
|
---|
495 | alpha_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
|
---|
496 | bfd *abfd;
|
---|
497 | PTR filehdr;
|
---|
498 | PTR aouthdr;
|
---|
499 | {
|
---|
500 | PTR ecoff;
|
---|
501 |
|
---|
502 | ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
|
---|
503 |
|
---|
504 | if (ecoff != NULL)
|
---|
505 | {
|
---|
506 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
|
---|
507 |
|
---|
508 | /* Set additional BFD flags according to the object type from the
|
---|
509 | machine specific file header flags. */
|
---|
510 | switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
|
---|
511 | {
|
---|
512 | case F_ALPHA_SHARABLE:
|
---|
513 | abfd->flags |= DYNAMIC;
|
---|
514 | break;
|
---|
515 | case F_ALPHA_CALL_SHARED:
|
---|
516 | /* Always executable if using shared libraries as the run time
|
---|
517 | loader might resolve undefined references. */
|
---|
518 | abfd->flags |= (DYNAMIC | EXEC_P);
|
---|
519 | break;
|
---|
520 | }
|
---|
521 | }
|
---|
522 | return ecoff;
|
---|
523 | }
|
---|
524 | |
---|
525 |
|
---|
526 | /* Reloc handling. */
|
---|
527 |
|
---|
528 | /* Swap a reloc in. */
|
---|
529 |
|
---|
530 | static void
|
---|
531 | alpha_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
|
---|
532 | bfd *abfd;
|
---|
533 | PTR ext_ptr;
|
---|
534 | struct internal_reloc *intern;
|
---|
535 | {
|
---|
536 | const RELOC *ext = (RELOC *) ext_ptr;
|
---|
537 |
|
---|
538 | intern->r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext->r_vaddr);
|
---|
539 | intern->r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_symndx);
|
---|
540 |
|
---|
541 | BFD_ASSERT (bfd_header_little_endian (abfd));
|
---|
542 |
|
---|
543 | intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
|
---|
544 | >> RELOC_BITS0_TYPE_SH_LITTLE);
|
---|
545 | intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
|
---|
546 | intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
|
---|
547 | >> RELOC_BITS1_OFFSET_SH_LITTLE);
|
---|
548 | /* Ignored the reserved bits. */
|
---|
549 | intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
|
---|
550 | >> RELOC_BITS3_SIZE_SH_LITTLE);
|
---|
551 |
|
---|
552 | if (intern->r_type == ALPHA_R_LITUSE
|
---|
553 | || intern->r_type == ALPHA_R_GPDISP)
|
---|
554 | {
|
---|
555 | /* Handle the LITUSE and GPDISP relocs specially. Its symndx
|
---|
556 | value is not actually a symbol index, but is instead a
|
---|
557 | special code. We put the code in the r_size field, and
|
---|
558 | clobber the symndx. */
|
---|
559 | if (intern->r_size != 0)
|
---|
560 | abort ();
|
---|
561 | intern->r_size = intern->r_symndx;
|
---|
562 | intern->r_symndx = RELOC_SECTION_NONE;
|
---|
563 | }
|
---|
564 | else if (intern->r_type == ALPHA_R_IGNORE)
|
---|
565 | {
|
---|
566 | /* The IGNORE reloc generally follows a GPDISP reloc, and is
|
---|
567 | against the .lita section. The section is irrelevant. */
|
---|
568 | if (! intern->r_extern &&
|
---|
569 | intern->r_symndx == RELOC_SECTION_ABS)
|
---|
570 | abort ();
|
---|
571 | if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA)
|
---|
572 | intern->r_symndx = RELOC_SECTION_ABS;
|
---|
573 | }
|
---|
574 | }
|
---|
575 |
|
---|
576 | /* Swap a reloc out. */
|
---|
577 |
|
---|
578 | static void
|
---|
579 | alpha_ecoff_swap_reloc_out (abfd, intern, dst)
|
---|
580 | bfd *abfd;
|
---|
581 | const struct internal_reloc *intern;
|
---|
582 | PTR dst;
|
---|
583 | {
|
---|
584 | RELOC *ext = (RELOC *) dst;
|
---|
585 | long symndx;
|
---|
586 | unsigned char size;
|
---|
587 |
|
---|
588 | /* Undo the hackery done in swap_reloc_in. */
|
---|
589 | if (intern->r_type == ALPHA_R_LITUSE
|
---|
590 | || intern->r_type == ALPHA_R_GPDISP)
|
---|
591 | {
|
---|
592 | symndx = intern->r_size;
|
---|
593 | size = 0;
|
---|
594 | }
|
---|
595 | else if (intern->r_type == ALPHA_R_IGNORE
|
---|
596 | && ! intern->r_extern
|
---|
597 | && intern->r_symndx == RELOC_SECTION_ABS)
|
---|
598 | {
|
---|
599 | symndx = RELOC_SECTION_LITA;
|
---|
600 | size = intern->r_size;
|
---|
601 | }
|
---|
602 | else
|
---|
603 | {
|
---|
604 | symndx = intern->r_symndx;
|
---|
605 | size = intern->r_size;
|
---|
606 | }
|
---|
607 |
|
---|
608 | BFD_ASSERT (intern->r_extern
|
---|
609 | || (intern->r_symndx >= 0 && intern->r_symndx <= 14));
|
---|
610 |
|
---|
611 | bfd_h_put_64 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
|
---|
612 | bfd_h_put_32 (abfd, symndx, (bfd_byte *) ext->r_symndx);
|
---|
613 |
|
---|
614 | BFD_ASSERT (bfd_header_little_endian (abfd));
|
---|
615 |
|
---|
616 | ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE)
|
---|
617 | & RELOC_BITS0_TYPE_LITTLE);
|
---|
618 | ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
|
---|
619 | | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
|
---|
620 | & RELOC_BITS1_OFFSET_LITTLE));
|
---|
621 | ext->r_bits[2] = 0;
|
---|
622 | ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE)
|
---|
623 | & RELOC_BITS3_SIZE_LITTLE);
|
---|
624 | }
|
---|
625 |
|
---|
626 | /* Finish canonicalizing a reloc. Part of this is generic to all
|
---|
627 | ECOFF targets, and that part is in ecoff.c. The rest is done in
|
---|
628 | this backend routine. It must fill in the howto field. */
|
---|
629 |
|
---|
630 | static void
|
---|
631 | alpha_adjust_reloc_in (abfd, intern, rptr)
|
---|
632 | bfd *abfd;
|
---|
633 | const struct internal_reloc *intern;
|
---|
634 | arelent *rptr;
|
---|
635 | {
|
---|
636 | if (intern->r_type > ALPHA_R_GPVALUE)
|
---|
637 | abort ();
|
---|
638 |
|
---|
639 | switch (intern->r_type)
|
---|
640 | {
|
---|
641 | case ALPHA_R_BRADDR:
|
---|
642 | case ALPHA_R_SREL16:
|
---|
643 | case ALPHA_R_SREL32:
|
---|
644 | case ALPHA_R_SREL64:
|
---|
645 | /* This relocs appear to be fully resolved when they are against
|
---|
646 | internal symbols. Against external symbols, BRADDR at least
|
---|
647 | appears to be resolved against the next instruction. */
|
---|
648 | if (! intern->r_extern)
|
---|
649 | rptr->addend = 0;
|
---|
650 | else
|
---|
651 | rptr->addend = - (intern->r_vaddr + 4);
|
---|
652 | break;
|
---|
653 |
|
---|
654 | case ALPHA_R_GPREL32:
|
---|
655 | case ALPHA_R_LITERAL:
|
---|
656 | /* Copy the gp value for this object file into the addend, to
|
---|
657 | ensure that we are not confused by the linker. */
|
---|
658 | if (! intern->r_extern)
|
---|
659 | rptr->addend += ecoff_data (abfd)->gp;
|
---|
660 | break;
|
---|
661 |
|
---|
662 | case ALPHA_R_LITUSE:
|
---|
663 | case ALPHA_R_GPDISP:
|
---|
664 | /* The LITUSE and GPDISP relocs do not use a symbol, or an
|
---|
665 | addend, but they do use a special code. Put this code in the
|
---|
666 | addend field. */
|
---|
667 | rptr->addend = intern->r_size;
|
---|
668 | break;
|
---|
669 |
|
---|
670 | case ALPHA_R_OP_STORE:
|
---|
671 | /* The STORE reloc needs the size and offset fields. We store
|
---|
672 | them in the addend. */
|
---|
673 | BFD_ASSERT (intern->r_offset <= 256 && intern->r_size <= 256);
|
---|
674 | rptr->addend = (intern->r_offset << 8) + intern->r_size;
|
---|
675 | break;
|
---|
676 |
|
---|
677 | case ALPHA_R_OP_PUSH:
|
---|
678 | case ALPHA_R_OP_PSUB:
|
---|
679 | case ALPHA_R_OP_PRSHIFT:
|
---|
680 | /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
|
---|
681 | address. I believe that the address supplied is really an
|
---|
682 | addend. */
|
---|
683 | rptr->addend = intern->r_vaddr;
|
---|
684 | break;
|
---|
685 |
|
---|
686 | case ALPHA_R_GPVALUE:
|
---|
687 | /* Set the addend field to the new GP value. */
|
---|
688 | rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp;
|
---|
689 | break;
|
---|
690 |
|
---|
691 | case ALPHA_R_IGNORE:
|
---|
692 | /* If the type is ALPHA_R_IGNORE, make sure this is a reference
|
---|
693 | to the absolute section so that the reloc is ignored. For
|
---|
694 | some reason the address of this reloc type is not adjusted by
|
---|
695 | the section vma. We record the gp value for this object file
|
---|
696 | here, for convenience when doing the GPDISP relocation. */
|
---|
697 | rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
---|
698 | rptr->address = intern->r_vaddr;
|
---|
699 | rptr->addend = ecoff_data (abfd)->gp;
|
---|
700 | break;
|
---|
701 |
|
---|
702 | default:
|
---|
703 | break;
|
---|
704 | }
|
---|
705 |
|
---|
706 | rptr->howto = &alpha_howto_table[intern->r_type];
|
---|
707 | }
|
---|
708 |
|
---|
709 | /* When writing out a reloc we need to pull some values back out of
|
---|
710 | the addend field into the reloc. This is roughly the reverse of
|
---|
711 | alpha_adjust_reloc_in, except that there are several changes we do
|
---|
712 | not need to undo. */
|
---|
713 |
|
---|
714 | static void
|
---|
715 | alpha_adjust_reloc_out (abfd, rel, intern)
|
---|
716 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
717 | const arelent *rel;
|
---|
718 | struct internal_reloc *intern;
|
---|
719 | {
|
---|
720 | switch (intern->r_type)
|
---|
721 | {
|
---|
722 | case ALPHA_R_LITUSE:
|
---|
723 | case ALPHA_R_GPDISP:
|
---|
724 | intern->r_size = rel->addend;
|
---|
725 | break;
|
---|
726 |
|
---|
727 | case ALPHA_R_OP_STORE:
|
---|
728 | intern->r_size = rel->addend & 0xff;
|
---|
729 | intern->r_offset = (rel->addend >> 8) & 0xff;
|
---|
730 | break;
|
---|
731 |
|
---|
732 | case ALPHA_R_OP_PUSH:
|
---|
733 | case ALPHA_R_OP_PSUB:
|
---|
734 | case ALPHA_R_OP_PRSHIFT:
|
---|
735 | intern->r_vaddr = rel->addend;
|
---|
736 | break;
|
---|
737 |
|
---|
738 | case ALPHA_R_IGNORE:
|
---|
739 | intern->r_vaddr = rel->address;
|
---|
740 | break;
|
---|
741 |
|
---|
742 | default:
|
---|
743 | break;
|
---|
744 | }
|
---|
745 | }
|
---|
746 |
|
---|
747 | /* The size of the stack for the relocation evaluator. */
|
---|
748 | #define RELOC_STACKSIZE (10)
|
---|
749 |
|
---|
750 | /* Alpha ECOFF relocs have a built in expression evaluator as well as
|
---|
751 | other interdependencies. Rather than use a bunch of special
|
---|
752 | functions and global variables, we use a single routine to do all
|
---|
753 | the relocation for a section. I haven't yet worked out how the
|
---|
754 | assembler is going to handle this. */
|
---|
755 |
|
---|
756 | static bfd_byte *
|
---|
757 | alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
|
---|
758 | data, relocateable, symbols)
|
---|
759 | bfd *abfd;
|
---|
760 | struct bfd_link_info *link_info;
|
---|
761 | struct bfd_link_order *link_order;
|
---|
762 | bfd_byte *data;
|
---|
763 | boolean relocateable;
|
---|
764 | asymbol **symbols;
|
---|
765 | {
|
---|
766 | bfd *input_bfd = link_order->u.indirect.section->owner;
|
---|
767 | asection *input_section = link_order->u.indirect.section;
|
---|
768 | long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
|
---|
769 | arelent **reloc_vector = NULL;
|
---|
770 | long reloc_count;
|
---|
771 | bfd *output_bfd = relocateable ? abfd : (bfd *) NULL;
|
---|
772 | bfd_vma gp;
|
---|
773 | boolean gp_undefined;
|
---|
774 | bfd_vma stack[RELOC_STACKSIZE];
|
---|
775 | int tos = 0;
|
---|
776 |
|
---|
777 | if (reloc_size < 0)
|
---|
778 | goto error_return;
|
---|
779 | reloc_vector = (arelent **) bfd_malloc (reloc_size);
|
---|
780 | if (reloc_vector == NULL && reloc_size != 0)
|
---|
781 | goto error_return;
|
---|
782 |
|
---|
783 | if (! bfd_get_section_contents (input_bfd, input_section, data,
|
---|
784 | (file_ptr) 0, input_section->_raw_size))
|
---|
785 | goto error_return;
|
---|
786 |
|
---|
787 | /* The section size is not going to change. */
|
---|
788 | input_section->_cooked_size = input_section->_raw_size;
|
---|
789 | input_section->reloc_done = true;
|
---|
790 |
|
---|
791 | reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
|
---|
792 | reloc_vector, symbols);
|
---|
793 | if (reloc_count < 0)
|
---|
794 | goto error_return;
|
---|
795 | if (reloc_count == 0)
|
---|
796 | goto successful_return;
|
---|
797 |
|
---|
798 | /* Get the GP value for the output BFD. */
|
---|
799 | gp_undefined = false;
|
---|
800 | gp = _bfd_get_gp_value (abfd);
|
---|
801 | if (gp == 0)
|
---|
802 | {
|
---|
803 | if (relocateable != false)
|
---|
804 | {
|
---|
805 | asection *sec;
|
---|
806 | bfd_vma lo;
|
---|
807 |
|
---|
808 | /* Make up a value. */
|
---|
809 | lo = (bfd_vma) -1;
|
---|
810 | for (sec = abfd->sections; sec != NULL; sec = sec->next)
|
---|
811 | {
|
---|
812 | if (sec->vma < lo
|
---|
813 | && (strcmp (sec->name, ".sbss") == 0
|
---|
814 | || strcmp (sec->name, ".sdata") == 0
|
---|
815 | || strcmp (sec->name, ".lit4") == 0
|
---|
816 | || strcmp (sec->name, ".lit8") == 0
|
---|
817 | || strcmp (sec->name, ".lita") == 0))
|
---|
818 | lo = sec->vma;
|
---|
819 | }
|
---|
820 | gp = lo + 0x8000;
|
---|
821 | _bfd_set_gp_value (abfd, gp);
|
---|
822 | }
|
---|
823 | else
|
---|
824 | {
|
---|
825 | struct bfd_link_hash_entry *h;
|
---|
826 |
|
---|
827 | h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false,
|
---|
828 | true);
|
---|
829 | if (h == (struct bfd_link_hash_entry *) NULL
|
---|
830 | || h->type != bfd_link_hash_defined)
|
---|
831 | gp_undefined = true;
|
---|
832 | else
|
---|
833 | {
|
---|
834 | gp = (h->u.def.value
|
---|
835 | + h->u.def.section->output_section->vma
|
---|
836 | + h->u.def.section->output_offset);
|
---|
837 | _bfd_set_gp_value (abfd, gp);
|
---|
838 | }
|
---|
839 | }
|
---|
840 | }
|
---|
841 |
|
---|
842 | for (; *reloc_vector != (arelent *) NULL; reloc_vector++)
|
---|
843 | {
|
---|
844 | arelent *rel;
|
---|
845 | bfd_reloc_status_type r;
|
---|
846 | char *err;
|
---|
847 |
|
---|
848 | rel = *reloc_vector;
|
---|
849 | r = bfd_reloc_ok;
|
---|
850 | switch (rel->howto->type)
|
---|
851 | {
|
---|
852 | case ALPHA_R_IGNORE:
|
---|
853 | rel->address += input_section->output_offset;
|
---|
854 | break;
|
---|
855 |
|
---|
856 | case ALPHA_R_REFLONG:
|
---|
857 | case ALPHA_R_REFQUAD:
|
---|
858 | case ALPHA_R_BRADDR:
|
---|
859 | case ALPHA_R_HINT:
|
---|
860 | case ALPHA_R_SREL16:
|
---|
861 | case ALPHA_R_SREL32:
|
---|
862 | case ALPHA_R_SREL64:
|
---|
863 | if (relocateable
|
---|
864 | && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
|
---|
865 | {
|
---|
866 | rel->address += input_section->output_offset;
|
---|
867 | break;
|
---|
868 | }
|
---|
869 | r = bfd_perform_relocation (input_bfd, rel, data, input_section,
|
---|
870 | output_bfd, &err);
|
---|
871 | break;
|
---|
872 |
|
---|
873 | case ALPHA_R_GPREL32:
|
---|
874 | /* This relocation is used in a switch table. It is a 32
|
---|
875 | bit offset from the current GP value. We must adjust it
|
---|
876 | by the different between the original GP value and the
|
---|
877 | current GP value. The original GP value is stored in the
|
---|
878 | addend. We adjust the addend and let
|
---|
879 | bfd_perform_relocation finish the job. */
|
---|
880 | rel->addend -= gp;
|
---|
881 | r = bfd_perform_relocation (input_bfd, rel, data, input_section,
|
---|
882 | output_bfd, &err);
|
---|
883 | if (r == bfd_reloc_ok && gp_undefined)
|
---|
884 | {
|
---|
885 | r = bfd_reloc_dangerous;
|
---|
886 | err = (char *) _("GP relative relocation used when GP not defined");
|
---|
887 | }
|
---|
888 | break;
|
---|
889 |
|
---|
890 | case ALPHA_R_LITERAL:
|
---|
891 | /* This is a reference to a literal value, generally
|
---|
892 | (always?) in the .lita section. This is a 16 bit GP
|
---|
893 | relative relocation. Sometimes the subsequent reloc is a
|
---|
894 | LITUSE reloc, which indicates how this reloc is used.
|
---|
895 | This sometimes permits rewriting the two instructions
|
---|
896 | referred to by the LITERAL and the LITUSE into different
|
---|
897 | instructions which do not refer to .lita. This can save
|
---|
898 | a memory reference, and permits removing a value from
|
---|
899 | .lita thus saving GP relative space.
|
---|
900 |
|
---|
901 | We do not these optimizations. To do them we would need
|
---|
902 | to arrange to link the .lita section first, so that by
|
---|
903 | the time we got here we would know the final values to
|
---|
904 | use. This would not be particularly difficult, but it is
|
---|
905 | not currently implemented. */
|
---|
906 |
|
---|
907 | {
|
---|
908 | unsigned long insn;
|
---|
909 |
|
---|
910 | /* I believe that the LITERAL reloc will only apply to a
|
---|
911 | ldq or ldl instruction, so check my assumption. */
|
---|
912 | insn = bfd_get_32 (input_bfd, data + rel->address);
|
---|
913 | BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
|
---|
914 | || ((insn >> 26) & 0x3f) == 0x28);
|
---|
915 |
|
---|
916 | rel->addend -= gp;
|
---|
917 | r = bfd_perform_relocation (input_bfd, rel, data, input_section,
|
---|
918 | output_bfd, &err);
|
---|
919 | if (r == bfd_reloc_ok && gp_undefined)
|
---|
920 | {
|
---|
921 | r = bfd_reloc_dangerous;
|
---|
922 | err =
|
---|
923 | (char *) _("GP relative relocation used when GP not defined");
|
---|
924 | }
|
---|
925 | }
|
---|
926 | break;
|
---|
927 |
|
---|
928 | case ALPHA_R_LITUSE:
|
---|
929 | /* See ALPHA_R_LITERAL above for the uses of this reloc. It
|
---|
930 | does not cause anything to happen, itself. */
|
---|
931 | rel->address += input_section->output_offset;
|
---|
932 | break;
|
---|
933 |
|
---|
934 | case ALPHA_R_GPDISP:
|
---|
935 | /* This marks the ldah of an ldah/lda pair which loads the
|
---|
936 | gp register with the difference of the gp value and the
|
---|
937 | current location. The second of the pair is r_size bytes
|
---|
938 | ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
|
---|
939 | but that no longer happens in OSF/1 3.2. */
|
---|
940 | {
|
---|
941 | unsigned long insn1, insn2;
|
---|
942 | bfd_vma addend;
|
---|
943 |
|
---|
944 | /* Get the two instructions. */
|
---|
945 | insn1 = bfd_get_32 (input_bfd, data + rel->address);
|
---|
946 | insn2 = bfd_get_32 (input_bfd, data + rel->address + rel->addend);
|
---|
947 |
|
---|
948 | BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
|
---|
949 | BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
|
---|
950 |
|
---|
951 | /* Get the existing addend. We must account for the sign
|
---|
952 | extension done by lda and ldah. */
|
---|
953 | addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
|
---|
954 | if (insn1 & 0x8000)
|
---|
955 | {
|
---|
956 | addend -= 0x80000000;
|
---|
957 | addend -= 0x80000000;
|
---|
958 | }
|
---|
959 | if (insn2 & 0x8000)
|
---|
960 | addend -= 0x10000;
|
---|
961 |
|
---|
962 | /* The existing addend includes the different between the
|
---|
963 | gp of the input BFD and the address in the input BFD.
|
---|
964 | Subtract this out. */
|
---|
965 | addend -= (ecoff_data (input_bfd)->gp
|
---|
966 | - (input_section->vma + rel->address));
|
---|
967 |
|
---|
968 | /* Now add in the final gp value, and subtract out the
|
---|
969 | final address. */
|
---|
970 | addend += (gp
|
---|
971 | - (input_section->output_section->vma
|
---|
972 | + input_section->output_offset
|
---|
973 | + rel->address));
|
---|
974 |
|
---|
975 | /* Change the instructions, accounting for the sign
|
---|
976 | extension, and write them out. */
|
---|
977 | if (addend & 0x8000)
|
---|
978 | addend += 0x10000;
|
---|
979 | insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
|
---|
980 | insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
|
---|
981 |
|
---|
982 | bfd_put_32 (input_bfd, (bfd_vma) insn1, data + rel->address);
|
---|
983 | bfd_put_32 (input_bfd, (bfd_vma) insn2,
|
---|
984 | data + rel->address + rel->addend);
|
---|
985 |
|
---|
986 | rel->address += input_section->output_offset;
|
---|
987 | }
|
---|
988 | break;
|
---|
989 |
|
---|
990 | case ALPHA_R_OP_PUSH:
|
---|
991 | /* Push a value on the reloc evaluation stack. */
|
---|
992 | {
|
---|
993 | asymbol *symbol;
|
---|
994 | bfd_vma relocation;
|
---|
995 |
|
---|
996 | if (relocateable)
|
---|
997 | {
|
---|
998 | rel->address += input_section->output_offset;
|
---|
999 | break;
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | /* Figure out the relocation of this symbol. */
|
---|
1003 | symbol = *rel->sym_ptr_ptr;
|
---|
1004 |
|
---|
1005 | if (bfd_is_und_section (symbol->section))
|
---|
1006 | r = bfd_reloc_undefined;
|
---|
1007 |
|
---|
1008 | if (bfd_is_com_section (symbol->section))
|
---|
1009 | relocation = 0;
|
---|
1010 | else
|
---|
1011 | relocation = symbol->value;
|
---|
1012 | relocation += symbol->section->output_section->vma;
|
---|
1013 | relocation += symbol->section->output_offset;
|
---|
1014 | relocation += rel->addend;
|
---|
1015 |
|
---|
1016 | if (tos >= RELOC_STACKSIZE)
|
---|
1017 | abort ();
|
---|
1018 |
|
---|
1019 | stack[tos++] = relocation;
|
---|
1020 | }
|
---|
1021 | break;
|
---|
1022 |
|
---|
1023 | case ALPHA_R_OP_STORE:
|
---|
1024 | /* Store a value from the reloc stack into a bitfield. */
|
---|
1025 | {
|
---|
1026 | bfd_vma val;
|
---|
1027 | int offset, size;
|
---|
1028 |
|
---|
1029 | if (relocateable)
|
---|
1030 | {
|
---|
1031 | rel->address += input_section->output_offset;
|
---|
1032 | break;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | if (tos == 0)
|
---|
1036 | abort ();
|
---|
1037 |
|
---|
1038 | /* The offset and size for this reloc are encoded into the
|
---|
1039 | addend field by alpha_adjust_reloc_in. */
|
---|
1040 | offset = (rel->addend >> 8) & 0xff;
|
---|
1041 | size = rel->addend & 0xff;
|
---|
1042 |
|
---|
1043 | val = bfd_get_64 (abfd, data + rel->address);
|
---|
1044 | val &=~ (((1 << size) - 1) << offset);
|
---|
1045 | val |= (stack[--tos] & ((1 << size) - 1)) << offset;
|
---|
1046 | bfd_put_64 (abfd, val, data + rel->address);
|
---|
1047 | }
|
---|
1048 | break;
|
---|
1049 |
|
---|
1050 | case ALPHA_R_OP_PSUB:
|
---|
1051 | /* Subtract a value from the top of the stack. */
|
---|
1052 | {
|
---|
1053 | asymbol *symbol;
|
---|
1054 | bfd_vma relocation;
|
---|
1055 |
|
---|
1056 | if (relocateable)
|
---|
1057 | {
|
---|
1058 | rel->address += input_section->output_offset;
|
---|
1059 | break;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | /* Figure out the relocation of this symbol. */
|
---|
1063 | symbol = *rel->sym_ptr_ptr;
|
---|
1064 |
|
---|
1065 | if (bfd_is_und_section (symbol->section))
|
---|
1066 | r = bfd_reloc_undefined;
|
---|
1067 |
|
---|
1068 | if (bfd_is_com_section (symbol->section))
|
---|
1069 | relocation = 0;
|
---|
1070 | else
|
---|
1071 | relocation = symbol->value;
|
---|
1072 | relocation += symbol->section->output_section->vma;
|
---|
1073 | relocation += symbol->section->output_offset;
|
---|
1074 | relocation += rel->addend;
|
---|
1075 |
|
---|
1076 | if (tos == 0)
|
---|
1077 | abort ();
|
---|
1078 |
|
---|
1079 | stack[tos - 1] -= relocation;
|
---|
1080 | }
|
---|
1081 | break;
|
---|
1082 |
|
---|
1083 | case ALPHA_R_OP_PRSHIFT:
|
---|
1084 | /* Shift the value on the top of the stack. */
|
---|
1085 | {
|
---|
1086 | asymbol *symbol;
|
---|
1087 | bfd_vma relocation;
|
---|
1088 |
|
---|
1089 | if (relocateable)
|
---|
1090 | {
|
---|
1091 | rel->address += input_section->output_offset;
|
---|
1092 | break;
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | /* Figure out the relocation of this symbol. */
|
---|
1096 | symbol = *rel->sym_ptr_ptr;
|
---|
1097 |
|
---|
1098 | if (bfd_is_und_section (symbol->section))
|
---|
1099 | r = bfd_reloc_undefined;
|
---|
1100 |
|
---|
1101 | if (bfd_is_com_section (symbol->section))
|
---|
1102 | relocation = 0;
|
---|
1103 | else
|
---|
1104 | relocation = symbol->value;
|
---|
1105 | relocation += symbol->section->output_section->vma;
|
---|
1106 | relocation += symbol->section->output_offset;
|
---|
1107 | relocation += rel->addend;
|
---|
1108 |
|
---|
1109 | if (tos == 0)
|
---|
1110 | abort ();
|
---|
1111 |
|
---|
1112 | stack[tos - 1] >>= relocation;
|
---|
1113 | }
|
---|
1114 | break;
|
---|
1115 |
|
---|
1116 | case ALPHA_R_GPVALUE:
|
---|
1117 | /* I really don't know if this does the right thing. */
|
---|
1118 | gp = rel->addend;
|
---|
1119 | gp_undefined = false;
|
---|
1120 | break;
|
---|
1121 |
|
---|
1122 | default:
|
---|
1123 | abort ();
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | if (relocateable)
|
---|
1127 | {
|
---|
1128 | asection *os = input_section->output_section;
|
---|
1129 |
|
---|
1130 | /* A partial link, so keep the relocs. */
|
---|
1131 | os->orelocation[os->reloc_count] = rel;
|
---|
1132 | os->reloc_count++;
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | if (r != bfd_reloc_ok)
|
---|
1136 | {
|
---|
1137 | switch (r)
|
---|
1138 | {
|
---|
1139 | case bfd_reloc_undefined:
|
---|
1140 | if (! ((*link_info->callbacks->undefined_symbol)
|
---|
1141 | (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
|
---|
1142 | input_bfd, input_section, rel->address, true)))
|
---|
1143 | goto error_return;
|
---|
1144 | break;
|
---|
1145 | case bfd_reloc_dangerous:
|
---|
1146 | if (! ((*link_info->callbacks->reloc_dangerous)
|
---|
1147 | (link_info, err, input_bfd, input_section,
|
---|
1148 | rel->address)))
|
---|
1149 | goto error_return;
|
---|
1150 | break;
|
---|
1151 | case bfd_reloc_overflow:
|
---|
1152 | if (! ((*link_info->callbacks->reloc_overflow)
|
---|
1153 | (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
|
---|
1154 | rel->howto->name, rel->addend, input_bfd,
|
---|
1155 | input_section, rel->address)))
|
---|
1156 | goto error_return;
|
---|
1157 | break;
|
---|
1158 | case bfd_reloc_outofrange:
|
---|
1159 | default:
|
---|
1160 | abort ();
|
---|
1161 | break;
|
---|
1162 | }
|
---|
1163 | }
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | if (tos != 0)
|
---|
1167 | abort ();
|
---|
1168 |
|
---|
1169 | successful_return:
|
---|
1170 | if (reloc_vector != NULL)
|
---|
1171 | free (reloc_vector);
|
---|
1172 | return data;
|
---|
1173 |
|
---|
1174 | error_return:
|
---|
1175 | if (reloc_vector != NULL)
|
---|
1176 | free (reloc_vector);
|
---|
1177 | return NULL;
|
---|
1178 | }
|
---|
1179 |
|
---|
1180 | /* Get the howto structure for a generic reloc type. */
|
---|
1181 |
|
---|
1182 | static reloc_howto_type *
|
---|
1183 | alpha_bfd_reloc_type_lookup (abfd, code)
|
---|
1184 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
1185 | bfd_reloc_code_real_type code;
|
---|
1186 | {
|
---|
1187 | int alpha_type;
|
---|
1188 |
|
---|
1189 | switch (code)
|
---|
1190 | {
|
---|
1191 | case BFD_RELOC_32:
|
---|
1192 | alpha_type = ALPHA_R_REFLONG;
|
---|
1193 | break;
|
---|
1194 | case BFD_RELOC_64:
|
---|
1195 | case BFD_RELOC_CTOR:
|
---|
1196 | alpha_type = ALPHA_R_REFQUAD;
|
---|
1197 | break;
|
---|
1198 | case BFD_RELOC_GPREL32:
|
---|
1199 | alpha_type = ALPHA_R_GPREL32;
|
---|
1200 | break;
|
---|
1201 | case BFD_RELOC_ALPHA_LITERAL:
|
---|
1202 | alpha_type = ALPHA_R_LITERAL;
|
---|
1203 | break;
|
---|
1204 | case BFD_RELOC_ALPHA_LITUSE:
|
---|
1205 | alpha_type = ALPHA_R_LITUSE;
|
---|
1206 | break;
|
---|
1207 | case BFD_RELOC_ALPHA_GPDISP_HI16:
|
---|
1208 | alpha_type = ALPHA_R_GPDISP;
|
---|
1209 | break;
|
---|
1210 | case BFD_RELOC_ALPHA_GPDISP_LO16:
|
---|
1211 | alpha_type = ALPHA_R_IGNORE;
|
---|
1212 | break;
|
---|
1213 | case BFD_RELOC_23_PCREL_S2:
|
---|
1214 | alpha_type = ALPHA_R_BRADDR;
|
---|
1215 | break;
|
---|
1216 | case BFD_RELOC_ALPHA_HINT:
|
---|
1217 | alpha_type = ALPHA_R_HINT;
|
---|
1218 | break;
|
---|
1219 | case BFD_RELOC_16_PCREL:
|
---|
1220 | alpha_type = ALPHA_R_SREL16;
|
---|
1221 | break;
|
---|
1222 | case BFD_RELOC_32_PCREL:
|
---|
1223 | alpha_type = ALPHA_R_SREL32;
|
---|
1224 | break;
|
---|
1225 | case BFD_RELOC_64_PCREL:
|
---|
1226 | alpha_type = ALPHA_R_SREL64;
|
---|
1227 | break;
|
---|
1228 | #if 0
|
---|
1229 | case ???:
|
---|
1230 | alpha_type = ALPHA_R_OP_PUSH;
|
---|
1231 | break;
|
---|
1232 | case ???:
|
---|
1233 | alpha_type = ALPHA_R_OP_STORE;
|
---|
1234 | break;
|
---|
1235 | case ???:
|
---|
1236 | alpha_type = ALPHA_R_OP_PSUB;
|
---|
1237 | break;
|
---|
1238 | case ???:
|
---|
1239 | alpha_type = ALPHA_R_OP_PRSHIFT;
|
---|
1240 | break;
|
---|
1241 | case ???:
|
---|
1242 | alpha_type = ALPHA_R_GPVALUE;
|
---|
1243 | break;
|
---|
1244 | #endif
|
---|
1245 | default:
|
---|
1246 | return (reloc_howto_type *) NULL;
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | return &alpha_howto_table[alpha_type];
|
---|
1250 | }
|
---|
1251 | |
---|
1252 |
|
---|
1253 | /* A helper routine for alpha_relocate_section which converts an
|
---|
1254 | external reloc when generating relocateable output. Returns the
|
---|
1255 | relocation amount. */
|
---|
1256 |
|
---|
1257 | static bfd_vma
|
---|
1258 | alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h)
|
---|
1259 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
---|
1260 | struct bfd_link_info *info;
|
---|
1261 | bfd *input_bfd;
|
---|
1262 | struct external_reloc *ext_rel;
|
---|
1263 | struct ecoff_link_hash_entry *h;
|
---|
1264 | {
|
---|
1265 | unsigned long r_symndx;
|
---|
1266 | bfd_vma relocation;
|
---|
1267 |
|
---|
1268 | BFD_ASSERT (info->relocateable);
|
---|
1269 |
|
---|
1270 | if (h->root.type == bfd_link_hash_defined
|
---|
1271 | || h->root.type == bfd_link_hash_defweak)
|
---|
1272 | {
|
---|
1273 | asection *hsec;
|
---|
1274 | const char *name;
|
---|
1275 |
|
---|
1276 | /* This symbol is defined in the output. Convert the reloc from
|
---|
1277 | being against the symbol to being against the section. */
|
---|
1278 |
|
---|
1279 | /* Clear the r_extern bit. */
|
---|
1280 | ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE;
|
---|
1281 |
|
---|
1282 | /* Compute a new r_symndx value. */
|
---|
1283 | hsec = h->root.u.def.section;
|
---|
1284 | name = bfd_get_section_name (output_bfd, hsec->output_section);
|
---|
1285 |
|
---|
1286 | r_symndx = -1;
|
---|
1287 | switch (name[1])
|
---|
1288 | {
|
---|
1289 | case 'A':
|
---|
1290 | if (strcmp (name, "*ABS*") == 0)
|
---|
1291 | r_symndx = RELOC_SECTION_ABS;
|
---|
1292 | break;
|
---|
1293 | case 'b':
|
---|
1294 | if (strcmp (name, ".bss") == 0)
|
---|
1295 | r_symndx = RELOC_SECTION_BSS;
|
---|
1296 | break;
|
---|
1297 | case 'd':
|
---|
1298 | if (strcmp (name, ".data") == 0)
|
---|
1299 | r_symndx = RELOC_SECTION_DATA;
|
---|
1300 | break;
|
---|
1301 | case 'f':
|
---|
1302 | if (strcmp (name, ".fini") == 0)
|
---|
1303 | r_symndx = RELOC_SECTION_FINI;
|
---|
1304 | break;
|
---|
1305 | case 'i':
|
---|
1306 | if (strcmp (name, ".init") == 0)
|
---|
1307 | r_symndx = RELOC_SECTION_INIT;
|
---|
1308 | break;
|
---|
1309 | case 'l':
|
---|
1310 | if (strcmp (name, ".lita") == 0)
|
---|
1311 | r_symndx = RELOC_SECTION_LITA;
|
---|
1312 | else if (strcmp (name, ".lit8") == 0)
|
---|
1313 | r_symndx = RELOC_SECTION_LIT8;
|
---|
1314 | else if (strcmp (name, ".lit4") == 0)
|
---|
1315 | r_symndx = RELOC_SECTION_LIT4;
|
---|
1316 | break;
|
---|
1317 | case 'p':
|
---|
1318 | if (strcmp (name, ".pdata") == 0)
|
---|
1319 | r_symndx = RELOC_SECTION_PDATA;
|
---|
1320 | break;
|
---|
1321 | case 'r':
|
---|
1322 | if (strcmp (name, ".rdata") == 0)
|
---|
1323 | r_symndx = RELOC_SECTION_RDATA;
|
---|
1324 | else if (strcmp (name, ".rconst") == 0)
|
---|
1325 | r_symndx = RELOC_SECTION_RCONST;
|
---|
1326 | break;
|
---|
1327 | case 's':
|
---|
1328 | if (strcmp (name, ".sdata") == 0)
|
---|
1329 | r_symndx = RELOC_SECTION_SDATA;
|
---|
1330 | else if (strcmp (name, ".sbss") == 0)
|
---|
1331 | r_symndx = RELOC_SECTION_SBSS;
|
---|
1332 | break;
|
---|
1333 | case 't':
|
---|
1334 | if (strcmp (name, ".text") == 0)
|
---|
1335 | r_symndx = RELOC_SECTION_TEXT;
|
---|
1336 | break;
|
---|
1337 | case 'x':
|
---|
1338 | if (strcmp (name, ".xdata") == 0)
|
---|
1339 | r_symndx = RELOC_SECTION_XDATA;
|
---|
1340 | break;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | if (r_symndx == -1)
|
---|
1344 | abort ();
|
---|
1345 |
|
---|
1346 | /* Add the section VMA and the symbol value. */
|
---|
1347 | relocation = (h->root.u.def.value
|
---|
1348 | + hsec->output_section->vma
|
---|
1349 | + hsec->output_offset);
|
---|
1350 | }
|
---|
1351 | else
|
---|
1352 | {
|
---|
1353 | /* Change the symndx value to the right one for
|
---|
1354 | the output BFD. */
|
---|
1355 | r_symndx = h->indx;
|
---|
1356 | if (r_symndx == -1)
|
---|
1357 | {
|
---|
1358 | /* Caller must give an error. */
|
---|
1359 | r_symndx = 0;
|
---|
1360 | }
|
---|
1361 | relocation = 0;
|
---|
1362 | }
|
---|
1363 |
|
---|
1364 | /* Write out the new r_symndx value. */
|
---|
1365 | bfd_h_put_32 (input_bfd, (bfd_vma) r_symndx,
|
---|
1366 | (bfd_byte *) ext_rel->r_symndx);
|
---|
1367 |
|
---|
1368 | return relocation;
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | /* Relocate a section while linking an Alpha ECOFF file. This is
|
---|
1372 | quite similar to get_relocated_section_contents. Perhaps they
|
---|
1373 | could be combined somehow. */
|
---|
1374 |
|
---|
1375 | static boolean
|
---|
1376 | alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
---|
1377 | contents, external_relocs)
|
---|
1378 | bfd *output_bfd;
|
---|
1379 | struct bfd_link_info *info;
|
---|
1380 | bfd *input_bfd;
|
---|
1381 | asection *input_section;
|
---|
1382 | bfd_byte *contents;
|
---|
1383 | PTR external_relocs;
|
---|
1384 | {
|
---|
1385 | asection **symndx_to_section, *lita_sec;
|
---|
1386 | struct ecoff_link_hash_entry **sym_hashes;
|
---|
1387 | bfd_vma gp;
|
---|
1388 | boolean gp_undefined;
|
---|
1389 | bfd_vma stack[RELOC_STACKSIZE];
|
---|
1390 | int tos = 0;
|
---|
1391 | struct external_reloc *ext_rel;
|
---|
1392 | struct external_reloc *ext_rel_end;
|
---|
1393 |
|
---|
1394 | /* We keep a table mapping the symndx found in an internal reloc to
|
---|
1395 | the appropriate section. This is faster than looking up the
|
---|
1396 | section by name each time. */
|
---|
1397 | symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
|
---|
1398 | if (symndx_to_section == (asection **) NULL)
|
---|
1399 | {
|
---|
1400 | symndx_to_section = ((asection **)
|
---|
1401 | bfd_alloc (input_bfd,
|
---|
1402 | (NUM_RELOC_SECTIONS
|
---|
1403 | * sizeof (asection *))));
|
---|
1404 | if (!symndx_to_section)
|
---|
1405 | return false;
|
---|
1406 |
|
---|
1407 | symndx_to_section[RELOC_SECTION_NONE] = NULL;
|
---|
1408 | symndx_to_section[RELOC_SECTION_TEXT] =
|
---|
1409 | bfd_get_section_by_name (input_bfd, ".text");
|
---|
1410 | symndx_to_section[RELOC_SECTION_RDATA] =
|
---|
1411 | bfd_get_section_by_name (input_bfd, ".rdata");
|
---|
1412 | symndx_to_section[RELOC_SECTION_DATA] =
|
---|
1413 | bfd_get_section_by_name (input_bfd, ".data");
|
---|
1414 | symndx_to_section[RELOC_SECTION_SDATA] =
|
---|
1415 | bfd_get_section_by_name (input_bfd, ".sdata");
|
---|
1416 | symndx_to_section[RELOC_SECTION_SBSS] =
|
---|
1417 | bfd_get_section_by_name (input_bfd, ".sbss");
|
---|
1418 | symndx_to_section[RELOC_SECTION_BSS] =
|
---|
1419 | bfd_get_section_by_name (input_bfd, ".bss");
|
---|
1420 | symndx_to_section[RELOC_SECTION_INIT] =
|
---|
1421 | bfd_get_section_by_name (input_bfd, ".init");
|
---|
1422 | symndx_to_section[RELOC_SECTION_LIT8] =
|
---|
1423 | bfd_get_section_by_name (input_bfd, ".lit8");
|
---|
1424 | symndx_to_section[RELOC_SECTION_LIT4] =
|
---|
1425 | bfd_get_section_by_name (input_bfd, ".lit4");
|
---|
1426 | symndx_to_section[RELOC_SECTION_XDATA] =
|
---|
1427 | bfd_get_section_by_name (input_bfd, ".xdata");
|
---|
1428 | symndx_to_section[RELOC_SECTION_PDATA] =
|
---|
1429 | bfd_get_section_by_name (input_bfd, ".pdata");
|
---|
1430 | symndx_to_section[RELOC_SECTION_FINI] =
|
---|
1431 | bfd_get_section_by_name (input_bfd, ".fini");
|
---|
1432 | symndx_to_section[RELOC_SECTION_LITA] =
|
---|
1433 | bfd_get_section_by_name (input_bfd, ".lita");
|
---|
1434 | symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
|
---|
1435 | symndx_to_section[RELOC_SECTION_RCONST] =
|
---|
1436 | bfd_get_section_by_name (input_bfd, ".rconst");
|
---|
1437 |
|
---|
1438 | ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
|
---|
1439 | }
|
---|
1440 |
|
---|
1441 | sym_hashes = ecoff_data (input_bfd)->sym_hashes;
|
---|
1442 |
|
---|
1443 | /* On the Alpha, the .lita section must be addressable by the global
|
---|
1444 | pointer. To support large programs, we need to allow multiple
|
---|
1445 | global pointers. This works as long as each input .lita section
|
---|
1446 | is <64KB big. This implies that when producing relocatable
|
---|
1447 | output, the .lita section is limited to 64KB. . */
|
---|
1448 |
|
---|
1449 | lita_sec = symndx_to_section[RELOC_SECTION_LITA];
|
---|
1450 | gp = _bfd_get_gp_value (output_bfd);
|
---|
1451 | if (! info->relocateable && lita_sec != NULL)
|
---|
1452 | {
|
---|
1453 | struct ecoff_section_tdata *lita_sec_data;
|
---|
1454 |
|
---|
1455 | /* Make sure we have a section data structure to which we can
|
---|
1456 | hang on to the gp value we pick for the section. */
|
---|
1457 | lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
|
---|
1458 | if (lita_sec_data == NULL)
|
---|
1459 | {
|
---|
1460 | lita_sec_data = ((struct ecoff_section_tdata *)
|
---|
1461 | bfd_zalloc (input_bfd,
|
---|
1462 | sizeof (struct ecoff_section_tdata)));
|
---|
1463 | ecoff_section_data (input_bfd, lita_sec) = lita_sec_data;
|
---|
1464 | }
|
---|
1465 |
|
---|
1466 | if (lita_sec_data->gp != 0)
|
---|
1467 | {
|
---|
1468 | /* If we already assigned a gp to this section, we better
|
---|
1469 | stick with that value. */
|
---|
1470 | gp = lita_sec_data->gp;
|
---|
1471 | }
|
---|
1472 | else
|
---|
1473 | {
|
---|
1474 | bfd_vma lita_vma;
|
---|
1475 | bfd_size_type lita_size;
|
---|
1476 |
|
---|
1477 | lita_vma = lita_sec->output_offset + lita_sec->output_section->vma;
|
---|
1478 | lita_size = lita_sec->_cooked_size;
|
---|
1479 | if (lita_size == 0)
|
---|
1480 | lita_size = lita_sec->_raw_size;
|
---|
1481 |
|
---|
1482 | if (gp == 0
|
---|
1483 | || lita_vma < gp - 0x8000
|
---|
1484 | || lita_vma + lita_size >= gp + 0x8000)
|
---|
1485 | {
|
---|
1486 | /* Either gp hasn't been set at all or the current gp
|
---|
1487 | cannot address this .lita section. In both cases we
|
---|
1488 | reset the gp to point into the "middle" of the
|
---|
1489 | current input .lita section. */
|
---|
1490 | if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning)
|
---|
1491 | {
|
---|
1492 | (*info->callbacks->warning) (info,
|
---|
1493 | _("using multiple gp values"),
|
---|
1494 | (char *) NULL, output_bfd,
|
---|
1495 | (asection *) NULL, (bfd_vma) 0);
|
---|
1496 | ecoff_data (output_bfd)->issued_multiple_gp_warning = true;
|
---|
1497 | }
|
---|
1498 | if (lita_vma < gp - 0x8000)
|
---|
1499 | gp = lita_vma + lita_size - 0x8000;
|
---|
1500 | else
|
---|
1501 | gp = lita_vma + 0x8000;
|
---|
1502 |
|
---|
1503 | }
|
---|
1504 |
|
---|
1505 | lita_sec_data->gp = gp;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | _bfd_set_gp_value (output_bfd, gp);
|
---|
1509 | }
|
---|
1510 |
|
---|
1511 | gp_undefined = (gp == 0);
|
---|
1512 |
|
---|
1513 | BFD_ASSERT (bfd_header_little_endian (output_bfd));
|
---|
1514 | BFD_ASSERT (bfd_header_little_endian (input_bfd));
|
---|
1515 |
|
---|
1516 | ext_rel = (struct external_reloc *) external_relocs;
|
---|
1517 | ext_rel_end = ext_rel + input_section->reloc_count;
|
---|
1518 | for (; ext_rel < ext_rel_end; ext_rel++)
|
---|
1519 | {
|
---|
1520 | bfd_vma r_vaddr;
|
---|
1521 | unsigned long r_symndx;
|
---|
1522 | int r_type;
|
---|
1523 | int r_extern;
|
---|
1524 | int r_offset;
|
---|
1525 | int r_size;
|
---|
1526 | boolean relocatep;
|
---|
1527 | boolean adjust_addrp;
|
---|
1528 | boolean gp_usedp;
|
---|
1529 | bfd_vma addend;
|
---|
1530 |
|
---|
1531 | r_vaddr = bfd_h_get_64 (input_bfd, (bfd_byte *) ext_rel->r_vaddr);
|
---|
1532 | r_symndx = bfd_h_get_32 (input_bfd, (bfd_byte *) ext_rel->r_symndx);
|
---|
1533 |
|
---|
1534 | r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
|
---|
1535 | >> RELOC_BITS0_TYPE_SH_LITTLE);
|
---|
1536 | r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
|
---|
1537 | r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
|
---|
1538 | >> RELOC_BITS1_OFFSET_SH_LITTLE);
|
---|
1539 | /* Ignored the reserved bits. */
|
---|
1540 | r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
|
---|
1541 | >> RELOC_BITS3_SIZE_SH_LITTLE);
|
---|
1542 |
|
---|
1543 | relocatep = false;
|
---|
1544 | adjust_addrp = true;
|
---|
1545 | gp_usedp = false;
|
---|
1546 | addend = 0;
|
---|
1547 |
|
---|
1548 | switch (r_type)
|
---|
1549 | {
|
---|
1550 | default:
|
---|
1551 | abort ();
|
---|
1552 |
|
---|
1553 | case ALPHA_R_IGNORE:
|
---|
1554 | /* This reloc appears after a GPDISP reloc. On earlier
|
---|
1555 | versions of OSF/1, It marked the position of the second
|
---|
1556 | instruction to be altered by the GPDISP reloc, but it is
|
---|
1557 | not otherwise used for anything. For some reason, the
|
---|
1558 | address of the relocation does not appear to include the
|
---|
1559 | section VMA, unlike the other relocation types. */
|
---|
1560 | if (info->relocateable)
|
---|
1561 | bfd_h_put_64 (input_bfd,
|
---|
1562 | input_section->output_offset + r_vaddr,
|
---|
1563 | (bfd_byte *) ext_rel->r_vaddr);
|
---|
1564 | adjust_addrp = false;
|
---|
1565 | break;
|
---|
1566 |
|
---|
1567 | case ALPHA_R_REFLONG:
|
---|
1568 | case ALPHA_R_REFQUAD:
|
---|
1569 | case ALPHA_R_HINT:
|
---|
1570 | relocatep = true;
|
---|
1571 | break;
|
---|
1572 |
|
---|
1573 | case ALPHA_R_BRADDR:
|
---|
1574 | case ALPHA_R_SREL16:
|
---|
1575 | case ALPHA_R_SREL32:
|
---|
1576 | case ALPHA_R_SREL64:
|
---|
1577 | if (r_extern)
|
---|
1578 | addend += - (r_vaddr + 4);
|
---|
1579 | relocatep = true;
|
---|
1580 | break;
|
---|
1581 |
|
---|
1582 | case ALPHA_R_GPREL32:
|
---|
1583 | /* This relocation is used in a switch table. It is a 32
|
---|
1584 | bit offset from the current GP value. We must adjust it
|
---|
1585 | by the different between the original GP value and the
|
---|
1586 | current GP value. */
|
---|
1587 | relocatep = true;
|
---|
1588 | addend = ecoff_data (input_bfd)->gp - gp;
|
---|
1589 | gp_usedp = true;
|
---|
1590 | break;
|
---|
1591 |
|
---|
1592 | case ALPHA_R_LITERAL:
|
---|
1593 | /* This is a reference to a literal value, generally
|
---|
1594 | (always?) in the .lita section. This is a 16 bit GP
|
---|
1595 | relative relocation. Sometimes the subsequent reloc is a
|
---|
1596 | LITUSE reloc, which indicates how this reloc is used.
|
---|
1597 | This sometimes permits rewriting the two instructions
|
---|
1598 | referred to by the LITERAL and the LITUSE into different
|
---|
1599 | instructions which do not refer to .lita. This can save
|
---|
1600 | a memory reference, and permits removing a value from
|
---|
1601 | .lita thus saving GP relative space.
|
---|
1602 |
|
---|
1603 | We do not these optimizations. To do them we would need
|
---|
1604 | to arrange to link the .lita section first, so that by
|
---|
1605 | the time we got here we would know the final values to
|
---|
1606 | use. This would not be particularly difficult, but it is
|
---|
1607 | not currently implemented. */
|
---|
1608 |
|
---|
1609 | /* I believe that the LITERAL reloc will only apply to a ldq
|
---|
1610 | or ldl instruction, so check my assumption. */
|
---|
1611 | {
|
---|
1612 | unsigned long insn;
|
---|
1613 |
|
---|
1614 | insn = bfd_get_32 (input_bfd,
|
---|
1615 | contents + r_vaddr - input_section->vma);
|
---|
1616 | BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
|
---|
1617 | || ((insn >> 26) & 0x3f) == 0x28);
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | relocatep = true;
|
---|
1621 | addend = ecoff_data (input_bfd)->gp - gp;
|
---|
1622 | gp_usedp = true;
|
---|
1623 | break;
|
---|
1624 |
|
---|
1625 | case ALPHA_R_LITUSE:
|
---|
1626 | /* See ALPHA_R_LITERAL above for the uses of this reloc. It
|
---|
1627 | does not cause anything to happen, itself. */
|
---|
1628 | break;
|
---|
1629 |
|
---|
1630 | case ALPHA_R_GPDISP:
|
---|
1631 | /* This marks the ldah of an ldah/lda pair which loads the
|
---|
1632 | gp register with the difference of the gp value and the
|
---|
1633 | current location. The second of the pair is r_symndx
|
---|
1634 | bytes ahead. It used to be marked with an ALPHA_R_IGNORE
|
---|
1635 | reloc, but OSF/1 3.2 no longer does that. */
|
---|
1636 | {
|
---|
1637 | unsigned long insn1, insn2;
|
---|
1638 |
|
---|
1639 | /* Get the two instructions. */
|
---|
1640 | insn1 = bfd_get_32 (input_bfd,
|
---|
1641 | contents + r_vaddr - input_section->vma);
|
---|
1642 | insn2 = bfd_get_32 (input_bfd,
|
---|
1643 | (contents
|
---|
1644 | + r_vaddr
|
---|
1645 | - input_section->vma
|
---|
1646 | + r_symndx));
|
---|
1647 |
|
---|
1648 | BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
|
---|
1649 | BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
|
---|
1650 |
|
---|
1651 | /* Get the existing addend. We must account for the sign
|
---|
1652 | extension done by lda and ldah. */
|
---|
1653 | addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
|
---|
1654 | if (insn1 & 0x8000)
|
---|
1655 | {
|
---|
1656 | /* This is addend -= 0x100000000 without causing an
|
---|
1657 | integer overflow on a 32 bit host. */
|
---|
1658 | addend -= 0x80000000;
|
---|
1659 | addend -= 0x80000000;
|
---|
1660 | }
|
---|
1661 | if (insn2 & 0x8000)
|
---|
1662 | addend -= 0x10000;
|
---|
1663 |
|
---|
1664 | /* The existing addend includes the difference between the
|
---|
1665 | gp of the input BFD and the address in the input BFD.
|
---|
1666 | We want to change this to the difference between the
|
---|
1667 | final GP and the final address. */
|
---|
1668 | addend += (gp
|
---|
1669 | - ecoff_data (input_bfd)->gp
|
---|
1670 | + input_section->vma
|
---|
1671 | - (input_section->output_section->vma
|
---|
1672 | + input_section->output_offset));
|
---|
1673 |
|
---|
1674 | /* Change the instructions, accounting for the sign
|
---|
1675 | extension, and write them out. */
|
---|
1676 | if (addend & 0x8000)
|
---|
1677 | addend += 0x10000;
|
---|
1678 | insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
|
---|
1679 | insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
|
---|
1680 |
|
---|
1681 | bfd_put_32 (input_bfd, (bfd_vma) insn1,
|
---|
1682 | contents + r_vaddr - input_section->vma);
|
---|
1683 | bfd_put_32 (input_bfd, (bfd_vma) insn2,
|
---|
1684 | contents + r_vaddr - input_section->vma + r_symndx);
|
---|
1685 |
|
---|
1686 | gp_usedp = true;
|
---|
1687 | }
|
---|
1688 | break;
|
---|
1689 |
|
---|
1690 | case ALPHA_R_OP_PUSH:
|
---|
1691 | case ALPHA_R_OP_PSUB:
|
---|
1692 | case ALPHA_R_OP_PRSHIFT:
|
---|
1693 | /* Manipulate values on the reloc evaluation stack. The
|
---|
1694 | r_vaddr field is not an address in input_section, it is
|
---|
1695 | the current value (including any addend) of the object
|
---|
1696 | being used. */
|
---|
1697 | if (! r_extern)
|
---|
1698 | {
|
---|
1699 | asection *s;
|
---|
1700 |
|
---|
1701 | s = symndx_to_section[r_symndx];
|
---|
1702 | if (s == (asection *) NULL)
|
---|
1703 | abort ();
|
---|
1704 | addend = s->output_section->vma + s->output_offset - s->vma;
|
---|
1705 | }
|
---|
1706 | else
|
---|
1707 | {
|
---|
1708 | struct ecoff_link_hash_entry *h;
|
---|
1709 |
|
---|
1710 | h = sym_hashes[r_symndx];
|
---|
1711 | if (h == (struct ecoff_link_hash_entry *) NULL)
|
---|
1712 | abort ();
|
---|
1713 |
|
---|
1714 | if (! info->relocateable)
|
---|
1715 | {
|
---|
1716 | if (h->root.type == bfd_link_hash_defined
|
---|
1717 | || h->root.type == bfd_link_hash_defweak)
|
---|
1718 | addend = (h->root.u.def.value
|
---|
1719 | + h->root.u.def.section->output_section->vma
|
---|
1720 | + h->root.u.def.section->output_offset);
|
---|
1721 | else
|
---|
1722 | {
|
---|
1723 | /* Note that we pass the address as 0, since we
|
---|
1724 | do not have a meaningful number for the
|
---|
1725 | location within the section that is being
|
---|
1726 | relocated. */
|
---|
1727 | if (! ((*info->callbacks->undefined_symbol)
|
---|
1728 | (info, h->root.root.string, input_bfd,
|
---|
1729 | input_section, (bfd_vma) 0, true)))
|
---|
1730 | return false;
|
---|
1731 | addend = 0;
|
---|
1732 | }
|
---|
1733 | }
|
---|
1734 | else
|
---|
1735 | {
|
---|
1736 | if (h->root.type != bfd_link_hash_defined
|
---|
1737 | && h->root.type != bfd_link_hash_defweak
|
---|
1738 | && h->indx == -1)
|
---|
1739 | {
|
---|
1740 | /* This symbol is not being written out. Pass
|
---|
1741 | the address as 0, as with undefined_symbol,
|
---|
1742 | above. */
|
---|
1743 | if (! ((*info->callbacks->unattached_reloc)
|
---|
1744 | (info, h->root.root.string, input_bfd,
|
---|
1745 | input_section, (bfd_vma) 0)))
|
---|
1746 | return false;
|
---|
1747 | }
|
---|
1748 |
|
---|
1749 | addend = alpha_convert_external_reloc (output_bfd, info,
|
---|
1750 | input_bfd,
|
---|
1751 | ext_rel, h);
|
---|
1752 | }
|
---|
1753 | }
|
---|
1754 |
|
---|
1755 | addend += r_vaddr;
|
---|
1756 |
|
---|
1757 | if (info->relocateable)
|
---|
1758 | {
|
---|
1759 | /* Adjust r_vaddr by the addend. */
|
---|
1760 | bfd_h_put_64 (input_bfd, addend,
|
---|
1761 | (bfd_byte *) ext_rel->r_vaddr);
|
---|
1762 | }
|
---|
1763 | else
|
---|
1764 | {
|
---|
1765 | switch (r_type)
|
---|
1766 | {
|
---|
1767 | case ALPHA_R_OP_PUSH:
|
---|
1768 | if (tos >= RELOC_STACKSIZE)
|
---|
1769 | abort ();
|
---|
1770 | stack[tos++] = addend;
|
---|
1771 | break;
|
---|
1772 |
|
---|
1773 | case ALPHA_R_OP_PSUB:
|
---|
1774 | if (tos == 0)
|
---|
1775 | abort ();
|
---|
1776 | stack[tos - 1] -= addend;
|
---|
1777 | break;
|
---|
1778 |
|
---|
1779 | case ALPHA_R_OP_PRSHIFT:
|
---|
1780 | if (tos == 0)
|
---|
1781 | abort ();
|
---|
1782 | stack[tos - 1] >>= addend;
|
---|
1783 | break;
|
---|
1784 | }
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | adjust_addrp = false;
|
---|
1788 | break;
|
---|
1789 |
|
---|
1790 | case ALPHA_R_OP_STORE:
|
---|
1791 | /* Store a value from the reloc stack into a bitfield. If
|
---|
1792 | we are generating relocateable output, all we do is
|
---|
1793 | adjust the address of the reloc. */
|
---|
1794 | if (! info->relocateable)
|
---|
1795 | {
|
---|
1796 | bfd_vma mask;
|
---|
1797 | bfd_vma val;
|
---|
1798 |
|
---|
1799 | if (tos == 0)
|
---|
1800 | abort ();
|
---|
1801 |
|
---|
1802 | /* Get the relocation mask. The separate steps and the
|
---|
1803 | casts to bfd_vma are attempts to avoid a bug in the
|
---|
1804 | Alpha OSF 1.3 C compiler. See reloc.c for more
|
---|
1805 | details. */
|
---|
1806 | mask = 1;
|
---|
1807 | mask <<= (bfd_vma) r_size;
|
---|
1808 | mask -= 1;
|
---|
1809 |
|
---|
1810 | /* FIXME: I don't know what kind of overflow checking,
|
---|
1811 | if any, should be done here. */
|
---|
1812 | val = bfd_get_64 (input_bfd,
|
---|
1813 | contents + r_vaddr - input_section->vma);
|
---|
1814 | val &=~ mask << (bfd_vma) r_offset;
|
---|
1815 | val |= (stack[--tos] & mask) << (bfd_vma) r_offset;
|
---|
1816 | bfd_put_64 (input_bfd, val,
|
---|
1817 | contents + r_vaddr - input_section->vma);
|
---|
1818 | }
|
---|
1819 | break;
|
---|
1820 |
|
---|
1821 | case ALPHA_R_GPVALUE:
|
---|
1822 | /* I really don't know if this does the right thing. */
|
---|
1823 | gp = ecoff_data (input_bfd)->gp + r_symndx;
|
---|
1824 | gp_undefined = false;
|
---|
1825 | break;
|
---|
1826 | }
|
---|
1827 |
|
---|
1828 | if (relocatep)
|
---|
1829 | {
|
---|
1830 | reloc_howto_type *howto;
|
---|
1831 | struct ecoff_link_hash_entry *h = NULL;
|
---|
1832 | asection *s = NULL;
|
---|
1833 | bfd_vma relocation;
|
---|
1834 | bfd_reloc_status_type r;
|
---|
1835 |
|
---|
1836 | /* Perform a relocation. */
|
---|
1837 |
|
---|
1838 | howto = &alpha_howto_table[r_type];
|
---|
1839 |
|
---|
1840 | if (r_extern)
|
---|
1841 | {
|
---|
1842 | h = sym_hashes[r_symndx];
|
---|
1843 | /* If h is NULL, that means that there is a reloc
|
---|
1844 | against an external symbol which we thought was just
|
---|
1845 | a debugging symbol. This should not happen. */
|
---|
1846 | if (h == (struct ecoff_link_hash_entry *) NULL)
|
---|
1847 | abort ();
|
---|
1848 | }
|
---|
1849 | else
|
---|
1850 | {
|
---|
1851 | if (r_symndx >= NUM_RELOC_SECTIONS)
|
---|
1852 | s = NULL;
|
---|
1853 | else
|
---|
1854 | s = symndx_to_section[r_symndx];
|
---|
1855 |
|
---|
1856 | if (s == (asection *) NULL)
|
---|
1857 | abort ();
|
---|
1858 | }
|
---|
1859 |
|
---|
1860 | if (info->relocateable)
|
---|
1861 | {
|
---|
1862 | /* We are generating relocateable output, and must
|
---|
1863 | convert the existing reloc. */
|
---|
1864 | if (r_extern)
|
---|
1865 | {
|
---|
1866 | if (h->root.type != bfd_link_hash_defined
|
---|
1867 | && h->root.type != bfd_link_hash_defweak
|
---|
1868 | && h->indx == -1)
|
---|
1869 | {
|
---|
1870 | /* This symbol is not being written out. */
|
---|
1871 | if (! ((*info->callbacks->unattached_reloc)
|
---|
1872 | (info, h->root.root.string, input_bfd,
|
---|
1873 | input_section, r_vaddr - input_section->vma)))
|
---|
1874 | return false;
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | relocation = alpha_convert_external_reloc (output_bfd,
|
---|
1878 | info,
|
---|
1879 | input_bfd,
|
---|
1880 | ext_rel,
|
---|
1881 | h);
|
---|
1882 | }
|
---|
1883 | else
|
---|
1884 | {
|
---|
1885 | /* This is a relocation against a section. Adjust
|
---|
1886 | the value by the amount the section moved. */
|
---|
1887 | relocation = (s->output_section->vma
|
---|
1888 | + s->output_offset
|
---|
1889 | - s->vma);
|
---|
1890 | }
|
---|
1891 |
|
---|
1892 | /* If this is PC relative, the existing object file
|
---|
1893 | appears to already have the reloc worked out. We
|
---|
1894 | must subtract out the old value and add in the new
|
---|
1895 | one. */
|
---|
1896 | if (howto->pc_relative)
|
---|
1897 | relocation -= (input_section->output_section->vma
|
---|
1898 | + input_section->output_offset
|
---|
1899 | - input_section->vma);
|
---|
1900 |
|
---|
1901 | /* Put in any addend. */
|
---|
1902 | relocation += addend;
|
---|
1903 |
|
---|
1904 | /* Adjust the contents. */
|
---|
1905 | r = _bfd_relocate_contents (howto, input_bfd, relocation,
|
---|
1906 | (contents
|
---|
1907 | + r_vaddr
|
---|
1908 | - input_section->vma));
|
---|
1909 | }
|
---|
1910 | else
|
---|
1911 | {
|
---|
1912 | /* We are producing a final executable. */
|
---|
1913 | if (r_extern)
|
---|
1914 | {
|
---|
1915 | /* This is a reloc against a symbol. */
|
---|
1916 | if (h->root.type == bfd_link_hash_defined
|
---|
1917 | || h->root.type == bfd_link_hash_defweak)
|
---|
1918 | {
|
---|
1919 | asection *hsec;
|
---|
1920 |
|
---|
1921 | hsec = h->root.u.def.section;
|
---|
1922 | relocation = (h->root.u.def.value
|
---|
1923 | + hsec->output_section->vma
|
---|
1924 | + hsec->output_offset);
|
---|
1925 | }
|
---|
1926 | else
|
---|
1927 | {
|
---|
1928 | if (! ((*info->callbacks->undefined_symbol)
|
---|
1929 | (info, h->root.root.string, input_bfd,
|
---|
1930 | input_section,
|
---|
1931 | r_vaddr - input_section->vma, true)))
|
---|
1932 | return false;
|
---|
1933 | relocation = 0;
|
---|
1934 | }
|
---|
1935 | }
|
---|
1936 | else
|
---|
1937 | {
|
---|
1938 | /* This is a reloc against a section. */
|
---|
1939 | relocation = (s->output_section->vma
|
---|
1940 | + s->output_offset
|
---|
1941 | - s->vma);
|
---|
1942 |
|
---|
1943 | /* Adjust a PC relative relocation by removing the
|
---|
1944 | reference to the original source section. */
|
---|
1945 | if (howto->pc_relative)
|
---|
1946 | relocation += input_section->vma;
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 | r = _bfd_final_link_relocate (howto,
|
---|
1950 | input_bfd,
|
---|
1951 | input_section,
|
---|
1952 | contents,
|
---|
1953 | r_vaddr - input_section->vma,
|
---|
1954 | relocation,
|
---|
1955 | addend);
|
---|
1956 | }
|
---|
1957 |
|
---|
1958 | if (r != bfd_reloc_ok)
|
---|
1959 | {
|
---|
1960 | switch (r)
|
---|
1961 | {
|
---|
1962 | default:
|
---|
1963 | case bfd_reloc_outofrange:
|
---|
1964 | abort ();
|
---|
1965 | case bfd_reloc_overflow:
|
---|
1966 | {
|
---|
1967 | const char *name;
|
---|
1968 |
|
---|
1969 | if (r_extern)
|
---|
1970 | name = sym_hashes[r_symndx]->root.root.string;
|
---|
1971 | else
|
---|
1972 | name = bfd_section_name (input_bfd,
|
---|
1973 | symndx_to_section[r_symndx]);
|
---|
1974 | if (! ((*info->callbacks->reloc_overflow)
|
---|
1975 | (info, name, alpha_howto_table[r_type].name,
|
---|
1976 | (bfd_vma) 0, input_bfd, input_section,
|
---|
1977 | r_vaddr - input_section->vma)))
|
---|
1978 | return false;
|
---|
1979 | }
|
---|
1980 | break;
|
---|
1981 | }
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 |
|
---|
1985 | if (info->relocateable && adjust_addrp)
|
---|
1986 | {
|
---|
1987 | /* Change the address of the relocation. */
|
---|
1988 | bfd_h_put_64 (input_bfd,
|
---|
1989 | (input_section->output_section->vma
|
---|
1990 | + input_section->output_offset
|
---|
1991 | - input_section->vma
|
---|
1992 | + r_vaddr),
|
---|
1993 | (bfd_byte *) ext_rel->r_vaddr);
|
---|
1994 | }
|
---|
1995 |
|
---|
1996 | if (gp_usedp && gp_undefined)
|
---|
1997 | {
|
---|
1998 | if (! ((*info->callbacks->reloc_dangerous)
|
---|
1999 | (info, _("GP relative relocation when GP not defined"),
|
---|
2000 | input_bfd, input_section, r_vaddr - input_section->vma)))
|
---|
2001 | return false;
|
---|
2002 | /* Only give the error once per link. */
|
---|
2003 | gp = 4;
|
---|
2004 | _bfd_set_gp_value (output_bfd, gp);
|
---|
2005 | gp_undefined = false;
|
---|
2006 | }
|
---|
2007 | }
|
---|
2008 |
|
---|
2009 | if (tos != 0)
|
---|
2010 | abort ();
|
---|
2011 |
|
---|
2012 | return true;
|
---|
2013 | }
|
---|
2014 | |
---|
2015 |
|
---|
2016 | /* Do final adjustments to the filehdr and the aouthdr. This routine
|
---|
2017 | sets the dynamic bits in the file header. */
|
---|
2018 |
|
---|
2019 | static boolean
|
---|
2020 | alpha_adjust_headers (abfd, fhdr, ahdr)
|
---|
2021 | bfd *abfd;
|
---|
2022 | struct internal_filehdr *fhdr;
|
---|
2023 | struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED;
|
---|
2024 | {
|
---|
2025 | if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
|
---|
2026 | fhdr->f_flags |= F_ALPHA_CALL_SHARED;
|
---|
2027 | else if ((abfd->flags & DYNAMIC) != 0)
|
---|
2028 | fhdr->f_flags |= F_ALPHA_SHARABLE;
|
---|
2029 | return true;
|
---|
2030 | }
|
---|
2031 | |
---|
2032 |
|
---|
2033 | /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
|
---|
2034 | introduced archive packing, in which the elements in an archive are
|
---|
2035 | optionally compressed using a simple dictionary scheme. We know
|
---|
2036 | how to read such archives, but we don't write them. */
|
---|
2037 |
|
---|
2038 | #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
|
---|
2039 | #define alpha_ecoff_slurp_extended_name_table \
|
---|
2040 | _bfd_ecoff_slurp_extended_name_table
|
---|
2041 | #define alpha_ecoff_construct_extended_name_table \
|
---|
2042 | _bfd_ecoff_construct_extended_name_table
|
---|
2043 | #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
|
---|
2044 | #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
|
---|
2045 | #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
|
---|
2046 | #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
|
---|
2047 |
|
---|
2048 | /* A compressed file uses this instead of ARFMAG. */
|
---|
2049 |
|
---|
2050 | #define ARFZMAG "Z\012"
|
---|
2051 |
|
---|
2052 | /* Read an archive header. This is like the standard routine, but it
|
---|
2053 | also accepts ARFZMAG. */
|
---|
2054 |
|
---|
2055 | static PTR
|
---|
2056 | alpha_ecoff_read_ar_hdr (abfd)
|
---|
2057 | bfd *abfd;
|
---|
2058 | {
|
---|
2059 | struct areltdata *ret;
|
---|
2060 | struct ar_hdr *h;
|
---|
2061 |
|
---|
2062 | ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
|
---|
2063 | if (ret == NULL)
|
---|
2064 | return NULL;
|
---|
2065 |
|
---|
2066 | h = (struct ar_hdr *) ret->arch_header;
|
---|
2067 | if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0)
|
---|
2068 | {
|
---|
2069 | bfd_byte ab[8];
|
---|
2070 |
|
---|
2071 | /* This is a compressed file. We must set the size correctly.
|
---|
2072 | The size is the eight bytes after the dummy file header. */
|
---|
2073 | if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0
|
---|
2074 | || bfd_read (ab, 1, 8, abfd) != 8
|
---|
2075 | || bfd_seek (abfd, - (FILHSZ + 8), SEEK_CUR) != 0)
|
---|
2076 | return NULL;
|
---|
2077 |
|
---|
2078 | ret->parsed_size = bfd_h_get_64 (abfd, ab);
|
---|
2079 | }
|
---|
2080 |
|
---|
2081 | return (PTR) ret;
|
---|
2082 | }
|
---|
2083 |
|
---|
2084 | /* Get an archive element at a specified file position. This is where
|
---|
2085 | we uncompress the archive element if necessary. */
|
---|
2086 |
|
---|
2087 | static bfd *
|
---|
2088 | alpha_ecoff_get_elt_at_filepos (archive, filepos)
|
---|
2089 | bfd *archive;
|
---|
2090 | file_ptr filepos;
|
---|
2091 | {
|
---|
2092 | bfd *nbfd = NULL;
|
---|
2093 | struct areltdata *tdata;
|
---|
2094 | struct ar_hdr *hdr;
|
---|
2095 | bfd_byte ab[8];
|
---|
2096 | bfd_size_type size;
|
---|
2097 | bfd_byte *buf, *p;
|
---|
2098 | struct bfd_in_memory *bim;
|
---|
2099 |
|
---|
2100 | nbfd = _bfd_get_elt_at_filepos (archive, filepos);
|
---|
2101 | if (nbfd == NULL)
|
---|
2102 | goto error_return;
|
---|
2103 |
|
---|
2104 | if ((nbfd->flags & BFD_IN_MEMORY) != 0)
|
---|
2105 | {
|
---|
2106 | /* We have already expanded this BFD. */
|
---|
2107 | return nbfd;
|
---|
2108 | }
|
---|
2109 |
|
---|
2110 | tdata = (struct areltdata *) nbfd->arelt_data;
|
---|
2111 | hdr = (struct ar_hdr *) tdata->arch_header;
|
---|
2112 | if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
|
---|
2113 | return nbfd;
|
---|
2114 |
|
---|
2115 | /* We must uncompress this element. We do this by copying it into a
|
---|
2116 | memory buffer, and making bfd_read and bfd_seek use that buffer.
|
---|
2117 | This can use a lot of memory, but it's simpler than getting a
|
---|
2118 | temporary file, making that work with the file descriptor caching
|
---|
2119 | code, and making sure that it is deleted at all appropriate
|
---|
2120 | times. It can be changed if it ever becomes important. */
|
---|
2121 |
|
---|
2122 | /* The compressed file starts with a dummy ECOFF file header. */
|
---|
2123 | if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0)
|
---|
2124 | goto error_return;
|
---|
2125 |
|
---|
2126 | /* The next eight bytes are the real file size. */
|
---|
2127 | if (bfd_read (ab, 1, 8, nbfd) != 8)
|
---|
2128 | goto error_return;
|
---|
2129 | size = bfd_h_get_64 (nbfd, ab);
|
---|
2130 |
|
---|
2131 | if (size == 0)
|
---|
2132 | buf = NULL;
|
---|
2133 | else
|
---|
2134 | {
|
---|
2135 | bfd_size_type left;
|
---|
2136 | bfd_byte dict[4096];
|
---|
2137 | unsigned int h;
|
---|
2138 | bfd_byte b;
|
---|
2139 |
|
---|
2140 | buf = (bfd_byte *) bfd_alloc (nbfd, size);
|
---|
2141 | if (buf == NULL)
|
---|
2142 | goto error_return;
|
---|
2143 | p = buf;
|
---|
2144 |
|
---|
2145 | left = size;
|
---|
2146 |
|
---|
2147 | /* I don't know what the next eight bytes are for. */
|
---|
2148 | if (bfd_read (ab, 1, 8, nbfd) != 8)
|
---|
2149 | goto error_return;
|
---|
2150 |
|
---|
2151 | /* This is the uncompression algorithm. It's a simple
|
---|
2152 | dictionary based scheme in which each character is predicted
|
---|
2153 | by a hash of the previous three characters. A control byte
|
---|
2154 | indicates whether the character is predicted or whether it
|
---|
2155 | appears in the input stream; each control byte manages the
|
---|
2156 | next eight bytes in the output stream. */
|
---|
2157 | memset (dict, 0, sizeof dict);
|
---|
2158 | h = 0;
|
---|
2159 | while (bfd_read (&b, 1, 1, nbfd) == 1)
|
---|
2160 | {
|
---|
2161 | unsigned int i;
|
---|
2162 |
|
---|
2163 | for (i = 0; i < 8; i++, b >>= 1)
|
---|
2164 | {
|
---|
2165 | bfd_byte n;
|
---|
2166 |
|
---|
2167 | if ((b & 1) == 0)
|
---|
2168 | n = dict[h];
|
---|
2169 | else
|
---|
2170 | {
|
---|
2171 | if (! bfd_read (&n, 1, 1, nbfd))
|
---|
2172 | goto error_return;
|
---|
2173 | dict[h] = n;
|
---|
2174 | }
|
---|
2175 |
|
---|
2176 | *p++ = n;
|
---|
2177 |
|
---|
2178 | --left;
|
---|
2179 | if (left == 0)
|
---|
2180 | break;
|
---|
2181 |
|
---|
2182 | h <<= 4;
|
---|
2183 | h ^= n;
|
---|
2184 | h &= sizeof dict - 1;
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 | if (left == 0)
|
---|
2188 | break;
|
---|
2189 | }
|
---|
2190 | }
|
---|
2191 |
|
---|
2192 | /* Now the uncompressed file contents are in buf. */
|
---|
2193 | bim = ((struct bfd_in_memory *)
|
---|
2194 | bfd_alloc (nbfd, sizeof (struct bfd_in_memory)));
|
---|
2195 | if (bim == NULL)
|
---|
2196 | goto error_return;
|
---|
2197 | bim->size = size;
|
---|
2198 | bim->buffer = buf;
|
---|
2199 |
|
---|
2200 | nbfd->mtime_set = true;
|
---|
2201 | nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
|
---|
2202 |
|
---|
2203 | nbfd->flags |= BFD_IN_MEMORY;
|
---|
2204 | nbfd->iostream = (PTR) bim;
|
---|
2205 | BFD_ASSERT (! nbfd->cacheable);
|
---|
2206 |
|
---|
2207 | return nbfd;
|
---|
2208 |
|
---|
2209 | error_return:
|
---|
2210 | if (nbfd != NULL)
|
---|
2211 | bfd_close (nbfd);
|
---|
2212 | return NULL;
|
---|
2213 | }
|
---|
2214 |
|
---|
2215 | /* Open the next archived file. */
|
---|
2216 |
|
---|
2217 | static bfd *
|
---|
2218 | alpha_ecoff_openr_next_archived_file (archive, last_file)
|
---|
2219 | bfd *archive;
|
---|
2220 | bfd *last_file;
|
---|
2221 | {
|
---|
2222 | file_ptr filestart;
|
---|
2223 |
|
---|
2224 | if (last_file == NULL)
|
---|
2225 | filestart = bfd_ardata (archive)->first_file_filepos;
|
---|
2226 | else
|
---|
2227 | {
|
---|
2228 | struct areltdata *t;
|
---|
2229 | struct ar_hdr *h;
|
---|
2230 | bfd_size_type size;
|
---|
2231 |
|
---|
2232 | /* We can't use arelt_size here, because that uses parsed_size,
|
---|
2233 | which is the uncompressed size. We need the compressed size. */
|
---|
2234 | t = (struct areltdata *) last_file->arelt_data;
|
---|
2235 | h = (struct ar_hdr *) t->arch_header;
|
---|
2236 | size = strtol (h->ar_size, (char **) NULL, 10);
|
---|
2237 |
|
---|
2238 | /* Pad to an even boundary...
|
---|
2239 | Note that last_file->origin can be odd in the case of
|
---|
2240 | BSD-4.4-style element with a long odd size. */
|
---|
2241 | filestart = last_file->origin + size;
|
---|
2242 | filestart += filestart % 2;
|
---|
2243 | }
|
---|
2244 |
|
---|
2245 | return alpha_ecoff_get_elt_at_filepos (archive, filestart);
|
---|
2246 | }
|
---|
2247 |
|
---|
2248 | /* Open the archive file given an index into the armap. */
|
---|
2249 |
|
---|
2250 | static bfd *
|
---|
2251 | alpha_ecoff_get_elt_at_index (abfd, index)
|
---|
2252 | bfd *abfd;
|
---|
2253 | symindex index;
|
---|
2254 | {
|
---|
2255 | carsym *entry;
|
---|
2256 |
|
---|
2257 | entry = bfd_ardata (abfd)->symdefs + index;
|
---|
2258 | return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset);
|
---|
2259 | }
|
---|
2260 | |
---|
2261 |
|
---|
2262 | /* This is the ECOFF backend structure. The backend field of the
|
---|
2263 | target vector points to this. */
|
---|
2264 |
|
---|
2265 | static const struct ecoff_backend_data alpha_ecoff_backend_data =
|
---|
2266 | {
|
---|
2267 | /* COFF backend structure. */
|
---|
2268 | {
|
---|
2269 | (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
|
---|
2270 | (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
|
---|
2271 | (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
|
---|
2272 | (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
|
---|
2273 | (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
|
---|
2274 | (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
|
---|
2275 | (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
|
---|
2276 | alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
|
---|
2277 | alpha_ecoff_swap_scnhdr_out,
|
---|
2278 | FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, true, false, 4, false, 2,
|
---|
2279 | alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
|
---|
2280 | alpha_ecoff_swap_scnhdr_in, NULL,
|
---|
2281 | alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
|
---|
2282 | alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
|
---|
2283 | _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
|
---|
2284 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
---|
2285 | NULL, NULL, NULL
|
---|
2286 | },
|
---|
2287 | /* Supported architecture. */
|
---|
2288 | bfd_arch_alpha,
|
---|
2289 | /* Initial portion of armap string. */
|
---|
2290 | "________64",
|
---|
2291 | /* The page boundary used to align sections in a demand-paged
|
---|
2292 | executable file. E.g., 0x1000. */
|
---|
2293 | 0x2000,
|
---|
2294 | /* True if the .rdata section is part of the text segment, as on the
|
---|
2295 | Alpha. False if .rdata is part of the data segment, as on the
|
---|
2296 | MIPS. */
|
---|
2297 | true,
|
---|
2298 | /* Bitsize of constructor entries. */
|
---|
2299 | 64,
|
---|
2300 | /* Reloc to use for constructor entries. */
|
---|
2301 | &alpha_howto_table[ALPHA_R_REFQUAD],
|
---|
2302 | {
|
---|
2303 | /* Symbol table magic number. */
|
---|
2304 | magicSym2,
|
---|
2305 | /* Alignment of debugging information. E.g., 4. */
|
---|
2306 | 8,
|
---|
2307 | /* Sizes of external symbolic information. */
|
---|
2308 | sizeof (struct hdr_ext),
|
---|
2309 | sizeof (struct dnr_ext),
|
---|
2310 | sizeof (struct pdr_ext),
|
---|
2311 | sizeof (struct sym_ext),
|
---|
2312 | sizeof (struct opt_ext),
|
---|
2313 | sizeof (struct fdr_ext),
|
---|
2314 | sizeof (struct rfd_ext),
|
---|
2315 | sizeof (struct ext_ext),
|
---|
2316 | /* Functions to swap in external symbolic data. */
|
---|
2317 | ecoff_swap_hdr_in,
|
---|
2318 | ecoff_swap_dnr_in,
|
---|
2319 | ecoff_swap_pdr_in,
|
---|
2320 | ecoff_swap_sym_in,
|
---|
2321 | ecoff_swap_opt_in,
|
---|
2322 | ecoff_swap_fdr_in,
|
---|
2323 | ecoff_swap_rfd_in,
|
---|
2324 | ecoff_swap_ext_in,
|
---|
2325 | _bfd_ecoff_swap_tir_in,
|
---|
2326 | _bfd_ecoff_swap_rndx_in,
|
---|
2327 | /* Functions to swap out external symbolic data. */
|
---|
2328 | ecoff_swap_hdr_out,
|
---|
2329 | ecoff_swap_dnr_out,
|
---|
2330 | ecoff_swap_pdr_out,
|
---|
2331 | ecoff_swap_sym_out,
|
---|
2332 | ecoff_swap_opt_out,
|
---|
2333 | ecoff_swap_fdr_out,
|
---|
2334 | ecoff_swap_rfd_out,
|
---|
2335 | ecoff_swap_ext_out,
|
---|
2336 | _bfd_ecoff_swap_tir_out,
|
---|
2337 | _bfd_ecoff_swap_rndx_out,
|
---|
2338 | /* Function to read in symbolic data. */
|
---|
2339 | _bfd_ecoff_slurp_symbolic_info
|
---|
2340 | },
|
---|
2341 | /* External reloc size. */
|
---|
2342 | RELSZ,
|
---|
2343 | /* Reloc swapping functions. */
|
---|
2344 | alpha_ecoff_swap_reloc_in,
|
---|
2345 | alpha_ecoff_swap_reloc_out,
|
---|
2346 | /* Backend reloc tweaking. */
|
---|
2347 | alpha_adjust_reloc_in,
|
---|
2348 | alpha_adjust_reloc_out,
|
---|
2349 | /* Relocate section contents while linking. */
|
---|
2350 | alpha_relocate_section,
|
---|
2351 | /* Do final adjustments to filehdr and aouthdr. */
|
---|
2352 | alpha_adjust_headers,
|
---|
2353 | /* Read an element from an archive at a given file position. */
|
---|
2354 | alpha_ecoff_get_elt_at_filepos
|
---|
2355 | };
|
---|
2356 |
|
---|
2357 | /* Looking up a reloc type is Alpha specific. */
|
---|
2358 | #define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
|
---|
2359 |
|
---|
2360 | /* So is getting relocated section contents. */
|
---|
2361 | #define _bfd_ecoff_bfd_get_relocated_section_contents \
|
---|
2362 | alpha_ecoff_get_relocated_section_contents
|
---|
2363 |
|
---|
2364 | /* Handling file windows is generic. */
|
---|
2365 | #define _bfd_ecoff_get_section_contents_in_window \
|
---|
2366 | _bfd_generic_get_section_contents_in_window
|
---|
2367 |
|
---|
2368 | /* Relaxing sections is generic. */
|
---|
2369 | #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
|
---|
2370 | #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
|
---|
2371 |
|
---|
2372 | const bfd_target ecoffalpha_little_vec =
|
---|
2373 | {
|
---|
2374 | "ecoff-littlealpha", /* name */
|
---|
2375 | bfd_target_ecoff_flavour,
|
---|
2376 | BFD_ENDIAN_LITTLE, /* data byte order is little */
|
---|
2377 | BFD_ENDIAN_LITTLE, /* header byte order is little */
|
---|
2378 |
|
---|
2379 | (HAS_RELOC | EXEC_P | /* object flags */
|
---|
2380 | HAS_LINENO | HAS_DEBUG |
|
---|
2381 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
---|
2382 |
|
---|
2383 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
---|
2384 | 0, /* leading underscore */
|
---|
2385 | ' ', /* ar_pad_char */
|
---|
2386 | 15, /* ar_max_namelen */
|
---|
2387 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
---|
2388 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
---|
2389 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
---|
2390 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
---|
2391 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
---|
2392 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
---|
2393 |
|
---|
2394 | {_bfd_dummy_target, alpha_ecoff_object_p, /* bfd_check_format */
|
---|
2395 | _bfd_ecoff_archive_p, _bfd_dummy_target},
|
---|
2396 | {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
|
---|
2397 | _bfd_generic_mkarchive, bfd_false},
|
---|
2398 | {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
|
---|
2399 | _bfd_write_archive_contents, bfd_false},
|
---|
2400 |
|
---|
2401 | BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
|
---|
2402 | BFD_JUMP_TABLE_COPY (_bfd_ecoff),
|
---|
2403 | BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
---|
2404 | BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff),
|
---|
2405 | BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
|
---|
2406 | BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
|
---|
2407 | BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
|
---|
2408 | BFD_JUMP_TABLE_LINK (_bfd_ecoff),
|
---|
2409 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
---|
2410 |
|
---|
2411 | NULL,
|
---|
2412 |
|
---|
2413 | (PTR) &alpha_ecoff_backend_data
|
---|
2414 | };
|
---|