1 |
/* BFD back-end for ns32k a.out-ish binaries. |
/* BFD back-end for ns32k a.out-ish binaries. |
2 |
Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 2000, 2001 |
Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999, 2000, 2001, |
3 |
Free Software Foundation, Inc. |
2002, 2003 Free Software Foundation, Inc. |
4 |
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au). |
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au). |
5 |
|
|
6 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
7 |
|
|
8 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
9 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
10 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
11 |
(at your option) any later version. |
(at your option) any later version. |
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
GNU General Public License for more details. |
GNU General Public License for more details. |
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
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. */ |
|
|
|
|
#define BYTES_IN_WORD 4 |
|
21 |
|
|
22 |
#include "bfd.h" |
#include "bfd.h" |
23 |
#include "aout/aout64.h" |
#include "aout/aout64.h" |
33 |
PARAMS((bfd *abfd AND |
PARAMS((bfd *abfd AND |
34 |
bfd_reloc_code_real_type code)); |
bfd_reloc_code_real_type code)); |
35 |
|
|
36 |
boolean |
bfd_boolean |
37 |
MYNS(write_object_contents) |
MYNS(write_object_contents) |
38 |
PARAMS((bfd *abfd)); |
PARAMS((bfd *abfd)); |
39 |
|
|
47 |
|
|
48 |
#define MY(OP) MYNS(OP) |
#define MY(OP) MYNS(OP) |
49 |
|
|
50 |
#define MY_swap_std_reloc_in MY(swap_std_reloc_in) |
#define MY_swap_std_reloc_in MY(swap_std_reloc_in) |
51 |
#define MY_swap_std_reloc_out MY(swap_std_reloc_out) |
#define MY_swap_std_reloc_out MY(swap_std_reloc_out) |
52 |
|
|
53 |
static void |
static void |
54 |
MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes, |
MY_swap_std_reloc_in PARAMS ((bfd *, struct reloc_std_external *, |
55 |
arelent *cache_ptr, asymbol **symbols, |
arelent *, asymbol **, |
56 |
bfd_size_type symcount)); |
bfd_size_type)); |
57 |
static void |
static void |
58 |
MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g, |
MY_swap_std_reloc_out PARAMS ((bfd *, arelent *, |
59 |
struct reloc_std_external *natptr)); |
struct reloc_std_external *)); |
60 |
reloc_howto_type * |
reloc_howto_type * |
61 |
MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *, |
MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *, |
62 |
int *, int *, int *)); |
int *, int *, int *)); |
65 |
struct reloc_std_external *)); |
struct reloc_std_external *)); |
66 |
|
|
67 |
/* The ns32k series is ah, unusual, when it comes to relocation. |
/* The ns32k series is ah, unusual, when it comes to relocation. |
68 |
There are three storage methods for relocateable objects. There |
There are three storage methods for relocatable objects. There |
69 |
are displacements, immediate operands and ordinary twos complement |
are displacements, immediate operands and ordinary twos complement |
70 |
data. Of these, only the last fits into the standard relocation |
data. Of these, only the last fits into the standard relocation |
71 |
scheme. Immediate operands are stored huffman encoded and |
scheme. Immediate operands are stored huffman encoded and |
72 |
immediate operands are stored big endian (where as the natural byte |
immediate operands are stored big endian (where as the natural byte |
73 |
order is little endian for this achitecture). |
order is little endian for this architecture). |
74 |
|
|
75 |
Note that the ns32k displacement storage method is orthogonal to |
Note that the ns32k displacement storage method is orthogonal to |
76 |
whether the relocation is pc relative or not. The "displacement" |
whether the relocation is pc relative or not. The "displacement" |
92 |
|
|
93 |
In addition, for historical reasons the encoding of the relocation types |
In addition, for historical reasons the encoding of the relocation types |
94 |
in the a.out format relocation entries is such that even the relocation |
in the a.out format relocation entries is such that even the relocation |
95 |
methods which are standard are not encoded the standard way. */ |
methods which are standard are not encoded the standard way. */ |
96 |
|
|
97 |
reloc_howto_type MY(howto_table)[] = |
reloc_howto_type MY(howto_table)[] = |
98 |
{ |
{ |
99 |
|
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */ |
100 |
/* ns32k immediate operands. */ |
/* ns32k immediate operands. */ |
101 |
HOWTO (BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_IMM_8, 0, 0, 8, FALSE, 0, complain_overflow_signed, |
102 |
_bfd_ns32k_reloc_imm, "NS32K_IMM_8", |
_bfd_ns32k_reloc_imm, "NS32K_IMM_8", |
103 |
true, 0x000000ff,0x000000ff, false), |
TRUE, 0x000000ff,0x000000ff, FALSE), |
104 |
HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, FALSE, 0, complain_overflow_signed, |
105 |
_bfd_ns32k_reloc_imm, "NS32K_IMM_16", |
_bfd_ns32k_reloc_imm, "NS32K_IMM_16", |
106 |
true, 0x0000ffff,0x0000ffff, false), |
TRUE, 0x0000ffff,0x0000ffff, FALSE), |
107 |
HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, FALSE, 0, complain_overflow_signed, |
108 |
_bfd_ns32k_reloc_imm, "NS32K_IMM_32", |
_bfd_ns32k_reloc_imm, "NS32K_IMM_32", |
109 |
true, 0xffffffff,0xffffffff, false), |
TRUE, 0xffffffff,0xffffffff, FALSE), |
110 |
HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, TRUE, 0, complain_overflow_signed, |
111 |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8", |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8", |
112 |
true, 0x000000ff, 0x000000ff, false), |
TRUE, 0x000000ff, 0x000000ff, FALSE), |
113 |
HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_signed, |
114 |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16", |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16", |
115 |
true, 0x0000ffff,0x0000ffff, false), |
TRUE, 0x0000ffff,0x0000ffff, FALSE), |
116 |
HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_signed, |
117 |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32", |
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32", |
118 |
true, 0xffffffff,0xffffffff, false), |
TRUE, 0xffffffff,0xffffffff, FALSE), |
119 |
|
|
120 |
/* ns32k displacements. */ |
/* ns32k displacements. */ |
121 |
HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 7, FALSE, 0, complain_overflow_signed, |
122 |
_bfd_ns32k_reloc_disp, "NS32K_DISP_8", |
_bfd_ns32k_reloc_disp, "NS32K_DISP_8", |
123 |
true, 0x000000ff,0x000000ff, false), |
TRUE, 0x000000ff,0x000000ff, FALSE), |
124 |
HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 14, FALSE, 0, complain_overflow_signed, |
125 |
_bfd_ns32k_reloc_disp, "NS32K_DISP_16", |
_bfd_ns32k_reloc_disp, "NS32K_DISP_16", |
126 |
true, 0x0000ffff, 0x0000ffff, false), |
TRUE, 0x0000ffff, 0x0000ffff, FALSE), |
127 |
HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true, |
HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 30, FALSE, 0, complain_overflow_signed, |
128 |
_bfd_ns32k_reloc_disp, "NS32K_DISP_32", |
_bfd_ns32k_reloc_disp, "NS32K_DISP_32", |
129 |
true, 0xffffffff, 0xffffffff, false), |
TRUE, 0xffffffff, 0xffffffff, FALSE), |
130 |
HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 7, TRUE, 0, complain_overflow_signed, |
131 |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8", |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8", |
132 |
true, 0x000000ff,0x000000ff, false), |
TRUE, 0x000000ff,0x000000ff, FALSE), |
133 |
HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 14, TRUE, 0, complain_overflow_signed, |
134 |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16", |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16", |
135 |
true, 0x0000ffff,0x0000ffff, false), |
TRUE, 0x0000ffff,0x0000ffff, FALSE), |
136 |
HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false, |
HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 30, TRUE, 0, complain_overflow_signed, |
137 |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_32", |
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_32", |
138 |
true, 0xffffffff,0xffffffff, false), |
TRUE, 0xffffffff,0xffffffff, FALSE), |
139 |
|
|
140 |
/* Normal 2's complement. */ |
/* Normal 2's complement. */ |
141 |
HOWTO (BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0, |
HOWTO (BFD_RELOC_8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0, |
142 |
"8", true, 0x000000ff,0x000000ff, false), |
"8", TRUE, 0x000000ff,0x000000ff, FALSE), |
143 |
HOWTO (BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0, |
HOWTO (BFD_RELOC_16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0, |
144 |
"16", true, 0x0000ffff,0x0000ffff, false), |
"16", TRUE, 0x0000ffff,0x0000ffff, FALSE), |
145 |
HOWTO (BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0, |
HOWTO (BFD_RELOC_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0, |
146 |
"32", true, 0xffffffff,0xffffffff, false), |
"32", TRUE, 0xffffffff,0xffffffff, FALSE), |
147 |
HOWTO (BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0, |
HOWTO (BFD_RELOC_8_PCREL, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, |
148 |
"PCREL_8", true, 0x000000ff,0x000000ff, false), |
"PCREL_8", TRUE, 0x000000ff,0x000000ff, FALSE), |
149 |
HOWTO (BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0, |
HOWTO (BFD_RELOC_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, |
150 |
"PCREL_16", true, 0x0000ffff,0x0000ffff, false), |
"PCREL_16", TRUE, 0x0000ffff,0x0000ffff, FALSE), |
151 |
HOWTO (BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0, |
HOWTO (BFD_RELOC_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, |
152 |
"PCREL_32", true, 0xffffffff,0xffffffff, false), |
"PCREL_32", TRUE, 0xffffffff,0xffffffff, FALSE), |
153 |
}; |
}; |
154 |
|
|
155 |
#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14) |
#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14) |
354 |
{ |
{ |
355 |
int r_ns32k_type = (howto - MY(howto_table)) / 6; |
int r_ns32k_type = (howto - MY(howto_table)) / 6; |
356 |
bfd_vma (*get_data) PARAMS ((bfd_byte *, int)); |
bfd_vma (*get_data) PARAMS ((bfd_byte *, int)); |
357 |
int (*put_data) PARAMS ((bfd_vma, bfd_byte *, int)); |
void (*put_data) PARAMS ((bfd_vma, bfd_byte *, int)); |
358 |
|
|
359 |
switch (r_ns32k_type) |
switch (r_ns32k_type) |
360 |
{ |
{ |