00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #define N_HEADER_IN_TEXT(x) 0
00030 #define N_TXTOFF(x) 32
00031 #define ENTRY_CAN_BE_ZERO
00032 #define TEXT_START_ADDR 0
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #define N_TXTADDR(x) ((x).a_entry & ~(bfd_vma) 0xffff)
00044
00045
00046 #define SEGMENT_SIZE 2
00047
00048
00049
00050
00051
00052
00053
00054 #define ZMAGIC_DISK_BLOCK_SIZE N_TXTOFF (0)
00055
00056
00057
00058
00059 #define TARGET_PAGE_SIZE SEGMENT_SIZE
00060 #define TARGETNAME "a.out-cris"
00061
00062
00063
00064
00065 #define N_SHARED_LIB(x) 0
00066
00067
00068 #define DEFAULT_ARCH bfd_arch_cris
00069
00070
00071
00072
00073 #define MY(OP) CONCAT2 (cris_aout_,OP)
00074 #define NAME(x, y) CONCAT3 (cris_aout,_32_,y)
00075
00076 #include "bfd.h"
00077
00078
00079 #define MY_exec_hdr_flags 1
00080
00081 #define MY_write_object_contents MY(write_object_contents)
00082 static bfd_boolean MY(write_object_contents) PARAMS ((bfd *));
00083
00084
00085 struct reloc_ext_external;
00086
00087 #define MY_swap_ext_reloc_out MY(swap_ext_reloc_out)
00088 static void MY(swap_ext_reloc_out) PARAMS ((bfd *, arelent *,
00089 struct reloc_ext_external *));
00090
00091 #define MY_swap_ext_reloc_in MY(swap_ext_reloc_in)
00092 static void MY(swap_ext_reloc_in) PARAMS ((bfd *, struct
00093 reloc_ext_external *,
00094 arelent *, asymbol **,
00095 bfd_size_type));
00096
00097 #define MY_set_sizes MY(set_sizes)
00098 static bfd_boolean MY(set_sizes) PARAMS ((bfd *));
00099
00100
00101
00102
00103
00104
00105 #define MY_set_arch_mach NAME (aout, set_arch_mach)
00106 #define SET_ARCH_MACH(BFD, EXEC) \
00107 MY_set_arch_mach (BFD, DEFAULT_ARCH, N_MACHTYPE (EXEC))
00108
00109
00110
00111 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x80
00112 #define RELOC_EXT_BITS_TYPE_LITTLE 3
00113 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 0
00114
00115 #ifndef MY_get_section_contents
00116 #define MY_get_section_contents aout_32_get_section_contents
00117 #endif
00118
00119 #define MACHTYPE_OK(mtype) ((mtype) == M_CRIS)
00120
00121
00122 #include "aout32.c"
00123 #include "aout-target.h"
00124
00125
00126
00127 static bfd_boolean
00128 MY(write_object_contents) (abfd)
00129 bfd *abfd;
00130 {
00131 struct external_exec exec_bytes;
00132 struct internal_exec *execp = exec_hdr (abfd);
00133
00134
00135
00136
00137
00138 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
00139
00140
00141
00142 if (bfd_get_arch(abfd) == bfd_arch_cris)
00143 N_SET_MACHTYPE(*execp, M_CRIS);
00144
00145 N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
00146
00147 WRITE_HEADERS (abfd, execp);
00148
00149 return TRUE;
00150 }
00151
00152
00153
00154
00155
00156 static void
00157 MY(swap_ext_reloc_out) (abfd, g, natptr)
00158 bfd *abfd;
00159 arelent *g;
00160 struct reloc_ext_external *natptr;
00161 {
00162 int r_index;
00163 int r_extern;
00164 unsigned int r_type;
00165 bfd_vma r_addend;
00166 asymbol *sym = *(g->sym_ptr_ptr);
00167 asection *output_section = sym->section->output_section;
00168
00169 PUT_WORD (abfd, g->address, natptr->r_address);
00170
00171 r_type = (unsigned int) g->howto->type;
00172
00173 r_addend = g->addend;
00174 if ((sym->flags & BSF_SECTION_SYM) != 0)
00175 r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
00176
00177
00178
00179
00180
00181
00182
00183
00184 if (bfd_is_abs_section (bfd_get_section (sym)))
00185 {
00186 r_extern = 0;
00187 r_index = N_ABS;
00188 }
00189 else if ((sym->flags & BSF_SECTION_SYM) == 0)
00190 {
00191 if (bfd_is_und_section (bfd_get_section (sym))
00192
00193 || (sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
00194 r_extern = 1;
00195 else
00196 r_extern = 0;
00197 r_index = (*(g->sym_ptr_ptr))->KEEPIT;
00198 }
00199 else
00200 {
00201
00202 r_extern = 0;
00203 r_index = output_section->target_index;
00204 }
00205
00206
00207
00208
00209 if (r_type > 2)
00210 {
00211 (*_bfd_error_handler) (_("%s: Invalid relocation type exported: %d"),
00212 bfd_get_filename (abfd), r_type);
00213
00214 bfd_set_error (bfd_error_wrong_format);
00215 }
00216
00217
00218 natptr->r_index[2] = r_index >> 16;
00219 natptr->r_index[1] = r_index >> 8;
00220 natptr->r_index[0] = r_index;
00221 natptr->r_type[0] =
00222 (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
00223 | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
00224
00225 PUT_WORD (abfd, r_addend, natptr->r_addend);
00226 }
00227
00228
00229
00230 static void
00231 MY(swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
00232 bfd *abfd;
00233 struct reloc_ext_external *bytes;
00234 arelent *cache_ptr;
00235 asymbol **symbols;
00236 bfd_size_type symcount;
00237 {
00238 unsigned int r_index;
00239 int r_extern;
00240 unsigned int r_type;
00241 struct aoutdata *su = &(abfd->tdata.aout_data->a);
00242
00243 cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
00244
00245
00246 r_index = (bytes->r_index[2] << 16)
00247 | (bytes->r_index[1] << 8)
00248 | bytes->r_index[0];
00249 r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
00250 r_type = ((bytes->r_type[0]) >> RELOC_EXT_BITS_TYPE_SH_LITTLE)
00251 & RELOC_EXT_BITS_TYPE_LITTLE;
00252
00253 if (r_type > 2)
00254 {
00255 (*_bfd_error_handler) (_("%B: Invalid relocation type imported: %d"),
00256 abfd, r_type);
00257
00258 bfd_set_error (bfd_error_wrong_format);
00259 }
00260
00261 cache_ptr->howto = howto_table_ext + r_type;
00262
00263 if (r_extern && r_index > symcount)
00264 {
00265 (*_bfd_error_handler)
00266 (_("%B: Bad relocation record imported: %d"), abfd, r_index);
00267
00268 bfd_set_error (bfd_error_wrong_format);
00269
00270
00271 r_extern = 0;
00272 r_index = N_ABS;
00273 }
00274
00275
00276
00277 MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
00278 }
00279
00280
00281
00282
00283
00284 static bfd_boolean
00285 MY(set_sizes) (abfd)
00286 bfd *abfd;
00287 {
00288
00289
00290 adata(abfd).page_size = TARGET_PAGE_SIZE;
00291 adata(abfd).segment_size = SEGMENT_SIZE;
00292 adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
00293 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
00294
00295
00296
00297
00298
00299
00300 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
00301
00302 return TRUE;
00303 }
00304
00305
00306
00307
00308
00309
00310