00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "bfd.h"
00021 #include "sysdep.h"
00022 #include "libbfd.h"
00023 #include "elf-bfd.h"
00024 #include "elf/i960.h"
00025
00026 static bfd_reloc_status_type elf32_i960_relocate
00027 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
00028 static reloc_howto_type *elf32_i960_reloc_type_lookup
00029 PARAMS ((bfd *, bfd_reloc_code_real_type));
00030 static void elf32_i960_info_to_howto
00031 PARAMS ((bfd *, arelent *cache_ptr, Elf_Internal_Rela *));
00032 static void elf32_i960_info_to_howto_rel
00033 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
00034
00035 #define USE_REL 1
00036
00037 #define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup
00038 #define elf_info_to_howto elf32_i960_info_to_howto
00039 #define elf_info_to_howto_rel elf32_i960_info_to_howto_rel
00040
00041 static reloc_howto_type elf_howto_table[]=
00042 {
00043 HOWTO(R_960_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
00044 elf32_i960_relocate, "R_960_NONE", TRUE,
00045 0x00000000, 0x00000000, FALSE),
00046 EMPTY_HOWTO (1),
00047 HOWTO (R_960_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
00048 elf32_i960_relocate, "R_960_32", TRUE,
00049 0xffffffff, 0xffffffff, FALSE),
00050 HOWTO (R_960_IP24, 0, 2, 24, TRUE, 0, complain_overflow_signed,
00051 elf32_i960_relocate, "R_960_IP24 ", TRUE,
00052 0x00ffffff, 0x00ffffff, FALSE),
00053 EMPTY_HOWTO (4),
00054 EMPTY_HOWTO (5),
00055 EMPTY_HOWTO (6),
00056 EMPTY_HOWTO (7)
00057 };
00058
00059 static enum elf_i960_reloc_type
00060 elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code)
00061 {
00062 switch (code)
00063 {
00064 default:
00065 return R_960_NONE;
00066 case BFD_RELOC_I960_CALLJ:
00067 return R_960_OPTCALL;
00068 case BFD_RELOC_32:
00069 case BFD_RELOC_CTOR:
00070 return R_960_32;
00071 case BFD_RELOC_24_PCREL:
00072 return R_960_IP24;
00073 }
00074 }
00075
00076 static void
00077 elf32_i960_info_to_howto (abfd, cache_ptr, dst)
00078 bfd *abfd ATTRIBUTE_UNUSED;
00079 arelent *cache_ptr ATTRIBUTE_UNUSED;
00080 Elf_Internal_Rela *dst ATTRIBUTE_UNUSED;
00081 {
00082 abort ();
00083 }
00084
00085 static void
00086 elf32_i960_info_to_howto_rel (abfd, cache_ptr, dst)
00087 bfd *abfd ATTRIBUTE_UNUSED;
00088 arelent *cache_ptr;
00089 Elf_Internal_Rela *dst;
00090 {
00091 enum elf_i960_reloc_type type;
00092
00093 type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info);
00094 BFD_ASSERT (type < R_960_max);
00095
00096 cache_ptr->howto = &elf_howto_table[(int) type];
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 bfd_reloc_status_type
00110 elf32_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
00111 output_bfd, error_message)
00112 bfd *abfd ATTRIBUTE_UNUSED;
00113 arelent *reloc_entry;
00114 asymbol *symbol;
00115 PTR data ATTRIBUTE_UNUSED;
00116 asection *input_section;
00117 bfd *output_bfd;
00118 char **error_message ATTRIBUTE_UNUSED;
00119 {
00120
00121
00122
00123
00124 if (output_bfd != (bfd *) NULL
00125 && reloc_entry->howto->pc_relative
00126 && !reloc_entry->howto->pcrel_offset)
00127 {
00128 reloc_entry->addend -= symbol->value;
00129 }
00130
00131 else if (output_bfd != (bfd *) NULL
00132 && (symbol->flags & BSF_SECTION_SYM) != 0)
00133 {
00134 reloc_entry->addend -= symbol->section->output_section->vma;
00135 }
00136 else
00137 {
00138
00139 if (output_bfd != (bfd *) NULL
00140 && (symbol->flags & BSF_SECTION_SYM) == 0
00141 && (! reloc_entry->howto->partial_inplace
00142 || reloc_entry->addend == 0))
00143 {
00144 reloc_entry->address += input_section->output_offset;
00145 return bfd_reloc_ok;
00146 }
00147 }
00148
00149 return bfd_reloc_continue;
00150 }
00151
00152 static reloc_howto_type *
00153 elf32_i960_reloc_type_lookup (abfd, code)
00154 bfd *abfd ATTRIBUTE_UNUSED;
00155 bfd_reloc_code_real_type code;
00156 {
00157 return elf_howto_table + elf32_i960_bfd_to_reloc_type (code);
00158 }
00159
00160 #define TARGET_LITTLE_SYM bfd_elf32_i960_vec
00161 #define TARGET_LITTLE_NAME "elf32-i960"
00162 #define ELF_ARCH bfd_arch_i960
00163 #define ELF_MACHINE_CODE EM_960
00164 #define ELF_MAXPAGESIZE 1
00165
00166 #include "elf32-target.h"