1 |
/* BFD backend for MIPS BSD (a.out) binaries. |
/* BFD backend for MIPS BSD (a.out) binaries. |
2 |
Copyright 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001 |
Copyright 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
3 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
4 |
Written by Ralph Campbell. |
Written by Ralph Campbell. |
5 |
|
|
19 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
20 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
21 |
|
|
|
#define BYTES_IN_WORD 4 |
|
22 |
/* #define ENTRY_CAN_BE_ZERO */ |
/* #define ENTRY_CAN_BE_ZERO */ |
23 |
#define N_HEADER_IN_TEXT(x) 1 |
#define N_HEADER_IN_TEXT(x) 1 |
24 |
#define N_SHARED_LIB(x) 0 |
#define N_SHARED_LIB(x) 0 |
52 |
static void MY(choose_reloc_size) PARAMS ((bfd *abfd)); |
static void MY(choose_reloc_size) PARAMS ((bfd *abfd)); |
53 |
|
|
54 |
#define MY_write_object_contents MY(write_object_contents) |
#define MY_write_object_contents MY(write_object_contents) |
55 |
static boolean MY(write_object_contents) PARAMS ((bfd *abfd)); |
static bfd_boolean MY(write_object_contents) PARAMS ((bfd *abfd)); |
56 |
|
|
57 |
/* We can't use MY(x) here because it leads to a recursive call to CONCAT2 |
/* We can't use MY(x) here because it leads to a recursive call to CONCAT2 |
58 |
when expanded inside JUMP_TABLE. */ |
when expanded inside JUMP_TABLE. */ |
70 |
#include "aout-target.h" |
#include "aout-target.h" |
71 |
|
|
72 |
static bfd_reloc_status_type mips_fix_jmp_addr |
static bfd_reloc_status_type mips_fix_jmp_addr |
73 |
PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *, |
PARAMS ((bfd *, arelent *, struct bfd_symbol *, PTR, asection *, |
74 |
bfd *, char **)); |
bfd *, char **)); |
75 |
static reloc_howto_type *MY(reloc_howto_type_lookup) |
static reloc_howto_type *MY(reloc_howto_type_lookup) |
76 |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
90 |
{ |
{ |
91 |
case M_MIPS1: |
case M_MIPS1: |
92 |
arch = bfd_arch_mips; |
arch = bfd_arch_mips; |
93 |
machine = 3000; |
machine = bfd_mach_mips3000; |
94 |
break; |
break; |
95 |
|
|
96 |
case M_MIPS2: |
case M_MIPS2: |
97 |
arch = bfd_arch_mips; |
arch = bfd_arch_mips; |
98 |
machine = 4000; |
machine = bfd_mach_mips4000; |
99 |
break; |
break; |
100 |
|
|
101 |
default: |
default: |
129 |
Section contents have already been written. We write the |
Section contents have already been written. We write the |
130 |
file header, symbols, and relocation. */ |
file header, symbols, and relocation. */ |
131 |
|
|
132 |
static boolean |
static bfd_boolean |
133 |
MY (write_object_contents) (abfd) |
MY (write_object_contents) (abfd) |
134 |
bfd *abfd; |
bfd *abfd; |
135 |
{ |
{ |
163 |
case bfd_arch_mips: |
case bfd_arch_mips: |
164 |
switch (bfd_get_mach (abfd)) |
switch (bfd_get_mach (abfd)) |
165 |
{ |
{ |
166 |
case 4000: |
case bfd_mach_mips4000: |
167 |
case 6000: |
case bfd_mach_mips6000: |
168 |
N_SET_MACHTYPE (*execp, M_MIPS2); |
N_SET_MACHTYPE (*execp, M_MIPS2); |
169 |
break; |
break; |
170 |
default: |
default: |
180 |
|
|
181 |
WRITE_HEADERS (abfd, execp); |
WRITE_HEADERS (abfd, execp); |
182 |
|
|
183 |
return true; |
return TRUE; |
184 |
} |
} |
185 |
|
|
186 |
/* MIPS relocation types. */ |
/* MIPS relocation types. */ |
203 |
error_message) |
error_message) |
204 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
205 |
arelent *reloc_entry; |
arelent *reloc_entry; |
206 |
struct symbol_cache_entry *symbol; |
struct bfd_symbol *symbol; |
207 |
PTR data ATTRIBUTE_UNUSED; |
PTR data ATTRIBUTE_UNUSED; |
208 |
asection *input_section; |
asection *input_section; |
209 |
bfd *output_bfd; |
bfd *output_bfd; |
220 |
&& (symbol->flags & BSF_WEAK) == 0) |
&& (symbol->flags & BSF_WEAK) == 0) |
221 |
return bfd_reloc_undefined; |
return bfd_reloc_undefined; |
222 |
|
|
223 |
/* Work out which section the relocation is targetted at and the |
/* Work out which section the relocation is targeted at and the |
224 |
initial relocation command value. */ |
initial relocation command value. */ |
225 |
if (bfd_is_com_section (symbol->section)) |
if (bfd_is_com_section (symbol->section)) |
226 |
relocation = 0; |
relocation = 0; |
271 |
&& (symbol->flags & BSF_WEAK) == 0) |
&& (symbol->flags & BSF_WEAK) == 0) |
272 |
return bfd_reloc_undefined; |
return bfd_reloc_undefined; |
273 |
|
|
274 |
/* Work out which section the relocation is targetted at and the |
/* Work out which section the relocation is targeted at and the |
275 |
initial relocation command value. */ |
initial relocation command value. */ |
276 |
if (bfd_is_com_section (symbol->section)) |
if (bfd_is_com_section (symbol->section)) |
277 |
relocation = 0; |
relocation = 0; |
289 |
} |
} |
290 |
|
|
291 |
static reloc_howto_type mips_howto_table_ext[] = { |
static reloc_howto_type mips_howto_table_ext[] = { |
292 |
{MIPS_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, |
{MIPS_RELOC_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, |
293 |
"32", false, 0, 0xffffffff, false}, |
"32", FALSE, 0, 0xffffffff, FALSE}, |
294 |
{MIPS_RELOC_JMP, 2, 2, 26, false, 0, complain_overflow_dont, |
{MIPS_RELOC_JMP, 2, 2, 26, FALSE, 0, complain_overflow_dont, |
295 |
mips_fix_jmp_addr, |
mips_fix_jmp_addr, |
296 |
"MIPS_JMP", false, 0, 0x03ffffff, false}, |
"MIPS_JMP", FALSE, 0, 0x03ffffff, FALSE}, |
297 |
{MIPS_RELOC_WDISP16, 2, 2, 16, true, 0, complain_overflow_signed, 0, |
{MIPS_RELOC_WDISP16, 2, 2, 16, TRUE, 0, complain_overflow_signed, 0, |
298 |
"WDISP16", false, 0, 0x0000ffff, false}, |
"WDISP16", FALSE, 0, 0x0000ffff, FALSE}, |
299 |
{MIPS_RELOC_HI16, 16, 2, 16, false, 0, complain_overflow_bitfield, 0, |
{MIPS_RELOC_HI16, 16, 2, 16, FALSE, 0, complain_overflow_bitfield, 0, |
300 |
"HI16", false, 0, 0x0000ffff, false}, |
"HI16", FALSE, 0, 0x0000ffff, FALSE}, |
301 |
{MIPS_RELOC_HI16_S, 16, 2, 16, false, 0, complain_overflow_bitfield, |
{MIPS_RELOC_HI16_S, 16, 2, 16, FALSE, 0, complain_overflow_bitfield, |
302 |
mips_fix_hi16_s, |
mips_fix_hi16_s, |
303 |
"HI16_S", false, 0, 0x0000ffff, false}, |
"HI16_S", FALSE, 0, 0x0000ffff, FALSE}, |
304 |
{MIPS_RELOC_LO16, 0, 2, 16, false, 0, complain_overflow_dont, 0, |
{MIPS_RELOC_LO16, 0, 2, 16, FALSE, 0, complain_overflow_dont, 0, |
305 |
"LO16", false, 0, 0x0000ffff, false}, |
"LO16", FALSE, 0, 0x0000ffff, FALSE}, |
306 |
}; |
}; |
307 |
|
|
308 |
static reloc_howto_type * |
static reloc_howto_type * |