1 /* ARC-specific support for 32-bit ELF
2 Copyright (C) 1994 Free Software Foundation, Inc.
3 Contributed by Doug Evans (dje@cygnus.com).
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 static bfd_reloc_status_type arc_elf_unsupported_reloc
27 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
28 static const struct reloc_howto_struct
*bfd_elf32_bfd_reloc_type_lookup
29 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
30 static void arc_info_to_howto
31 PARAMS ((bfd
*abfd
, arelent
*cache_ptr
, Elf32_Internal_Rela
*dst
));
41 static reloc_howto_type elf_arc_howto_table
[] =
43 /* This reloc does nothing. */
44 HOWTO (R_ARC_NONE
, /* type */
46 2, /* size (0 = byte, 1 = short, 2 = long) */
48 false, /* pc_relative */
50 complain_overflow_bitfield
, /* complain_on_overflow */
51 bfd_elf_generic_reloc
, /* special_function */
52 "R_ARC_NONE", /* name */
53 false, /* partial_inplace */
56 false), /* pcrel_offset */
58 /* A standard 32 bit relocation. */
59 HOWTO (R_ARC_ADDR32
, /* type */
61 2, /* size (0 = byte, 1 = short, 2 = long) */
63 false, /* pc_relative */
65 complain_overflow_bitfield
, /* complain_on_overflow */
66 bfd_elf_generic_reloc
, /* special_function */
67 "R_ARC_ADDR32", /* name */
68 false, /* partial_inplace */
70 0xffffffff, /* dst_mask */
71 false), /* pcrel_offset */
73 /* A relative 22 bit branch; the lower two bits must be zero. */
74 HOWTO (R_ARC_B22_PCREL
, /* type */
76 2, /* size (0 = byte, 1 = short, 2 = long) */
78 true, /* pc_relative */
80 complain_overflow_signed
, /* complain_on_overflow */
81 bfd_elf_generic_reloc
, /* special_function */
82 "R_ARC_B22_PCREL", /* name */
83 false, /* partial_inplace */
85 0x07ffff80, /* dst_mask */
86 true), /* pcrel_offset */
90 /* Don't pretend we can deal with unsupported relocs. */
92 static bfd_reloc_status_type
93 arc_elf_unsupported_reloc (abfd
, reloc_entry
, symbol
, data
, input_section
,
94 output_bfd
, error_message
)
99 asection
*input_section
;
101 char **error_message
;
106 /* Map BFD reloc types to PowerPC ELF reloc types. */
110 unsigned char bfd_reloc_val
;
111 unsigned char elf_reloc_val
;
114 static const struct arc_reloc_map arc_reloc_map
[] =
116 { BFD_RELOC_NONE
, R_ARC_NONE
, },
117 { BFD_RELOC_32
, R_ARC_ADDR32
},
118 { BFD_RELOC_CTOR
, R_ARC_ADDR32
},
119 { BFD_RELOC_ARC_B22_PCREL
, R_ARC_B22_PCREL
},
122 static const struct reloc_howto_struct
*
123 bfd_elf32_bfd_reloc_type_lookup (abfd
, code
)
125 bfd_reloc_code_real_type code
;
130 i
< sizeof (arc_reloc_map
) / sizeof (struct arc_reloc_map
);
133 if (arc_reloc_map
[i
].bfd_reloc_val
== code
)
134 return &elf_arc_howto_table
[arc_reloc_map
[i
].elf_reloc_val
];
140 /* Set the howto pointer for an ARC ELF reloc. */
143 arc_info_to_howto (abfd
, cache_ptr
, dst
)
146 Elf32_Internal_Rela
*dst
;
148 BFD_ASSERT (ELF32_R_TYPE (dst
->r_info
) < (unsigned int) R_ARC_max
);
149 cache_ptr
->howto
= &elf_arc_howto_table
[ELF32_R_TYPE (dst
->r_info
)];
152 #define TARGET_BIG_SYM bfd_elf32_arc_vec
153 #define TARGET_BIG_NAME "elf32-arc"
154 #define ELF_ARCH bfd_arch_arc
155 #define ELF_MACHINE_CODE EM_CYGNUS_ARC
156 #define ELF_MAXPAGESIZE 0x10000
157 #define elf_info_to_howto arc_info_to_howto
159 #include "elf32-target.h"