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