Commit | Line | Data |
---|---|---|
0eddce27 | 1 | /* Intel 960 specific support for 32-bit ELF |
1049f94e | 2 | Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
b2ef150d ILT |
3 | |
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "bfd.h" | |
21 | #include "sysdep.h" | |
22 | #include "libbfd.h" | |
23 | #include "elf-bfd.h" | |
24 | #include "elf/i960.h" | |
25 | ||
26 | static bfd_reloc_status_type elf32_i960_relocate | |
27 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
28 | static reloc_howto_type *elf32_i960_reloc_type_lookup | |
29 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
5a65713f | 30 | static void elf32_i960_info_to_howto |
947216bf | 31 | PARAMS ((bfd *, arelent *cache_ptr, Elf_Internal_Rela *)); |
5a65713f | 32 | static void elf32_i960_info_to_howto_rel |
947216bf | 33 | PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); |
b2ef150d ILT |
34 | |
35 | #define USE_REL 1 | |
36 | ||
37 | #define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup | |
38 | #define elf_info_to_howto elf32_i960_info_to_howto | |
39 | #define elf_info_to_howto_rel elf32_i960_info_to_howto_rel | |
40 | ||
41 | static reloc_howto_type elf_howto_table[]= | |
42 | { | |
b34976b6 AM |
43 | HOWTO(R_960_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield, |
44 | elf32_i960_relocate, "R_960_NONE", TRUE, | |
45 | 0x00000000, 0x00000000, FALSE), | |
5f771d47 | 46 | EMPTY_HOWTO (1), |
b34976b6 AM |
47 | HOWTO (R_960_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, |
48 | elf32_i960_relocate, "R_960_32", TRUE, | |
49 | 0xffffffff, 0xffffffff, FALSE), | |
50 | HOWTO (R_960_IP24, 0, 2, 24, TRUE, 0, complain_overflow_signed, | |
51 | elf32_i960_relocate, "R_960_IP24 ", TRUE, | |
52 | 0x00ffffff, 0x00ffffff, FALSE), | |
5f771d47 ILT |
53 | EMPTY_HOWTO (4), |
54 | EMPTY_HOWTO (5), | |
55 | EMPTY_HOWTO (6), | |
56 | EMPTY_HOWTO (7) | |
b2ef150d ILT |
57 | }; |
58 | ||
59 | static enum elf_i960_reloc_type | |
60 | elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code) | |
61 | { | |
62 | switch (code) | |
63 | { | |
64 | default: | |
65 | return R_960_NONE; | |
66 | case BFD_RELOC_I960_CALLJ: | |
67 | return R_960_OPTCALL; | |
68 | case BFD_RELOC_32: | |
69 | case BFD_RELOC_CTOR: | |
70 | return R_960_32; | |
71 | case BFD_RELOC_24_PCREL: | |
72 | return R_960_IP24; | |
73 | } | |
74 | } | |
75 | ||
76 | static void | |
77 | elf32_i960_info_to_howto (abfd, cache_ptr, dst) | |
5f771d47 ILT |
78 | bfd *abfd ATTRIBUTE_UNUSED; |
79 | arelent *cache_ptr ATTRIBUTE_UNUSED; | |
947216bf | 80 | Elf_Internal_Rela *dst ATTRIBUTE_UNUSED; |
b2ef150d ILT |
81 | { |
82 | abort (); | |
83 | } | |
84 | ||
85 | static void | |
86 | elf32_i960_info_to_howto_rel (abfd, cache_ptr, dst) | |
5f771d47 | 87 | bfd *abfd ATTRIBUTE_UNUSED; |
b2ef150d | 88 | arelent *cache_ptr; |
947216bf | 89 | Elf_Internal_Rela *dst; |
b2ef150d ILT |
90 | { |
91 | enum elf_i960_reloc_type type; | |
92 | ||
93 | type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info); | |
94 | BFD_ASSERT (type < R_960_max); | |
95 | ||
96 | cache_ptr->howto = &elf_howto_table[(int) type]; | |
97 | } | |
98 | ||
1049f94e | 99 | /* ELF relocs are against symbols. If we are producing relocatable |
b2ef150d ILT |
100 | output, and the reloc is against an external symbol, and nothing |
101 | has given us any additional addend, the resulting reloc will also | |
102 | be against the same symbol. In such a case, we don't want to | |
103 | change anything about the way the reloc is handled, since it will | |
104 | all be done at final link time. Rather than put special case code | |
105 | into bfd_perform_relocation, all the reloc types use this howto | |
106 | function. It just short circuits the reloc if producing | |
1049f94e | 107 | relocatable output against an external symbol. */ |
b2ef150d | 108 | |
b2ef150d | 109 | bfd_reloc_status_type |
0eddce27 AM |
110 | elf32_i960_relocate (abfd, reloc_entry, symbol, data, input_section, |
111 | output_bfd, error_message) | |
5f771d47 | 112 | bfd *abfd ATTRIBUTE_UNUSED; |
b2ef150d ILT |
113 | arelent *reloc_entry; |
114 | asymbol *symbol; | |
5f771d47 | 115 | PTR data ATTRIBUTE_UNUSED; |
b2ef150d ILT |
116 | asection *input_section; |
117 | bfd *output_bfd; | |
5f771d47 | 118 | char **error_message ATTRIBUTE_UNUSED; |
b2ef150d ILT |
119 | { |
120 | /* HACK: I think this first condition is necessary when producing | |
121 | relocatable output. After the end of HACK, the code is identical | |
122 | to bfd_elf_generic_reloc(). I would _guess_ the first change | |
123 | belongs there rather than here. martindo 1998-10-23. */ | |
124 | if (output_bfd != (bfd *) NULL | |
125 | && reloc_entry->howto->pc_relative | |
126 | && !reloc_entry->howto->pcrel_offset) | |
127 | { | |
128 | reloc_entry->addend -= symbol->value; | |
129 | } | |
6609fa74 | 130 | /* This is more dubious. */ |
b2ef150d ILT |
131 | else if (output_bfd != (bfd *) NULL |
132 | && (symbol->flags & BSF_SECTION_SYM) != 0) | |
133 | { | |
134 | reloc_entry->addend -= symbol->section->output_section->vma; | |
135 | } | |
136 | else | |
137 | { | |
138 | /* end of HACK */ | |
139 | if (output_bfd != (bfd *) NULL | |
140 | && (symbol->flags & BSF_SECTION_SYM) == 0 | |
141 | && (! reloc_entry->howto->partial_inplace | |
142 | || reloc_entry->addend == 0)) | |
143 | { | |
144 | reloc_entry->address += input_section->output_offset; | |
145 | return bfd_reloc_ok; | |
146 | } | |
147 | } | |
148 | ||
149 | return bfd_reloc_continue; | |
150 | } | |
151 | ||
152 | static reloc_howto_type * | |
153 | elf32_i960_reloc_type_lookup (abfd, code) | |
5f771d47 | 154 | bfd *abfd ATTRIBUTE_UNUSED; |
b2ef150d ILT |
155 | bfd_reloc_code_real_type code; |
156 | { | |
157 | return elf_howto_table + elf32_i960_bfd_to_reloc_type (code); | |
158 | } | |
159 | ||
160 | #define TARGET_LITTLE_SYM bfd_elf32_i960_vec | |
161 | #define TARGET_LITTLE_NAME "elf32-i960" | |
162 | #define ELF_ARCH bfd_arch_i960 | |
163 | #define ELF_MACHINE_CODE EM_960 | |
79e5982f | 164 | #define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */ |
b2ef150d ILT |
165 | |
166 | #include "elf32-target.h" |