Lots of changes from David Mosberger-Tang; see ChangeLog and NOTES for details:
[deliverable/binutils-gdb.git] / bfd / elf32-arc.c
CommitLineData
82b1edf7
KR
1/* ARC-specific support for 32-bit ELF
2 Copyright (C) 1994 Free Software Foundation, Inc.
3 Contributed by Doug Evans (dje@cygnus.com).
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21#include "bfd.h"
22#include "sysdep.h"
23#include "libbfd.h"
24#include "libelf.h"
25
26static bfd_reloc_status_type arc_elf_unsupported_reloc
27 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
28static const struct reloc_howto_struct *bfd_elf32_bfd_reloc_type_lookup
29 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
30static void arc_info_to_howto
31 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
32
33enum reloc_type
34{
35 R_ARC_NONE = 0,
36 R_ARC_ADDR32,
37 R_ARC_B22_PCREL,
38 R_ARC_max
39};
40
41static reloc_howto_type elf_arc_howto_table[] =
42{
43 /* This reloc does nothing. */
44 HOWTO (R_ARC_NONE, /* type */
45 0, /* rightshift */
46 2, /* size (0 = byte, 1 = short, 2 = long) */
47 32, /* bitsize */
48 false, /* pc_relative */
49 0, /* bitpos */
50 complain_overflow_bitfield, /* complain_on_overflow */
51 bfd_elf_generic_reloc, /* special_function */
52 "R_ARC_NONE", /* name */
53 false, /* partial_inplace */
54 0, /* src_mask */
55 0, /* dst_mask */
56 false), /* pcrel_offset */
57
58 /* A standard 32 bit relocation. */
59 HOWTO (R_ARC_ADDR32, /* type */
60 0, /* rightshift */
61 2, /* size (0 = byte, 1 = short, 2 = long) */
62 32, /* bitsize */
63 false, /* pc_relative */
64 0, /* bitpos */
65 complain_overflow_bitfield, /* complain_on_overflow */
66 bfd_elf_generic_reloc, /* special_function */
67 "R_ARC_ADDR32", /* name */
68 false, /* partial_inplace */
69 0, /* src_mask */
70 0xffffffff, /* dst_mask */
71 false), /* pcrel_offset */
72
73 /* A relative 22 bit branch; the lower two bits must be zero. */
74 HOWTO (R_ARC_B22_PCREL, /* type */
75 2, /* rightshift */
76 2, /* size (0 = byte, 1 = short, 2 = long) */
77 22, /* bitsize */
78 true, /* pc_relative */
79 7, /* bitpos */
80 complain_overflow_signed, /* complain_on_overflow */
81 bfd_elf_generic_reloc, /* special_function */
82 "R_ARC_B22_PCREL", /* name */
83 false, /* partial_inplace */
84 0, /* src_mask */
85 0x07ffff80, /* dst_mask */
86 true), /* pcrel_offset */
87
88};
89
90/* Don't pretend we can deal with unsupported relocs. */
91
92static bfd_reloc_status_type
93arc_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
94 output_bfd, error_message)
95 bfd *abfd;
96 arelent *reloc_entry;
97 asymbol *symbol;
98 PTR data;
99 asection *input_section;
100 bfd *output_bfd;
101 char **error_message;
102{
103 abort ();
104}
105
106/* Map BFD reloc types to PowerPC ELF reloc types. */
107
108struct arc_reloc_map
109{
110 unsigned char bfd_reloc_val;
111 unsigned char elf_reloc_val;
112};
113
114static const struct arc_reloc_map arc_reloc_map[] =
115{
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 },
120};
121
122static const struct reloc_howto_struct *
123bfd_elf32_bfd_reloc_type_lookup (abfd, code)
124 bfd *abfd;
125 bfd_reloc_code_real_type code;
126{
127 int i;
128
129 for (i = 0;
130 i < sizeof (arc_reloc_map) / sizeof (struct arc_reloc_map);
131 i++)
132 {
133 if (arc_reloc_map[i].bfd_reloc_val == code)
134 return &elf_arc_howto_table[arc_reloc_map[i].elf_reloc_val];
135 }
136
137 return NULL;
138}
139
140/* Set the howto pointer for an ARC ELF reloc. */
141
142static void
143arc_info_to_howto (abfd, cache_ptr, dst)
144 bfd *abfd;
145 arelent *cache_ptr;
146 Elf32_Internal_Rela *dst;
147{
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)];
150}
151
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
158
159#include "elf32-target.h"
This page took 0.030111 seconds and 4 git commands to generate.