1 <<<<<<< 1.3 is dead
>>>>>>>
2 #define BYTES_IN_WORD 4
4 /* #define ENTRY_CAN_BE_ZERO */
5 #define N_HEADER_IN_TEXT(x) 1
6 #define N_SHARED_LIB(x) 0
8 (N_MAGIC(x) != ZMAGIC ? (x).a_entry : /* object file or NMAGIC */\
9 TEXT_START_ADDR + EXEC_BYTES_SIZE /* no padding */\
11 #define N_DATADDR(x) (N_TXTADDR(x)+N_TXTSIZE(x))
12 #define TEXT_START_ADDR 4096
13 #define PAGE_SIZE 4096
14 #define SEGMENT_SIZE PAGE_SIZE
15 #define DEFAULT_ARCH bfd_arch_mips
16 #define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
17 || (mtype) == M_MIPS1 || (mtype) == M_MIPS2)
18 #define MY_symbol_leading_char '\0'
20 #define MY(OP) CAT(mipsbsd_,OP)
27 #define SET_ARCH_MACH(ABFD, EXEC) \
28 MY(set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
29 MY(choose_reloc_size)(ABFD);
30 void MY(set_arch_mach
) PARAMS ((bfd
*abfd
, int machtype
));
31 static void MY(choose_reloc_size
) PARAMS ((bfd
*abfd
));
33 #define MY_write_object_contents MY(write_object_contents)
34 static boolean
MY(write_object_contents
) PARAMS ((bfd
*abfd
));
36 #define MY_reloc_howto_type_lookup MY(reloc_howto_type_lookup)
37 #define MY_canonicalize_reloc MY(canonicalize_reloc)
39 #define MY_backend_data &MY(backend_data)
42 #include "aout-target.h"
45 * These really should be common to all BSD systems.
46 * Also, to reduce space, should ifdef the individual cases if MINIMIZE=1.
49 MY(set_arch_mach
) (abfd
, machtype
)
53 enum bfd_architecture arch
;
56 /* Determine the architecture and machine type of the object file. */
72 arch
= bfd_arch_sparc
;
102 arch
= bfd_arch_obscure
;
106 bfd_set_arch_mach(abfd
, arch
, machine
);
109 /* Determine the size of a relocation entry, based on the architecture */
111 MY(choose_reloc_size
) (abfd
)
114 switch (bfd_get_arch(abfd
)) {
118 obj_reloc_entry_size (abfd
) = RELOC_EXT_SIZE
;
121 obj_reloc_entry_size (abfd
) = RELOC_STD_SIZE
;
126 /* Write an object file in BSD a.out format.
127 Section contents have already been written. We write the
128 file header, symbols, and relocation. */
131 MY(write_object_contents
) (abfd
)
134 struct external_exec exec_bytes
;
135 struct internal_exec
*execp
= exec_hdr (abfd
);
137 /* Magic number, maestro, please! */
138 switch (bfd_get_arch(abfd
)) {
140 switch (bfd_get_mach(abfd
)) {
142 N_SET_MACHTYPE(*execp
, M_68010
);
146 N_SET_MACHTYPE(*execp
, M_68020
);
151 N_SET_MACHTYPE(*execp
, M_SPARC
);
154 N_SET_MACHTYPE(*execp
, M_386
);
157 N_SET_MACHTYPE(*execp
, M_29K
);
160 switch (bfd_get_mach(abfd
)) {
163 N_SET_MACHTYPE(*execp
, M_MIPS2
);
166 N_SET_MACHTYPE(*execp
, M_MIPS1
);
171 N_SET_MACHTYPE(*execp
, M_UNKNOWN
);
174 MY(choose_reloc_size
)(abfd
);
176 WRITE_HEADERS(abfd
, execp
);
182 * MIPS relocation types.
184 #define MIPS_RELOC_32 0
185 #define MIPS_RELOC_JMP 1
186 #define MIPS_RELOC_WDISP16 2
187 #define MIPS_RELOC_HI16 3
188 #define MIPS_RELOC_HI16_S 4
189 #define MIPS_RELOC_LO16 5
192 * This is only called when performing a BFD_RELOC_HI16_S relocation.
193 * We need to see if bit 15 is set in the result. If it is, we add
194 * 0x10000 and continue normally. This will compensate for the sign extension
195 * when the low bits are added at run time.
197 bfd_reloc_status_type
198 mips_fix_hi16_s (abfd
,reloc_entry
,symbol
,data
,input_section
,output_bfd
)
200 arelent
*reloc_entry
;
201 struct symbol_cache_entry
*symbol
;
203 asection
*input_section
;
208 /* If this is a partial relocation, just continue. */
209 if (output_bfd
!= (bfd
*)NULL
)
210 return bfd_reloc_continue
;
213 * Work out which section the relocation is targetted at and the
214 * initial relocation command value.
216 if (symbol
->section
== &bfd_com_section
)
219 relocation
= symbol
->value
;
221 relocation
+= symbol
->section
->output_section
->vma
;
222 relocation
+= symbol
->section
->output_offset
;
223 relocation
+= reloc_entry
->addend
;
225 if (relocation
& 0x8000)
226 reloc_entry
->addend
+= 0x10000;
228 return bfd_reloc_continue
;
231 static reloc_howto_type mips_howto_table_ext
[] = {
232 MIPS_RELOC_32
, 0, 2, 32, false, 0, true, true, 0,
233 "32", false, 0, 0xffffffff, false,
234 MIPS_RELOC_JMP
, 2, 2, 26, false, 0, false, true, 0,
235 "MIPS_JMP", false, 0, 0x03ffffff, false,
236 MIPS_RELOC_WDISP16
, 2, 1, 16, true, 0, false, true, 0,
237 "WDISP16", false, 0, 0x0000ffff, false,
238 MIPS_RELOC_HI16
, 16, 1, 16, false, 0, false, true, 0,
239 "HI16", false, 0, 0x0000ffff, false,
240 MIPS_RELOC_HI16_S
, 16, 1, 16, false, 0, false, true, mips_fix_hi16_s
,
241 "HI16_S", false, 0, 0x0000ffff, false,
242 MIPS_RELOC_LO16
, 0, 1, 16, false, 0, false, true, 0,
243 "LO16", false, 0, 0x0000ffff, false,
246 static reloc_howto_type
*
247 MY(reloc_howto_type_lookup
) (abfd
, code
)
249 bfd_reloc_code_real_type code
;
251 extern reloc_howto_type
NAME(aout
,ext_howto_table
)[];
253 switch (bfd_get_arch (abfd
))
260 #define IDX(i,j) case i: return &NAME(aout,ext_howto_table)[j]
261 IDX (BFD_RELOC_CTOR
, 2);
262 IDX (BFD_RELOC_32
, 2);
263 IDX (BFD_RELOC_HI22
, 8);
264 IDX (BFD_RELOC_LO10
, 11);
265 IDX (BFD_RELOC_32_PCREL_S2
, 6);
271 return (&mips_howto_table_ext
[MIPS_RELOC_32
]);
272 case BFD_RELOC_MIPS_JMP
:
273 return (&mips_howto_table_ext
[MIPS_RELOC_JMP
]);
274 case BFD_RELOC_16_PCREL_S2
:
275 return (&mips_howto_table_ext
[MIPS_RELOC_WDISP16
]);
277 return (&mips_howto_table_ext
[MIPS_RELOC_HI16
]);
278 case BFD_RELOC_HI16_S
:
279 return (&mips_howto_table_ext
[MIPS_RELOC_HI16_S
]);
281 return (&mips_howto_table_ext
[MIPS_RELOC_LO16
]);
291 * This is just like the standard aoutx.h version but we need to do our
292 * own mapping of external reloc type values to howto entries.
295 MY(canonicalize_reloc
)(abfd
, section
, relptr
, symbols
)
301 arelent
*tblptr
= section
->relocation
;
302 unsigned int count
, c
;
303 extern reloc_howto_type
NAME(aout
,ext_howto_table
)[];
305 /* If we have already read in the relocation table, return the values. */
306 if (section
->flags
& SEC_CONSTRUCTOR
) {
307 arelent_chain
*chain
= section
->constructor_chain
;
309 for (count
= 0; count
< section
->reloc_count
; count
++) {
310 *relptr
++ = &chain
->relent
;
314 return section
->reloc_count
;
316 if (tblptr
&& section
->reloc_count
) {
317 for (count
= 0; count
++ < section
->reloc_count
;)
318 *relptr
++ = tblptr
++;
320 return section
->reloc_count
;
323 if (!NAME(aout
,slurp_reloc_table
)(abfd
, section
, symbols
))
325 tblptr
= section
->relocation
;
329 /* fix up howto entries */
330 for (count
= 0; count
++ < section
->reloc_count
;)
332 c
= tblptr
->howto
- NAME(aout
,ext_howto_table
);
333 tblptr
->howto
= &mips_howto_table_ext
[c
];
335 *relptr
++ = tblptr
++;
338 return section
->reloc_count
;
341 static CONST
struct aout_backend_data
MY(backend_data
) = {
342 0, /* zmagic contiguous */
343 1, /* text incl header */
344 PAGE_SIZE
, /* text vma */
346 0, /* text size includes exec header */
349 bfd_target aout_mips_little_vec
=
351 "aout-mips-little", /* name */
352 bfd_target_aout_flavour
,
353 false, /* target byte order (little) */
354 false, /* target headers byte order (little) */
355 (HAS_RELOC
| EXEC_P
| /* object flags */
356 HAS_LINENO
| HAS_DEBUG
|
357 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
358 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
359 MY_symbol_leading_char
,
360 ' ', /* ar_pad_char */
361 15, /* ar_max_namelen */
362 1, /* minimum alignment */
363 _do_getl64
, _do_putl64
, _do_getl32
, _do_putl32
, _do_getl16
, _do_putl16
, /* data */
364 _do_getl64
, _do_putl64
, _do_getl32
, _do_putl32
, _do_getl16
, _do_putl16
, /* hdrs */
365 {_bfd_dummy_target
, MY_object_p
, /* bfd_check_format */
366 bfd_generic_archive_p
, MY_core_file_p
},
367 {bfd_false
, MY_mkobject
, /* bfd_set_format */
368 _bfd_generic_mkarchive
, bfd_false
},
369 {bfd_false
, MY_write_object_contents
, /* bfd_write_contents */
370 _bfd_write_archive_contents
, bfd_false
},
372 MY_core_file_failing_command
,
373 MY_core_file_failing_signal
,
374 MY_core_file_matches_executable_p
,
376 MY_slurp_extended_name_table
,
379 MY_close_and_cleanup
,
380 MY_set_section_contents
,
381 MY_get_section_contents
,
383 MY_get_symtab_upper_bound
,
385 MY_get_reloc_upper_bound
,
386 MY_canonicalize_reloc
,
387 MY_make_empty_symbol
,
391 MY_openr_next_archived_file
,
392 MY_find_nearest_line
,
393 MY_generic_stat_arch_elt
,
395 MY_bfd_debug_info_start
,
396 MY_bfd_debug_info_end
,
397 MY_bfd_debug_info_accumulate
,
398 bfd_generic_get_relocated_section_contents
,
399 bfd_generic_relax_section
,
400 bfd_generic_seclet_link
,
401 MY_reloc_howto_type_lookup
,
402 MY_make_debug_symbol
,
403 (PTR
) MY_backend_data
,
406 bfd_target aout_mips_big_vec
=
408 "aout-mips-big", /* name */
409 bfd_target_aout_flavour
,
410 true, /* target byte order (big) */
411 true, /* target headers byte order (big) */
412 (HAS_RELOC
| EXEC_P
| /* object flags */
413 HAS_LINENO
| HAS_DEBUG
|
414 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
415 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
416 MY_symbol_leading_char
,
417 ' ', /* ar_pad_char */
418 15, /* ar_max_namelen */
419 1, /* minimum alignment */
420 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* data */
421 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* hdrs */
422 {_bfd_dummy_target
, MY_object_p
, /* bfd_check_format */
423 bfd_generic_archive_p
, MY_core_file_p
},
424 {bfd_false
, MY_mkobject
, /* bfd_set_format */
425 _bfd_generic_mkarchive
, bfd_false
},
426 {bfd_false
, MY_write_object_contents
, /* bfd_write_contents */
427 _bfd_write_archive_contents
, bfd_false
},
429 MY_core_file_failing_command
,
430 MY_core_file_failing_signal
,
431 MY_core_file_matches_executable_p
,
433 MY_slurp_extended_name_table
,
436 MY_close_and_cleanup
,
437 MY_set_section_contents
,
438 MY_get_section_contents
,
440 MY_get_symtab_upper_bound
,
442 MY_get_reloc_upper_bound
,
443 MY_canonicalize_reloc
,
444 MY_make_empty_symbol
,
448 MY_openr_next_archived_file
,
449 MY_find_nearest_line
,
450 MY_generic_stat_arch_elt
,
452 MY_bfd_debug_info_start
,
453 MY_bfd_debug_info_end
,
454 MY_bfd_debug_info_accumulate
,
455 bfd_generic_get_relocated_section_contents
,
456 bfd_generic_relax_section
,
457 bfd_generic_seclet_link
,
458 MY_reloc_howto_type_lookup
,
459 MY_make_debug_symbol
,
460 (PTR
) MY_backend_data
,