1 /* D10V-specific support for 32-bit ELF
2 Copyright (C) 1996 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
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
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 /* #include "elf/d10v.h" */
27 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
28 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
29 static void d10v_info_to_howto_rel
30 PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
33 /* Use REL instead of RELA to save space */
47 static reloc_howto_type elf_d10v_howto_table[] =
49 /* This reloc does nothing. */
50 HOWTO (R_D10V_NONE, /* type */
52 2, /* size (0 = byte, 1 = short, 2 = long) */
54 false, /* pc_relative */
56 complain_overflow_bitfield, /* complain_on_overflow */
57 bfd_elf_generic_reloc, /* special_function */
58 "R_D10V_NONE", /* name */
59 false, /* partial_inplace */
62 false), /* pcrel_offset */
64 /* An PC Relative 10-bit relocation, shifted by 2 */
66 HOWTO (R_D10V_10_PCREL_R, /* type */
68 2, /* size (0 = byte, 1 = short, 2 = long) */
70 true, /* pc_relative */
72 complain_overflow_bitfield, /* complain_on_overflow */
73 bfd_elf_generic_reloc, /* special_function */
74 "R_D10V_10_PCREL_R", /* name */
75 false, /* partial_inplace */
78 true), /* pcrel_offset */
80 /* An PC Relative 10-bit relocation, shifted by 2 */
82 HOWTO (R_D10V_10_PCREL_L, /* type */
84 2, /* size (0 = byte, 1 = short, 2 = long) */
86 true, /* pc_relative */
88 complain_overflow_bitfield, /* complain_on_overflow */
89 bfd_elf_generic_reloc, /* special_function */
90 "R_D10V_10_PCREL_L", /* name */
91 false, /* partial_inplace */
92 0x07f8000, /* src_mask */
93 0x07f8000, /* dst_mask */
94 true), /* pcrel_offset */
96 /* A 16 bit absolute relocation */
97 HOWTO (R_D10V_16, /* type */
99 2, /* size (0 = byte, 1 = short, 2 = long) */
101 false, /* pc_relative */
103 complain_overflow_bitfield, /* complain_on_overflow */
104 bfd_elf_generic_reloc, /* special_function */
105 "R_D10V_16", /* name */
106 false, /* partial_inplace */
107 0xffff, /* src_mask */
108 0xffff, /* dst_mask */
109 false), /* pcrel_offset */
111 /* An 18 bit absolute relocation, right shifted 2 */
112 HOWTO (R_D10V_18, /* type */
114 2, /* size (0 = byte, 1 = short, 2 = long) */
116 false, /* pc_relative */
118 complain_overflow_bitfield, /* complain_on_overflow */
119 bfd_elf_generic_reloc, /* special_function */
120 "R_D10V_18", /* name */
121 false, /* partial_inplace */
122 0xffff, /* src_mask */
123 0xffff, /* dst_mask */
124 false), /* pcrel_offset */
126 /* A relative 18 bit relocation, right shifted by 2 */
127 HOWTO (R_D10V_18_PCREL, /* type */
129 2, /* size (0 = byte, 1 = short, 2 = long) */
131 true, /* pc_relative */
133 complain_overflow_signed, /* complain_on_overflow */
134 bfd_elf_generic_reloc, /* special_function */
135 "R_D10V_18_PCREL", /* name */
136 false, /* partial_inplace */
137 0xffff, /* src_mask */
138 0xffff, /* dst_mask */
139 true), /* pcrel_offset */
143 /* Map BFD reloc types to D10V ELF reloc types. */
145 struct d10v_reloc_map
147 unsigned char bfd_reloc_val;
148 unsigned char elf_reloc_val;
151 static const struct d10v_reloc_map d10v_reloc_map[] =
153 { BFD_RELOC_NONE, R_D10V_NONE, },
154 { BFD_RELOC_D10V_10_PCREL_R, R_D10V_10_PCREL_R },
155 { BFD_RELOC_D10V_10_PCREL_L, R_D10V_10_PCREL_L },
156 { BFD_RELOC_16, R_D10V_16 },
157 { BFD_RELOC_D10V_18, R_D10V_18 },
158 { BFD_RELOC_D10V_18_PCREL, R_D10V_18_PCREL },
161 static reloc_howto_type *
162 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
164 bfd_reloc_code_real_type code;
169 i < sizeof (d10v_reloc_map) / sizeof (struct d10v_reloc_map);
172 if (d10v_reloc_map[i].bfd_reloc_val == code)
173 return &elf_d10v_howto_table[d10v_reloc_map[i].elf_reloc_val];
179 /* Set the howto pointer for an D10V ELF reloc. */
182 d10v_info_to_howto_rel (abfd, cache_ptr, dst)
185 Elf32_Internal_Rel *dst;
189 r_type = ELF32_R_TYPE (dst->r_info);
190 BFD_ASSERT (r_type < (unsigned int) R_D10V_max);
191 cache_ptr->howto = &elf_d10v_howto_table[r_type];
194 #define ELF_ARCH bfd_arch_d10v
195 #define ELF_MACHINE_CODE EM_CYGNUS_D10V
196 #define ELF_MAXPAGESIZE 0x1000
198 #define TARGET_BIG_SYM bfd_elf32_d10v_vec
199 #define TARGET_BIG_NAME "elf32-d10v"
201 #define elf_info_to_howto 0
202 #define elf_info_to_howto_rel d10v_info_to_howto_rel
203 #define elf_backend_object_p 0
204 #define elf_backend_final_write_processing 0
206 #include "elf32-target.h"