No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / bfd / elf32-i960.c
blobf458320655b4fd092dda902d405be9239cf984d7
1 /* Intel 960 specific support for 32-bit ELF
2 Copyright 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
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.
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. */
21 #include "bfd.h"
22 #include "sysdep.h"
23 #include "libbfd.h"
24 #include "elf-bfd.h"
25 #include "elf/i960.h"
27 #define USE_REL 1
29 #define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup
30 #define elf_info_to_howto elf32_i960_info_to_howto
31 #define elf_info_to_howto_rel elf32_i960_info_to_howto_rel
33 /* ELF relocs are against symbols. If we are producing relocatable
34 output, and the reloc is against an external symbol, and nothing
35 has given us any additional addend, the resulting reloc will also
36 be against the same symbol. In such a case, we don't want to
37 change anything about the way the reloc is handled, since it will
38 all be done at final link time. Rather than put special case code
39 into bfd_perform_relocation, all the reloc types use this howto
40 function. It just short circuits the reloc if producing
41 relocatable output against an external symbol. */
43 static bfd_reloc_status_type
44 elf32_i960_relocate (bfd *abfd ATTRIBUTE_UNUSED,
45 arelent *reloc_entry,
46 asymbol *symbol,
47 PTR data ATTRIBUTE_UNUSED,
48 asection *input_section,
49 bfd *output_bfd,
50 char **error_message ATTRIBUTE_UNUSED)
52 /* HACK: I think this first condition is necessary when producing
53 relocatable output. After the end of HACK, the code is identical
54 to bfd_elf_generic_reloc(). I would _guess_ the first change
55 belongs there rather than here. martindo 1998-10-23. */
56 if (output_bfd != (bfd *) NULL
57 && reloc_entry->howto->pc_relative
58 && !reloc_entry->howto->pcrel_offset)
59 reloc_entry->addend -= symbol->value;
61 /* This is more dubious. */
62 else if (output_bfd != (bfd *) NULL
63 && (symbol->flags & BSF_SECTION_SYM) != 0)
64 reloc_entry->addend -= symbol->section->output_section->vma;
66 else
68 /* ...end of HACK. */
69 if (output_bfd != (bfd *) NULL
70 && (symbol->flags & BSF_SECTION_SYM) == 0
71 && (! reloc_entry->howto->partial_inplace
72 || reloc_entry->addend == 0))
74 reloc_entry->address += input_section->output_offset;
75 return bfd_reloc_ok;
79 return bfd_reloc_continue;
82 static reloc_howto_type elf_howto_table[]=
84 HOWTO (R_960_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
85 elf32_i960_relocate, "R_960_NONE", TRUE,
86 0x00000000, 0x00000000, FALSE),
87 EMPTY_HOWTO (1),
88 HOWTO (R_960_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
89 elf32_i960_relocate, "R_960_32", TRUE,
90 0xffffffff, 0xffffffff, FALSE),
91 HOWTO (R_960_IP24, 0, 2, 24, TRUE, 0, complain_overflow_signed,
92 elf32_i960_relocate, "R_960_IP24 ", TRUE,
93 0x00ffffff, 0x00ffffff, FALSE),
94 EMPTY_HOWTO (4),
95 EMPTY_HOWTO (5),
96 EMPTY_HOWTO (6),
97 EMPTY_HOWTO (7)
100 static enum elf_i960_reloc_type
101 elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code)
103 switch (code)
105 default:
106 return R_960_NONE;
107 case BFD_RELOC_I960_CALLJ:
108 return R_960_OPTCALL;
109 case BFD_RELOC_32:
110 case BFD_RELOC_CTOR:
111 return R_960_32;
112 case BFD_RELOC_24_PCREL:
113 return R_960_IP24;
117 static void
118 elf32_i960_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
119 arelent * cache_ptr ATTRIBUTE_UNUSED,
120 Elf_Internal_Rela * dst ATTRIBUTE_UNUSED)
122 abort ();
125 static void
126 elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
127 arelent *cache_ptr,
128 Elf_Internal_Rela *dst)
130 enum elf_i960_reloc_type type;
132 type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info);
133 BFD_ASSERT (type < R_960_max);
135 cache_ptr->howto = &elf_howto_table[(int) type];
138 static reloc_howto_type *
139 elf32_i960_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
140 bfd_reloc_code_real_type code)
142 return elf_howto_table + elf32_i960_bfd_to_reloc_type (code);
145 #define TARGET_LITTLE_SYM bfd_elf32_i960_vec
146 #define TARGET_LITTLE_NAME "elf32-i960"
147 #define ELF_ARCH bfd_arch_i960
148 #define ELF_MACHINE_CODE EM_960
149 #define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */
151 #include "elf32-target.h"