Missing ChangeLog and files for commit 8b00c176168dc7b0d78d0dc1f7d42f915375dc4a
[deliverable/binutils-gdb.git] / bfd / elf32-i960.c
CommitLineData
0eddce27 1/* Intel 960 specific support for 32-bit ELF
2571583a 2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
b2ef150d 3
47b0e7ad 4 This file is part of BFD, the Binary File Descriptor library.
b2ef150d 5
47b0e7ad
NC
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
cd123cb7 8 the Free Software Foundation; either version 3 of the License, or
47b0e7ad 9 (at your option) any later version.
b2ef150d 10
47b0e7ad
NC
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.
b2ef150d 15
47b0e7ad
NC
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., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
b2ef150d 20
b2ef150d 21#include "sysdep.h"
3db64b00 22#include "bfd.h"
b2ef150d
ILT
23#include "libbfd.h"
24#include "elf-bfd.h"
25#include "elf/i960.h"
26
b2ef150d
ILT
27#define USE_REL 1
28
29#define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup
157090f7
AM
30#define bfd_elf32_bfd_reloc_name_lookup \
31 elf32_i960_reloc_name_lookup
b2ef150d
ILT
32#define elf_info_to_howto elf32_i960_info_to_howto
33#define elf_info_to_howto_rel elf32_i960_info_to_howto_rel
34
47b0e7ad
NC
35/* ELF relocs are against symbols. If we are producing relocatable
36 output, and the reloc is against an external symbol, and nothing
37 has given us any additional addend, the resulting reloc will also
38 be against the same symbol. In such a case, we don't want to
39 change anything about the way the reloc is handled, since it will
40 all be done at final link time. Rather than put special case code
41 into bfd_perform_relocation, all the reloc types use this howto
42 function. It just short circuits the reloc if producing
43 relocatable output against an external symbol. */
44
45static bfd_reloc_status_type
46elf32_i960_relocate (bfd *abfd ATTRIBUTE_UNUSED,
47 arelent *reloc_entry,
48 asymbol *symbol,
2c3fc389 49 void * data ATTRIBUTE_UNUSED,
47b0e7ad
NC
50 asection *input_section,
51 bfd *output_bfd,
52 char **error_message ATTRIBUTE_UNUSED)
53{
54 /* HACK: I think this first condition is necessary when producing
55 relocatable output. After the end of HACK, the code is identical
56 to bfd_elf_generic_reloc(). I would _guess_ the first change
57 belongs there rather than here. martindo 1998-10-23. */
58 if (output_bfd != (bfd *) NULL
59 && reloc_entry->howto->pc_relative
60 && !reloc_entry->howto->pcrel_offset)
61 reloc_entry->addend -= symbol->value;
62
63 /* This is more dubious. */
64 else if (output_bfd != (bfd *) NULL
65 && (symbol->flags & BSF_SECTION_SYM) != 0)
66 reloc_entry->addend -= symbol->section->output_section->vma;
67
68 else
69 {
70 /* ...end of HACK. */
71 if (output_bfd != (bfd *) NULL
72 && (symbol->flags & BSF_SECTION_SYM) == 0
73 && (! reloc_entry->howto->partial_inplace
74 || reloc_entry->addend == 0))
75 {
76 reloc_entry->address += input_section->output_offset;
77 return bfd_reloc_ok;
78 }
79 }
80
81 return bfd_reloc_continue;
82}
83
b2ef150d
ILT
84static reloc_howto_type elf_howto_table[]=
85{
6346d5ca 86 HOWTO (R_960_NONE, 0, 3, 0, FALSE, 0, complain_overflow_dont,
47b0e7ad
NC
87 elf32_i960_relocate, "R_960_NONE", TRUE,
88 0x00000000, 0x00000000, FALSE),
5f771d47 89 EMPTY_HOWTO (1),
b34976b6 90 HOWTO (R_960_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
47b0e7ad
NC
91 elf32_i960_relocate, "R_960_32", TRUE,
92 0xffffffff, 0xffffffff, FALSE),
b34976b6 93 HOWTO (R_960_IP24, 0, 2, 24, TRUE, 0, complain_overflow_signed,
47b0e7ad
NC
94 elf32_i960_relocate, "R_960_IP24 ", TRUE,
95 0x00ffffff, 0x00ffffff, FALSE),
5f771d47
ILT
96 EMPTY_HOWTO (4),
97 EMPTY_HOWTO (5),
98 EMPTY_HOWTO (6),
99 EMPTY_HOWTO (7)
b2ef150d
ILT
100};
101
102static enum elf_i960_reloc_type
103elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code)
104{
105 switch (code)
106 {
107 default:
108 return R_960_NONE;
109 case BFD_RELOC_I960_CALLJ:
110 return R_960_OPTCALL;
111 case BFD_RELOC_32:
112 case BFD_RELOC_CTOR:
113 return R_960_32;
114 case BFD_RELOC_24_PCREL:
115 return R_960_IP24;
116 }
117}
118
119static void
47b0e7ad
NC
120elf32_i960_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
121 arelent * cache_ptr ATTRIBUTE_UNUSED,
122 Elf_Internal_Rela * dst ATTRIBUTE_UNUSED)
b2ef150d
ILT
123{
124 abort ();
125}
126
127static void
47b0e7ad
NC
128elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
129 arelent *cache_ptr,
130 Elf_Internal_Rela *dst)
b2ef150d
ILT
131{
132 enum elf_i960_reloc_type type;
133
134 type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info);
5860e3f8
NC
135
136 /* PR 17521: file: 9609b8d6. */
137 if (type >= R_960_max)
138 {
695344c0 139 /* xgettext:c-format */
64d29018 140 _bfd_error_handler (_("%B: invalid i960 reloc number: %d"), abfd, type);
5860e3f8
NC
141 type = 0;
142 }
b2ef150d
ILT
143
144 cache_ptr->howto = &elf_howto_table[(int) type];
145}
146
b2ef150d 147static reloc_howto_type *
47b0e7ad
NC
148elf32_i960_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
149 bfd_reloc_code_real_type code)
b2ef150d
ILT
150{
151 return elf_howto_table + elf32_i960_bfd_to_reloc_type (code);
152}
153
157090f7
AM
154static reloc_howto_type *
155elf32_i960_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
156 const char *r_name)
157{
158 unsigned int i;
159
160 for (i = 0; i < sizeof (elf_howto_table) / sizeof (elf_howto_table[0]); i++)
161 if (elf_howto_table[i].name != NULL
162 && strcasecmp (elf_howto_table[i].name, r_name) == 0)
163 return &elf_howto_table[i];
164
165 return NULL;
166}
167
6d00b590 168#define TARGET_LITTLE_SYM i960_elf32_vec
b2ef150d
ILT
169#define TARGET_LITTLE_NAME "elf32-i960"
170#define ELF_ARCH bfd_arch_i960
171#define ELF_MACHINE_CODE EM_960
79e5982f 172#define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */
b2ef150d
ILT
173
174#include "elf32-target.h"
This page took 0.803756 seconds and 4 git commands to generate.