Changeset 609 for branches/GNU/src/binutils/bfd/aout-ns32k.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/aout-ns32k.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for ns32k a.out-ish binaries. 2 Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 2000 2 Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Contributed by Ian Dall (idall@eleceng.adelaide.edu.au). 5 5 6 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 9 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 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 22 #define BYTES_IN_WORD 4 6 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 9 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 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 21 24 22 #include "bfd.h" … … 26 24 #include "ns32k.h" 27 25 28 #define MYNS(OP) CAT(ns32kaout_,OP) 26 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 27 remove whitespace added here, and thus will fail to concatenate 28 the tokens. */ 29 #define MYNS(OP) CONCAT2 (ns32kaout_,OP) 30 29 31 reloc_howto_type * 30 32 MYNS(bfd_reloc_type_lookup) … … 32 34 bfd_reloc_code_real_type code)); 33 35 34 b oolean36 bfd_boolean 35 37 MYNS(write_object_contents) 36 38 PARAMS((bfd *abfd)); 37 39 38 /* Avoid multiple definitions from aoutx if supporting standard a.out format(s) 39 * as well as this one 40 */ 41 #define NAME(x,y) CAT3(ns32kaout,_32_,y) 40 /* Avoid multiple definitions from aoutx if supporting 41 standard a.out format(s) as well as this one. */ 42 #define NAME(x,y) CONCAT3 (ns32kaout,_32_,y) 42 43 43 44 void bfd_ns32k_arch PARAMS ((void)); … … 47 48 #define MY(OP) MYNS(OP) 48 49 49 #define MY_swap_std_reloc_in MY(swap_std_reloc_in)50 #define MY_swap_std_reloc_in MY(swap_std_reloc_in) 50 51 #define MY_swap_std_reloc_out MY(swap_std_reloc_out) 51 52 52 53 static void 53 MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes, 54 arelent *cache_ptr, asymbol **symbols, 55 bfd_size_type symcount)); 56 54 MY_swap_std_reloc_in PARAMS ((bfd *, struct reloc_std_external *, 55 arelent *, asymbol **, 56 bfd_size_type)); 57 57 static void 58 MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g, 59 struct reloc_std_external *natptr)); 58 MY_swap_std_reloc_out PARAMS ((bfd *, arelent *, 59 struct reloc_std_external *)); 60 reloc_howto_type * 61 MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *, 62 int *, int *, int *)); 63 void 64 MY(put_reloc) PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *, 65 struct reloc_std_external *)); 60 66 61 67 /* The ns32k series is ah, unusual, when it comes to relocation. 62 * There are three storage methods for relocateable objects. There 63 * are displacements, immediate operands and ordinary twos complement 64 * data. Of these, only the last fits into the standard relocation 65 * scheme. Immediate operands are stored huffman encoded and 66 * immediate operands are stored big endian (where as the natural byte 67 * order is little endian for this achitecture). 68 69 * Note that the ns32k displacement storage method is orthogonal to 70 * whether the relocation is pc relative or not. The "displacement" 71 * storage scheme is used for essentially all address constants. The 72 * displacement can be relative to zero (absolute displacement), 73 * relative to the pc (pc relative), the stack pointer, the frame 74 * pointer, the static base register and general purpose register etc. 75 76 * For example: 77 * 78 * sym1: .long . # pc relative 2's complement 79 * sym1: .long foo # 2's complement not pc relative 80 * 81 * self: movd @self, r0 # pc relative displacement 82 * movd foo, r0 # non pc relative displacement 83 * 84 * self: movd self, r0 # pc relative immediate 85 * movd foo, r0 # non pc relative immediate 86 * 87 * In addition, for historical reasons the encoding of the relocation types 88 * in the a.out format relocation entries is such that even the relocation 89 * methods which are standard are not encoded the standard way. 90 * 91 */ 68 There are three storage methods for relocateable objects. There 69 are displacements, immediate operands and ordinary twos complement 70 data. Of these, only the last fits into the standard relocation 71 scheme. Immediate operands are stored huffman encoded and 72 immediate operands are stored big endian (where as the natural byte 73 order is little endian for this achitecture). 74 75 Note that the ns32k displacement storage method is orthogonal to 76 whether the relocation is pc relative or not. The "displacement" 77 storage scheme is used for essentially all address constants. The 78 displacement can be relative to zero (absolute displacement), 79 relative to the pc (pc relative), the stack pointer, the frame 80 pointer, the static base register and general purpose register etc. 81 82 For example: 83 84 sym1: .long . # pc relative 2's complement 85 sym1: .long foo # 2's complement not pc relative 86 87 self: movd @self, r0 # pc relative displacement 88 movd foo, r0 # non pc relative displacement 89 90 self: movd self, r0 # pc relative immediate 91 movd foo, r0 # non pc relative immediate 92 93 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 95 methods which are standard are not encoded the standard way. */ 92 96 93 97 reloc_howto_type MY(howto_table)[] = 94 { 95 /* ns32k immediate operands */ 96 HOWTO (BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true, 97 _bfd_ns32k_reloc_imm, "NS32K_IMM_8", 98 true, 0x000000ff,0x000000ff, false), 99 HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true, 100 _bfd_ns32k_reloc_imm, "NS32K_IMM_16", 101 true, 0x0000ffff,0x0000ffff, false), 102 HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true, 103 _bfd_ns32k_reloc_imm, "NS32K_IMM_32", 104 true, 0xffffffff,0xffffffff, false), 105 HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false, 106 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8", 107 true, 0x000000ff, 0x000000ff, false), 108 HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false, 109 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16", 110 true, 0x0000ffff,0x0000ffff, false), 111 HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false, 112 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32", 113 true, 0xffffffff,0xffffffff, false), 114 115 /* ns32k displacements */ 116 HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true, 117 _bfd_ns32k_reloc_disp, "NS32K_DISP_8", 118 true, 0x000000ff,0x000000ff, false), 119 HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true, 120 _bfd_ns32k_reloc_disp, "NS32K_DISP_16", 121 true, 0x0000ffff, 0x0000ffff, false), 122 HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true, 123 _bfd_ns32k_reloc_disp, "NS32K_DISP_32", 124 true, 0xffffffff, 0xffffffff, false), 125 HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false, 126 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8", 127 true, 0x000000ff,0x000000ff, false), 128 HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false, 129 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16", 130 true, 0x0000ffff,0x0000ffff, false), 131 HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false, 132 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_32", 133 true, 0xffffffff,0xffffffff, false), 134 135 /* Normal 2's complement */ 136 HOWTO (BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0, 137 "8", true, 0x000000ff,0x000000ff, false), 138 HOWTO (BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0, 139 "16", true, 0x0000ffff,0x0000ffff, false), 140 HOWTO (BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0, 141 "32", true, 0xffffffff,0xffffffff, false), 142 HOWTO (BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0, 143 "PCREL_8", true, 0x000000ff,0x000000ff, false), 144 HOWTO (BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0, 145 "PCREL_16", true, 0x0000ffff,0x0000ffff, false), 146 HOWTO (BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0, 147 "PCREL_32", true, 0xffffffff,0xffffffff, false), 148 }; 98 { 99 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */ 100 /* ns32k immediate operands. */ 101 HOWTO (BFD_RELOC_NS32K_IMM_8, 0, 0, 8, FALSE, 0, complain_overflow_signed, 102 _bfd_ns32k_reloc_imm, "NS32K_IMM_8", 103 TRUE, 0x000000ff,0x000000ff, FALSE), 104 HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, FALSE, 0, complain_overflow_signed, 105 _bfd_ns32k_reloc_imm, "NS32K_IMM_16", 106 TRUE, 0x0000ffff,0x0000ffff, FALSE), 107 HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, FALSE, 0, complain_overflow_signed, 108 _bfd_ns32k_reloc_imm, "NS32K_IMM_32", 109 TRUE, 0xffffffff,0xffffffff, FALSE), 110 HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, TRUE, 0, complain_overflow_signed, 111 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8", 112 TRUE, 0x000000ff, 0x000000ff, FALSE), 113 HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_signed, 114 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16", 115 TRUE, 0x0000ffff,0x0000ffff, FALSE), 116 HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_signed, 117 _bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32", 118 TRUE, 0xffffffff,0xffffffff, FALSE), 119 120 /* ns32k displacements. */ 121 HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 7, FALSE, 0, complain_overflow_signed, 122 _bfd_ns32k_reloc_disp, "NS32K_DISP_8", 123 TRUE, 0x000000ff,0x000000ff, FALSE), 124 HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 14, FALSE, 0, complain_overflow_signed, 125 _bfd_ns32k_reloc_disp, "NS32K_DISP_16", 126 TRUE, 0x0000ffff, 0x0000ffff, FALSE), 127 HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 30, FALSE, 0, complain_overflow_signed, 128 _bfd_ns32k_reloc_disp, "NS32K_DISP_32", 129 TRUE, 0xffffffff, 0xffffffff, FALSE), 130 HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 7, TRUE, 0, complain_overflow_signed, 131 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8", 132 TRUE, 0x000000ff,0x000000ff, FALSE), 133 HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 14, TRUE, 0, complain_overflow_signed, 134 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16", 135 TRUE, 0x0000ffff,0x0000ffff, FALSE), 136 HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 30, TRUE, 0, complain_overflow_signed, 137 _bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_32", 138 TRUE, 0xffffffff,0xffffffff, FALSE), 139 140 /* Normal 2's complement. */ 141 HOWTO (BFD_RELOC_8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0, 142 "8", TRUE, 0x000000ff,0x000000ff, FALSE), 143 HOWTO (BFD_RELOC_16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0, 144 "16", TRUE, 0x0000ffff,0x0000ffff, FALSE), 145 HOWTO (BFD_RELOC_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0, 146 "32", TRUE, 0xffffffff,0xffffffff, FALSE), 147 HOWTO (BFD_RELOC_8_PCREL, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, 148 "PCREL_8", TRUE, 0x000000ff,0x000000ff, FALSE), 149 HOWTO (BFD_RELOC_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, 150 "PCREL_16", TRUE, 0x0000ffff,0x0000ffff, FALSE), 151 HOWTO (BFD_RELOC_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, 152 "PCREL_32", TRUE, 0xffffffff,0xffffffff, FALSE), 153 }; 149 154 150 155 #define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14) … … 165 170 unsigned int r_length; 166 171 int r_ns32k_type; 167 /* BFD_ASSERT(bfd_header_little_endian (abfd)); */ 172 173 /* BFD_ASSERT(bfd_header_little_endian (abfd)); */ 168 174 *r_index = ((rel->r_index[2] << 16) 169 175 | (rel->r_index[1] << 8) … … 178 184 } 179 185 180 #define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto) (BFD, REL, &IN, &EX, &PC) 186 #define MY_reloc_howto(BFD, REL, IN, EX, PC) \ 187 MY(reloc_howto) (BFD, REL, &IN, &EX, &PC) 181 188 182 189 void … … 185 192 int r_extern; 186 193 int r_index; 187 longvalue;194 bfd_vma value; 188 195 reloc_howto_type *howto; 189 196 struct reloc_std_external *reloc; … … 192 199 int r_pcrel; 193 200 int r_ns32k_type; 201 194 202 PUT_WORD (abfd, value, reloc->r_address); 195 r_length = howto->size ; /* Size as a power of two */196 r_pcrel = (int) howto->pc_relative; /* Relative to PC? */203 r_length = howto->size ; /* Size as a power of two. */ 204 r_pcrel = (int) howto->pc_relative; /* Relative to PC? */ 197 205 r_ns32k_type = (howto - MY(howto_table) )/6; 198 /* BFD_ASSERT (bfd_header_little_endian (abfd)); */ 206 207 /* BFD_ASSERT (bfd_header_little_endian (abfd)); */ 199 208 reloc->r_index[2] = r_index >> 16; 200 209 reloc->r_index[1] = r_index >> 8; … … 215 224 #define MY_relocate_contents _bfd_ns32k_relocate_contents 216 225 217 #include <aoutx.h>226 #include "aoutx.h" 218 227 219 228 reloc_howto_type * … … 233 242 case 32: 234 243 code = BFD_RELOC_32; 244 break; 245 default: 235 246 break; 236 247 } … … 255 266 ENTRY(BFD_RELOC_16_PCREL, 16); 256 267 ENTRY(BFD_RELOC_32_PCREL, 17); 257 default: return (reloc_howto_type *) NULL; 268 default: 269 return (reloc_howto_type *) NULL; 258 270 } 259 271 #undef ENTRY … … 273 285 struct aoutdata *su = &(abfd->tdata.aout_data->a); 274 286 275 cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address); 276 277 /* now the fun stuff */ 278 287 cache_ptr->address = H_GET_32 (abfd, bytes->r_address); 288 289 /* Now the fun stuff. */ 279 290 cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel); 280 291 281 MOVE_ADDRESS (0);292 MOVE_ADDRESS (0); 282 293 } 283 294 … … 296 307 r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma; 297 308 298 /* name was clobbered by aout_write_syms to be symbol index*/309 /* Name was clobbered by aout_write_syms to be symbol index. */ 299 310 300 311 /* If this relocation is relative to a symbol then set the … … 304 315 from the abs section, or as a symbol which has an abs value. 305 316 Check for that here. */ 306 307 317 if (bfd_is_com_section (output_section) 308 318 || output_section == &bfd_abs_section … … 312 322 { 313 323 /* Whoops, looked like an abs symbol, but is really an offset 314 from the abs section */324 from the abs section. */ 315 325 r_index = 0; 316 326 r_extern = 0; … … 318 328 else 319 329 { 320 /* Fill in symbol */330 /* Fill in symbol. */ 321 331 r_extern = 1; 322 332 #undef KEEPIT … … 328 338 else 329 339 { 330 /* Just an ordinary section */340 /* Just an ordinary section. */ 331 341 r_extern = 0; 332 342 r_index = output_section->target_index; … … 344 354 { 345 355 int r_ns32k_type = (howto - MY(howto_table)) / 6; 346 long (*get_data) PARAMS ((bfd_byte *, long, long));347 int (*put_data) PARAMS ((long, bfd_byte *, long, long));356 bfd_vma (*get_data) PARAMS ((bfd_byte *, int)); 357 void (*put_data) PARAMS ((bfd_vma, bfd_byte *, int)); 348 358 349 359 switch (r_ns32k_type) -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.