Changeset 609 for branches/GNU/src/binutils/bfd/vms-tir.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/vms-tir.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and 2 2 EVAX (openVMS/Alpha) files. 3 Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 4 Free Software Foundation, Inc. 4 5 5 6 TIR record handling functions … … 11 12 Written by Klaus K"ampf (kkaempf@rmi.de) 12 13 13 This program is free software; you can redistribute it and/or modify14 it under the terms of the GNU General Public License as published by15 the Free Software Foundation; either version 2 of the License, or16 (at your option) any later version.17 18 This program is distributed in the hope that it will be useful,19 but WITHOUT ANY WARRANTY; without even the implied warranty of20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the21 GNU General Public License for more details.22 23 You should have received a copy of the GNU General Public License24 along with this program; if not, write to the Free Software25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */14 This program is free software; you can redistribute it and/or modify 15 it under the terms of the GNU General Public License as published by 16 the Free Software Foundation; either version 2 of the License, or 17 (at your option) any later version. 18 19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 26 27 27 28 /* The following type abbreviations are used: … … 34 35 da data stream */ 35 36 36 #include <ctype.h>37 38 37 #include "bfd.h" 39 38 #include "sysdep.h" … … 43 42 #include "vms.h" 44 43 45 static void image_set_ptr PARAMS ((bfd *abfd, int psect, uquad offset)); 46 static void image_inc_ptr PARAMS ((bfd *abfd, uquad offset)); 47 static void image_dump PARAMS ((bfd *abfd, unsigned char *ptr, int size, int offset)); 48 static void image_write_b PARAMS ((bfd *abfd, unsigned int value)); 49 static void image_write_w PARAMS ((bfd *abfd, unsigned int value)); 50 static void image_write_l PARAMS ((bfd *abfd, unsigned long value)); 51 static void image_write_q PARAMS ((bfd *abfd, uquad value)); 52 53 /*-----------------------------------------------------------------------------*/ 44 static void image_set_ptr 45 PARAMS ((bfd *abfd, int psect, uquad offset)); 46 static void image_inc_ptr 47 PARAMS ((bfd *abfd, uquad offset)); 48 static void image_dump 49 PARAMS ((bfd *abfd, unsigned char *ptr, int size, int offset)); 50 static void image_write_b 51 PARAMS ((bfd *abfd, unsigned int value)); 52 static void image_write_w 53 PARAMS ((bfd *abfd, unsigned int value)); 54 static void image_write_l 55 PARAMS ((bfd *abfd, unsigned long value)); 56 static void image_write_q 57 PARAMS ((bfd *abfd, uquad value)); 58 static int check_section 59 PARAMS ((bfd *, int)); 60 static bfd_boolean etir_sta 61 PARAMS ((bfd *, int, unsigned char *)); 62 static bfd_boolean etir_sto 63 PARAMS ((bfd *, int, unsigned char *)); 64 static bfd_boolean etir_opr 65 PARAMS ((bfd *, int, unsigned char *)); 66 static bfd_boolean etir_ctl 67 PARAMS ((bfd *, int, unsigned char *)); 68 static bfd_boolean etir_stc 69 PARAMS ((bfd *, int, unsigned char *)); 70 static asection *new_section 71 PARAMS ((bfd *, int)); 72 static int alloc_section 73 PARAMS ((bfd *, unsigned int)); 74 static int etir_cmd 75 PARAMS ((bfd *, int, unsigned char *)); 76 static int analyze_tir 77 PARAMS ((bfd *, unsigned char *, unsigned int)); 78 static int analyze_etir 79 PARAMS ((bfd *, unsigned char *, unsigned int)); 80 static unsigned char * tir_opr 81 PARAMS ((bfd *, unsigned char *)); 82 static const char * tir_cmd_name 83 PARAMS ((int)); 84 static const char * cmd_name 85 PARAMS ((int)); 86 87 54 88 55 89 static int … … 58 92 int size; 59 93 { 60 intoffset;61 62 offset = PRIV (image_ptr) - PRIV(image_section)->contents;63 if ( (bfd_size_type) (offset + size) > PRIV(image_section)->_raw_size)94 bfd_size_type offset; 95 96 offset = PRIV (image_ptr) - PRIV (image_section)->contents; 97 if (offset + size > PRIV (image_section)->_raw_size) 64 98 { 65 PRIV(image_section)->contents = bfd_realloc (PRIV(image_section)->contents, offset + size); 66 if (PRIV(image_section)->contents == 0) 99 PRIV (image_section)->contents 100 = bfd_realloc (PRIV (image_section)->contents, offset + size); 101 if (PRIV (image_section)->contents == 0) 67 102 { 68 103 (*_bfd_error_handler) (_("No Mem !")); 69 104 return -1; 70 105 } 71 PRIV (image_section)->_raw_size = offset + size;72 PRIV (image_ptr) = PRIV(image_section)->contents + offset;106 PRIV (image_section)->_raw_size = offset + size; 107 PRIV (image_ptr) = PRIV (image_section)->contents + offset; 73 108 } 74 109 … … 76 111 } 77 112 78 /* routines to fill sections contents during tir/etir read*/79 80 /* Initialize image buffer pointer to be filled */113 /* Routines to fill sections contents during tir/etir read. */ 114 115 /* Initialize image buffer pointer to be filled. */ 81 116 82 117 static void … … 88 123 #if VMS_DEBUG 89 124 _bfd_vms_debug (4, "image_set_ptr (%d=%s, %d)\n", 90 psect, PRIV(sections)[psect]->name, offset);91 #endif 92 93 PRIV (image_ptr) = PRIV(sections)[psect]->contents + offset;94 PRIV (image_section) = PRIV(sections)[psect];125 psect, PRIV (sections)[psect]->name, offset); 126 #endif 127 128 PRIV (image_ptr) = PRIV (sections)[psect]->contents + offset; 129 PRIV (image_section) = PRIV (sections)[psect]; 95 130 return; 96 131 } 97 132 98 /* Increment image buffer pointer by offset */133 /* Increment image buffer pointer by offset. */ 99 134 100 135 static void … … 107 142 #endif 108 143 109 PRIV (image_ptr) += offset;144 PRIV (image_ptr) += offset; 110 145 111 146 return; 112 147 } 113 148 114 /* Dump multiple bytes to section image */149 /* Dump multiple bytes to section image. */ 115 150 116 151 static void … … 122 157 { 123 158 #if VMS_DEBUG 124 _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr)); 159 _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, 160 PRIV (image_ptr)); 125 161 _bfd_hexdump (9, ptr, size, offset); 126 162 #endif 127 163 128 if (PRIV (is_vax) && check_section (abfd, size))164 if (PRIV (is_vax) && check_section (abfd, size)) 129 165 return; 130 166 131 167 while (size-- > 0) 132 *PRIV (image_ptr)++ = *ptr++;168 *PRIV (image_ptr)++ = *ptr++; 133 169 return; 134 170 } 135 171 136 /* Write byte to section image */172 /* Write byte to section image. */ 137 173 138 174 static void … … 142 178 { 143 179 #if VMS_DEBUG 144 _bfd_vms_debug (6, "image_write_b(%02x)\n", (int) value);145 #endif 146 147 if (PRIV (is_vax) && check_section (abfd, 1))180 _bfd_vms_debug (6, "image_write_b(%02x)\n", (int) value); 181 #endif 182 183 if (PRIV (is_vax) && check_section (abfd, 1)) 148 184 return; 149 185 150 *PRIV (image_ptr)++ = (value & 0xff);186 *PRIV (image_ptr)++ = (value & 0xff); 151 187 return; 152 188 } 153 189 154 /* Write 2-byte word to image */190 /* Write 2-byte word to image. */ 155 191 156 192 static void … … 160 196 { 161 197 #if VMS_DEBUG 162 _bfd_vms_debug (6, "image_write_w(%04x)\n", (int) value);163 #endif 164 165 if (PRIV (is_vax) && check_section (abfd, 2))198 _bfd_vms_debug (6, "image_write_w(%04x)\n", (int) value); 199 #endif 200 201 if (PRIV (is_vax) && check_section (abfd, 2)) 166 202 return; 167 203 168 bfd_putl16 ( value, PRIV(image_ptr));169 PRIV (image_ptr) += 2;204 bfd_putl16 ((bfd_vma) value, PRIV (image_ptr)); 205 PRIV (image_ptr) += 2; 170 206 171 207 return; 172 208 } 173 209 174 /* Write 4-byte long to image */210 /* Write 4-byte long to image. */ 175 211 176 212 static void … … 183 219 #endif 184 220 185 if (PRIV (is_vax) && check_section (abfd, 4))221 if (PRIV (is_vax) && check_section (abfd, 4)) 186 222 return; 187 223 188 bfd_putl32 ( value, PRIV(image_ptr));189 PRIV (image_ptr) += 4;224 bfd_putl32 ((bfd_vma) value, PRIV (image_ptr)); 225 PRIV (image_ptr) += 4; 190 226 191 227 return; 192 228 } 193 229 194 /* Write 8-byte quad to image */230 /* Write 8-byte quad to image. */ 195 231 196 232 static void … … 203 239 #endif 204 240 205 if (PRIV (is_vax) && check_section (abfd, 8))241 if (PRIV (is_vax) && check_section (abfd, 8)) 206 242 return; 207 243 208 bfd_putl64 (value, PRIV (image_ptr));209 PRIV (image_ptr) += 8;244 bfd_putl64 (value, PRIV (image_ptr)); 245 PRIV (image_ptr) += 8; 210 246 211 247 return; … … 213 249 214 250 215 251 static const char * 252 cmd_name (cmd) 253 int cmd; 254 { 255 switch (cmd) 256 { 257 case ETIR_S_C_STA_GBL: return "ETIR_S_C_STA_GBL"; 258 case ETIR_S_C_STA_PQ: return "ETIR_S_C_STA_PQ"; 259 case ETIR_S_C_STA_LI: return "ETIR_S_C_STA_LI"; 260 case ETIR_S_C_STA_MOD: return "ETIR_S_C_STA_MOD"; 261 case ETIR_S_C_STA_CKARG: return "ETIR_S_C_STA_CKARG"; 262 case ETIR_S_C_STO_B: return "ETIR_S_C_STO_B"; 263 case ETIR_S_C_STO_W: return "ETIR_S_C_STO_W"; 264 case ETIR_S_C_STO_GBL: return "ETIR_S_C_STO_GBL"; 265 case ETIR_S_C_STO_CA: return "ETIR_S_C_STO_CA"; 266 case ETIR_S_C_STO_RB: return "ETIR_S_C_STO_RB"; 267 case ETIR_S_C_STO_AB: return "ETIR_S_C_STO_AB"; 268 case ETIR_S_C_STO_GBL_LW: return "ETIR_S_C_STO_GBL_LW"; 269 case ETIR_S_C_STO_LP_PSB: return "ETIR_S_C_STO_LP_PSB"; 270 case ETIR_S_C_STO_HINT_GBL: return "ETIR_S_C_STO_HINT_GBL"; 271 case ETIR_S_C_STO_HINT_PS: return "ETIR_S_C_STO_HINT_PS"; 272 case ETIR_S_C_OPR_INSV: return "ETIR_S_C_OPR_INSV"; 273 case ETIR_S_C_OPR_USH: return "ETIR_S_C_OPR_USH"; 274 case ETIR_S_C_OPR_ROT: return "ETIR_S_C_OPR_ROT"; 275 case ETIR_S_C_OPR_REDEF: return "ETIR_S_C_OPR_REDEF"; 276 case ETIR_S_C_OPR_DFLIT: return "ETIR_S_C_OPR_DFLIT"; 277 case ETIR_S_C_STC_LP: return "ETIR_S_C_STC_LP"; 278 case ETIR_S_C_STC_GBL: return "ETIR_S_C_STC_GBL"; 279 case ETIR_S_C_STC_GCA: return "ETIR_S_C_STC_GCA"; 280 case ETIR_S_C_STC_PS: return "ETIR_S_C_STC_PS"; 281 case ETIR_S_C_STC_NBH_PS: return "ETIR_S_C_STC_NBH_PS"; 282 case ETIR_S_C_STC_NOP_GBL: return "ETIR_S_C_STC_NOP_GBL"; 283 case ETIR_S_C_STC_NOP_PS: return "ETIR_S_C_STC_NOP_PS"; 284 case ETIR_S_C_STC_BSR_GBL: return "ETIR_S_C_STC_BSR_GBL"; 285 case ETIR_S_C_STC_BSR_PS: return "ETIR_S_C_STC_BSR_PS"; 286 case ETIR_S_C_STC_LDA_GBL: return "ETIR_S_C_STC_LDA_GBL"; 287 case ETIR_S_C_STC_LDA_PS: return "ETIR_S_C_STC_LDA_PS"; 288 case ETIR_S_C_STC_BOH_GBL: return "ETIR_S_C_STC_BOH_GBL"; 289 case ETIR_S_C_STC_BOH_PS: return "ETIR_S_C_STC_BOH_PS"; 290 case ETIR_S_C_STC_NBH_GBL: return "ETIR_S_C_STC_NBH_GBL"; 291 292 default: 293 /* These names have not yet been added to this switch statement. */ 294 abort (); 295 } 296 } 216 297 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L) 217 298 … … 223 304 ptr points to data area in record 224 305 225 see table B-8 of the openVMS linker manual */226 227 static b oolean306 see table B-8 of the openVMS linker manual. */ 307 308 static bfd_boolean 228 309 etir_sta (abfd, cmd, ptr) 229 310 bfd *abfd; … … 234 315 #if VMS_DEBUG 235 316 _bfd_vms_debug (5, "etir_sta %d/%x\n", cmd, cmd); 236 _bfd_hexdump (8, ptr, 16, (int) ptr);317 _bfd_hexdump (8, ptr, 16, (int) ptr); 237 318 #endif 238 319 … … 242 323 243 324 /* stack global 244 arg: cs symbol name 245 246 stack 32 bit value of symbol (high bits set to 0) */ 247 248 case ETIR_S_C_STA_GBL: 249 { 250 char *name; 251 vms_symbol_entry *entry; 252 253 name = _bfd_vms_save_counted_string (ptr); 254 entry = (vms_symbol_entry *) 255 bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false); 256 if (entry == (vms_symbol_entry *)NULL) 257 { 258 #if VMS_DEBUG 259 _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name); 260 #endif 261 _bfd_vms_push (abfd, (uquad)0, -1); 262 } 263 else 264 { 265 _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1); 266 } 267 } 268 break; 269 270 /* stack longword 271 arg: lw value 272 273 stack 32 bit value, sign extend to 64 bit */ 274 275 case ETIR_S_C_STA_LW: 276 _bfd_vms_push (abfd, (uquad)bfd_getl32 (ptr), -1); 277 break; 278 279 /* stack global 280 arg: qw value 281 282 stack 64 bit value of symbol */ 283 284 case ETIR_S_C_STA_QW: 285 _bfd_vms_push (abfd, (uquad)bfd_getl64(ptr), -1); 286 break; 287 288 /* stack psect base plus quadword offset 289 arg: lw section index 290 qw signed quadword offset (low 32 bits) 291 292 stack qw argument and section index 293 (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */ 294 295 case ETIR_S_C_STA_PQ: 296 { 297 uquad dummy; 298 unsigned int psect; 299 300 psect = bfd_getl32 (ptr); 301 if (psect >= PRIV(section_count)) 302 { 303 (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ")); 304 bfd_set_error (bfd_error_bad_value); 305 return false; 306 } 307 dummy = bfd_getl64 (ptr+4); 308 _bfd_vms_push (abfd, dummy, psect); 309 } 310 break; 311 312 /* all not supported */ 313 314 case ETIR_S_C_STA_LI: 315 case ETIR_S_C_STA_MOD: 316 case ETIR_S_C_STA_CKARG: 317 318 (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd); 319 return false; 320 break; 321 322 default: 323 (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd); 324 return false; 325 arg: cs symbol name 326 327 stack 32 bit value of symbol (high bits set to 0) */ 328 329 case ETIR_S_C_STA_GBL: 330 { 331 char *name; 332 vms_symbol_entry *entry; 333 334 name = _bfd_vms_save_counted_string (ptr); 335 entry = (vms_symbol_entry *) 336 bfd_hash_lookup (PRIV (vms_symbol_table), name, FALSE, FALSE); 337 if (entry == (vms_symbol_entry *) NULL) 338 { 339 #if VMS_DEBUG 340 _bfd_vms_debug (3, "%s: no symbol \"%s\"\n", 341 cmd_name (cmd), name); 342 #endif 343 _bfd_vms_push (abfd, (uquad) 0, -1); 344 } 345 else 346 { 347 _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1); 348 } 349 } 350 break; 351 352 /* stack longword 353 arg: lw value 354 355 stack 32 bit value, sign extend to 64 bit */ 356 357 case ETIR_S_C_STA_LW: 358 _bfd_vms_push (abfd, (uquad) bfd_getl32 (ptr), -1); 359 break; 360 361 /* stack global 362 arg: qw value 363 364 stack 64 bit value of symbol */ 365 366 case ETIR_S_C_STA_QW: 367 _bfd_vms_push (abfd, (uquad) bfd_getl64 (ptr), -1); 368 break; 369 370 /* stack psect base plus quadword offset 371 arg: lw section index 372 qw signed quadword offset (low 32 bits) 373 374 stack qw argument and section index 375 (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */ 376 377 case ETIR_S_C_STA_PQ: 378 { 379 uquad dummy; 380 unsigned int psect; 381 382 psect = bfd_getl32 (ptr); 383 if (psect >= PRIV (section_count)) 384 { 385 (*_bfd_error_handler) (_("bad section index in %s"), 386 cmd_name (cmd)); 387 bfd_set_error (bfd_error_bad_value); 388 return FALSE; 389 } 390 dummy = bfd_getl64 (ptr+4); 391 _bfd_vms_push (abfd, dummy, (int) psect); 392 } 393 break; 394 395 case ETIR_S_C_STA_LI: 396 case ETIR_S_C_STA_MOD: 397 case ETIR_S_C_STA_CKARG: 398 (*_bfd_error_handler) (_("unsupported STA cmd %s"), cmd_name (cmd)); 399 return FALSE; 400 break; 401 402 default: 403 (*_bfd_error_handler) (_("reserved STA cmd %d"), cmd); 404 return FALSE; 325 405 break; 326 406 } … … 328 408 _bfd_vms_debug (5, "etir_sta true\n"); 329 409 #endif 330 return true;410 return TRUE; 331 411 } 332 412 … … 339 419 ptr points to data area in record 340 420 341 see table B-9 of the openVMS linker manual */342 343 static b oolean421 see table B-9 of the openVMS linker manual. */ 422 423 static bfd_boolean 344 424 etir_sto (abfd, cmd, ptr) 345 425 bfd *abfd; … … 352 432 #if VMS_DEBUG 353 433 _bfd_vms_debug (5, "etir_sto %d/%x\n", cmd, cmd); 354 _bfd_hexdump (8, ptr, 16, (int) ptr);434 _bfd_hexdump (8, ptr, 16, (int) ptr); 355 435 #endif 356 436 357 437 switch (cmd) 358 438 { 359 360 439 /* store byte: pop stack, write byte 361 440 arg: - */ … … 365 444 #if 0 366 445 if (is_share) /* FIXME */ 367 (*_bfd_error_handler) ("ETIR_S_C_STO_B: byte fixups not supported"); 368 #endif 369 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */ 446 (*_bfd_error_handler) ("%s: byte fixups not supported", 447 cmd_name (cmd)); 448 #endif 449 /* FIXME: check top bits */ 450 image_write_b (abfd, (unsigned int) dummy & 0xff); 370 451 break; 371 452 … … 377 458 #if 0 378 459 if (is_share) /* FIXME */ 379 (*_bfd_error_handler) ("ETIR_S_C_STO_B: word fixups not supported"); 380 #endif 381 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */ 460 (*_bfd_error_handler) ("%s: word fixups not supported", 461 cmd_name (cmd)); 462 #endif 463 /* FIXME: check top bits */ 464 image_write_w (abfd, (unsigned int) dummy & 0xffff); 382 465 break; 383 466 … … 387 470 case ETIR_S_C_STO_LW: 388 471 dummy = _bfd_vms_pop (abfd, &psect); 389 dummy += (PRIV(sections)[psect])->vma; 390 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */ 472 dummy += (PRIV (sections)[psect])->vma; 473 /* FIXME: check top bits. */ 474 image_write_l (abfd, (unsigned int) dummy & 0xffffffff); 391 475 break; 392 476 … … 396 480 case ETIR_S_C_STO_QW: 397 481 dummy = _bfd_vms_pop (abfd, &psect); 398 dummy += (PRIV (sections)[psect])->vma;482 dummy += (PRIV (sections)[psect])->vma; 399 483 image_write_q (abfd, dummy); /* FIXME: check top bits */ 400 484 break; … … 406 490 case ETIR_S_C_STO_IMMR: 407 491 { 408 unsigned longsize;492 int size; 409 493 410 494 size = bfd_getl32 (ptr); 411 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);412 while (dummy-- > 0 L)495 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 496 while (dummy-- > 0) 413 497 image_dump (abfd, ptr+4, size, 0); 414 498 } … … 416 500 417 501 /* store global: write symbol value 418 arg: cs global symbol name */502 arg: cs global symbol name. */ 419 503 420 504 case ETIR_S_C_STO_GBL: … … 424 508 425 509 name = _bfd_vms_save_counted_string (ptr); 426 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false); 427 if (entry == (vms_symbol_entry *)NULL) 510 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table), 511 name, FALSE, FALSE); 512 if (entry == (vms_symbol_entry *) NULL) 428 513 { 429 (*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""), 430 name); 431 return false; 514 (*_bfd_error_handler) (_("%s: no symbol \"%s\""), 515 cmd_name (cmd), name); 516 return FALSE; 517 } 518 else 519 /* FIXME, reloc. */ 520 image_write_q (abfd, (uquad) (entry->symbol->value)); 521 } 522 break; 523 524 /* store code address: write address of entry point 525 arg: cs global symbol name (procedure). */ 526 527 case ETIR_S_C_STO_CA: 528 { 529 vms_symbol_entry *entry; 530 char *name; 531 532 name = _bfd_vms_save_counted_string (ptr); 533 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table), 534 name, FALSE, FALSE); 535 if (entry == (vms_symbol_entry *) NULL) 536 { 537 (*_bfd_error_handler) (_("%s: no symbol \"%s\""), 538 cmd_name (cmd), name); 539 return FALSE; 432 540 } 433 541 else … … 436 544 break; 437 545 438 /* store code address: write address of entry point 439 arg: cs global symbol name (procedure) */ 440 441 case ETIR_S_C_STO_CA: 442 { 443 vms_symbol_entry *entry; 444 char *name; 445 446 name = _bfd_vms_save_counted_string (ptr); 447 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false); 448 if (entry == (vms_symbol_entry *)NULL) 449 { 450 (*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""), 451 name); 452 return false; 453 } 454 else 455 image_write_q (abfd, (uquad) (entry->symbol->value)); /* FIXME, reloc */ 456 } 457 break; 458 459 /* not supported */ 460 461 case ETIR_S_C_STO_RB: 462 case ETIR_S_C_STO_AB: 463 (*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported")); 464 break; 465 466 /* store offset to psect: pop stack, add low 32 bits to base of psect 467 arg: - */ 546 /* Store offset to psect: pop stack, add low 32 bits to base of psect 547 arg: none. */ 468 548 469 549 case ETIR_S_C_STO_OFF: 470 550 { 471 551 uquad q; 472 int psect ;473 474 q = _bfd_vms_pop (abfd, &psect );475 q += (PRIV (sections)[psect])->vma;552 int psect1; 553 554 q = _bfd_vms_pop (abfd, &psect1); 555 q += (PRIV (sections)[psect1])->vma; 476 556 image_write_q (abfd, q); 477 557 } 478 558 break; 479 559 480 /* store immediate560 /* Store immediate 481 561 arg: lw count of bytes 482 da data*/562 da data. */ 483 563 484 564 case ETIR_S_C_STO_IMM: … … 491 571 break; 492 572 493 /* this code is 'reserved to digital' according to the openVMS linker manual, 494 however it is generated by the DEC C compiler and defined in the include file. 573 /* This code is 'reserved to digital' according to the openVMS 574 linker manual, however it is generated by the DEC C compiler 575 and defined in the include file. 495 576 FIXME, since the following is just a guess 496 577 store global longword: store 32bit value of symbol 497 arg: cs symbol name */578 arg: cs symbol name. */ 498 579 499 580 case ETIR_S_C_STO_GBL_LW: … … 503 584 504 585 name = _bfd_vms_save_counted_string (ptr); 505 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false); 506 if (entry == (vms_symbol_entry *)NULL) 586 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table), 587 name, FALSE, FALSE); 588 if (entry == (vms_symbol_entry *) NULL) 507 589 { 508 590 #if VMS_DEBUG 509 _bfd_vms_debug (3, " ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name);510 #endif 511 image_write_l (abfd, (unsigned long) 0); /* FIXME, reloc */591 _bfd_vms_debug (3, "%s: no symbol \"%s\"\n", cmd_name (cmd), name); 592 #endif 593 image_write_l (abfd, (unsigned long) 0); /* FIXME, reloc */ 512 594 } 513 595 else 514 image_write_l (abfd, (unsigned long) (entry->symbol->value)); /* FIXME, reloc */ 596 /* FIXME, reloc. */ 597 image_write_l (abfd, (unsigned long) (entry->symbol->value)); 515 598 } 516 599 break; 517 600 518 /* not supported */519 601 case ETIR_S_C_STO_RB: 602 case ETIR_S_C_STO_AB: 520 603 case ETIR_S_C_STO_LP_PSB: 521 (*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported")); 522 break; 523 524 /* */ 604 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 605 break; 525 606 526 607 case ETIR_S_C_STO_HINT_GBL: 527 (*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));528 break;529 530 /* */531 532 608 case ETIR_S_C_STO_HINT_PS: 533 (*_bfd_error_handler) (_(" ETIR_S_C_STO_HINT_PS: not implemented"));609 (*_bfd_error_handler) (_("%s: not implemented"), cmd_name (cmd)); 534 610 break; 535 611 536 612 default: 537 (*_bfd_error_handler) (_(" Reserved STO cmd %d"), cmd);613 (*_bfd_error_handler) (_("reserved STO cmd %d"), cmd); 538 614 break; 539 615 } 540 616 541 return true;542 } 543 544 /* stack operator commands617 return TRUE; 618 } 619 620 /* Stack operator commands 545 621 all 32 bit signed arithmetic 546 622 all word just like a stack calculator 547 623 arguments are popped from stack, results are pushed on stack 548 624 549 see table B-10 of the openVMS linker manual */550 551 static b oolean625 see table B-10 of the openVMS linker manual. */ 626 627 static bfd_boolean 552 628 etir_opr (abfd, cmd, ptr) 553 629 bfd *abfd; … … 559 635 #if VMS_DEBUG 560 636 _bfd_vms_debug (5, "etir_opr %d/%x\n", cmd, cmd); 561 _bfd_hexdump (8, ptr, 16, (int) ptr);637 _bfd_hexdump (8, ptr, 16, (int) ptr); 562 638 #endif 563 639 564 640 switch (cmd) 565 641 { 566 /* operation */ 567 568 /* no-op */ 569 570 case ETIR_S_C_OPR_NOP: 571 break; 572 573 /* add */ 574 575 case ETIR_S_C_OPR_ADD: 576 op1 = (long)_bfd_vms_pop (abfd, NULL); 577 op2 = (long)_bfd_vms_pop (abfd, NULL); 642 case ETIR_S_C_OPR_NOP: /* no-op */ 643 break; 644 645 case ETIR_S_C_OPR_ADD: /* add */ 646 op1 = (long) _bfd_vms_pop (abfd, NULL); 647 op2 = (long) _bfd_vms_pop (abfd, NULL); 578 648 _bfd_vms_push (abfd, (uquad) (op1 + op2), -1); 579 649 break; 580 650 581 /* subtract */ 582 583 case ETIR_S_C_OPR_SUB: 584 op1 = (long)_bfd_vms_pop (abfd, NULL); 585 op2 = (long)_bfd_vms_pop (abfd, NULL); 651 case ETIR_S_C_OPR_SUB: /* subtract */ 652 op1 = (long) _bfd_vms_pop (abfd, NULL); 653 op2 = (long) _bfd_vms_pop (abfd, NULL); 586 654 _bfd_vms_push (abfd, (uquad) (op2 - op1), -1); 587 655 break; 588 656 589 /* multiply */ 590 591 case ETIR_S_C_OPR_MUL: 592 op1 = (long)_bfd_vms_pop (abfd, NULL); 593 op2 = (long)_bfd_vms_pop (abfd, NULL); 657 case ETIR_S_C_OPR_MUL: /* multiply */ 658 op1 = (long) _bfd_vms_pop (abfd, NULL); 659 op2 = (long) _bfd_vms_pop (abfd, NULL); 594 660 _bfd_vms_push (abfd, (uquad) (op1 * op2), -1); 595 661 break; 596 662 597 /* divide */ 598 599 case ETIR_S_C_OPR_DIV: 600 op1 = (long)_bfd_vms_pop (abfd, NULL); 601 op2 = (long)_bfd_vms_pop (abfd, NULL); 663 case ETIR_S_C_OPR_DIV: /* divide */ 664 op1 = (long) _bfd_vms_pop (abfd, NULL); 665 op2 = (long) _bfd_vms_pop (abfd, NULL); 602 666 if (op2 == 0) 603 _bfd_vms_push (abfd, (uquad) 0L, -1);667 _bfd_vms_push (abfd, (uquad) 0, -1); 604 668 else 605 669 _bfd_vms_push (abfd, (uquad) (op2 / op1), -1); 606 670 break; 607 671 608 /* logical and */ 609 610 case ETIR_S_C_OPR_AND: 611 op1 = (long)_bfd_vms_pop (abfd, NULL); 612 op2 = (long)_bfd_vms_pop (abfd, NULL); 672 case ETIR_S_C_OPR_AND: /* logical and */ 673 op1 = (long) _bfd_vms_pop (abfd, NULL); 674 op2 = (long) _bfd_vms_pop (abfd, NULL); 613 675 _bfd_vms_push (abfd, (uquad) (op1 & op2), -1); 614 676 break; 615 677 616 /* logical inclusive or */ 617 618 case ETIR_S_C_OPR_IOR: 619 op1 = (long)_bfd_vms_pop (abfd, NULL); 620 op2 = (long)_bfd_vms_pop (abfd, NULL); 678 case ETIR_S_C_OPR_IOR: /* logical inclusive or */ 679 op1 = (long) _bfd_vms_pop (abfd, NULL); 680 op2 = (long) _bfd_vms_pop (abfd, NULL); 621 681 _bfd_vms_push (abfd, (uquad) (op1 | op2), -1); 622 682 break; 623 683 624 /* logical exclusive or */ 625 626 case ETIR_S_C_OPR_EOR: 627 op1 = (long)_bfd_vms_pop (abfd, NULL); 628 op2 = (long)_bfd_vms_pop (abfd, NULL); 684 case ETIR_S_C_OPR_EOR: /* logical exclusive or */ 685 op1 = (long) _bfd_vms_pop (abfd, NULL); 686 op2 = (long) _bfd_vms_pop (abfd, NULL); 629 687 _bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1); 630 688 break; 631 689 632 /* negate */ 633 634 case ETIR_S_C_OPR_NEG: 635 op1 = (long)_bfd_vms_pop (abfd, NULL); 690 case ETIR_S_C_OPR_NEG: /* negate */ 691 op1 = (long) _bfd_vms_pop (abfd, NULL); 636 692 _bfd_vms_push (abfd, (uquad) (-op1), -1); 637 693 break; 638 694 639 /* complement */ 640 641 case ETIR_S_C_OPR_COM: 642 op1 = (long)_bfd_vms_pop (abfd, NULL); 695 case ETIR_S_C_OPR_COM: /* complement */ 696 op1 = (long) _bfd_vms_pop (abfd, NULL); 643 697 _bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1); 644 698 break; 645 699 646 /* insert field */ 647 648 case ETIR_S_C_OPR_INSV: 649 (void)_bfd_vms_pop (abfd, NULL); 650 (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported")); 651 break; 652 653 /* arithmetic shift */ 654 655 case ETIR_S_C_OPR_ASH: 656 op1 = (long)_bfd_vms_pop (abfd, NULL); 657 op2 = (long)_bfd_vms_pop (abfd, NULL); 700 case ETIR_S_C_OPR_ASH: /* arithmetic shift */ 701 op1 = (long) _bfd_vms_pop (abfd, NULL); 702 op2 = (long) _bfd_vms_pop (abfd, NULL); 658 703 if (op2 < 0) /* shift right */ 659 704 op1 >>= -op2; 660 705 else /* shift left */ 661 706 op1 <<= op2; 662 _bfd_vms_push (abfd, (uquad)op1, -1); 663 break; 664 665 /* unsigned shift */ 666 667 case ETIR_S_C_OPR_USH: 668 (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported")); 669 break; 670 671 /* rotate */ 672 673 case ETIR_S_C_OPR_ROT: 674 (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported")); 675 break; 676 677 /* select */ 678 679 case ETIR_S_C_OPR_SEL: 680 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L) 681 (void)_bfd_vms_pop (abfd, NULL); 707 _bfd_vms_push (abfd, (uquad) op1, -1); 708 break; 709 710 case ETIR_S_C_OPR_INSV: /* insert field */ 711 (void) _bfd_vms_pop (abfd, NULL); 712 case ETIR_S_C_OPR_USH: /* unsigned shift */ 713 case ETIR_S_C_OPR_ROT: /* rotate */ 714 case ETIR_S_C_OPR_REDEF: /* Redefine symbol to current location. */ 715 case ETIR_S_C_OPR_DFLIT: /* Define a literal. */ 716 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 717 break; 718 719 case ETIR_S_C_OPR_SEL: /* select */ 720 if ((long) _bfd_vms_pop (abfd, NULL) & 0x01L) 721 (void) _bfd_vms_pop (abfd, NULL); 682 722 else 683 723 { 684 op1 = (long) _bfd_vms_pop (abfd, NULL);685 (void) _bfd_vms_pop (abfd, NULL);686 _bfd_vms_push (abfd, (uquad) op1, -1);724 op1 = (long) _bfd_vms_pop (abfd, NULL); 725 (void) _bfd_vms_pop (abfd, NULL); 726 _bfd_vms_push (abfd, (uquad) op1, -1); 687 727 } 688 728 break; 689 729 690 /* redefine symbol to current location */691 692 case ETIR_S_C_OPR_REDEF:693 (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));694 break;695 696 /* define a literal */697 698 case ETIR_S_C_OPR_DFLIT:699 (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));700 break;701 702 730 default: 703 (*_bfd_error_handler) (_(" Reserved OPR cmd %d"), cmd);731 (*_bfd_error_handler) (_("reserved OPR cmd %d"), cmd); 704 732 break; 705 733 } 706 734 707 return true;708 } 709 710 /* control commands711 712 see table B-11 of the openVMS linker manual*/713 714 static b oolean735 return TRUE; 736 } 737 738 /* Control commands. 739 740 See table B-11 of the openVMS linker manual. */ 741 742 static bfd_boolean 715 743 etir_ctl (abfd, cmd, ptr) 716 744 bfd *abfd; … … 723 751 #if VMS_DEBUG 724 752 _bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd); 725 _bfd_hexdump (8, ptr, 16, (int) ptr);753 _bfd_hexdump (8, ptr, 16, (int) ptr); 726 754 #endif 727 755 … … 729 757 { 730 758 /* set relocation base: pop stack, set image location counter 731 arg: -*/759 arg: none. */ 732 760 733 761 case ETIR_S_C_CTL_SETRB: … … 745 773 746 774 /* define location: pop index, save location counter under index 747 arg: -*/775 arg: none. */ 748 776 749 777 case ETIR_S_C_CTL_DFLOC: … … 753 781 754 782 /* set location: pop index, restore location counter from index 755 arg: -*/783 arg: none. */ 756 784 757 785 case ETIR_S_C_CTL_STLOC: … … 761 789 762 790 /* stack defined location: pop index, push location counter from index 763 arg: -*/791 arg: none. */ 764 792 765 793 case ETIR_S_C_CTL_STKDL: … … 769 797 770 798 default: 771 (*_bfd_error_handler) (_(" Reserved CTL cmd %d"), cmd);799 (*_bfd_error_handler) (_("reserved CTL cmd %d"), cmd); 772 800 break; 773 801 } 774 return true;802 return TRUE; 775 803 } 776 804 777 805 /* store conditional commands 778 806 779 see table B-12 and B-13 of the openVMS linker manual*/780 781 static b oolean807 See table B-12 and B-13 of the openVMS linker manual. */ 808 809 static bfd_boolean 782 810 etir_stc (abfd, cmd, ptr) 783 811 bfd *abfd; … … 785 813 unsigned char *ptr ATTRIBUTE_UNUSED; 786 814 { 787 788 815 #if VMS_DEBUG 789 816 _bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd); 790 _bfd_hexdump (8, ptr, 16, (int) ptr);817 _bfd_hexdump (8, ptr, 16, (int) ptr); 791 818 #endif 792 819 … … 794 821 { 795 822 /* 200 Store-conditional Linkage Pair 796 arg: */823 arg: none. */ 797 824 798 825 case ETIR_S_C_STC_LP: 799 (*_bfd_error_handler) (_(" ETIR_S_C_STC_LP: not supported"));826 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 800 827 break; 801 828 802 829 /* 201 Store-conditional Linkage Pair with Procedure Signature 803 830 arg: lw linkage index 804 805 806 da signature*/831 cs procedure name 832 by signature length 833 da signature. */ 807 834 808 835 case ETIR_S_C_STC_LP_PSB: 809 image_inc_ptr (abfd, 16); /* skip entry,procval */836 image_inc_ptr (abfd, (uquad) 16); /* skip entry,procval */ 810 837 break; 811 838 812 839 /* 202 Store-conditional Address at global address 813 840 arg: lw linkage index 814 cs global name*/841 cs global name. */ 815 842 816 843 case ETIR_S_C_STC_GBL: 817 (*_bfd_error_handler) (_(" ETIR_S_C_STC_GBL: not supported"));844 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 818 845 break; 819 846 820 847 /* 203 Store-conditional Code Address at global address 821 848 arg: lw linkage index 822 cs procedure name*/849 cs procedure name. */ 823 850 824 851 case ETIR_S_C_STC_GCA: 825 (*_bfd_error_handler) (_(" ETIR_S_C_STC_GCA: not supported"));852 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 826 853 break; 827 854 828 855 /* 204 Store-conditional Address at psect + offset 829 856 arg: lw linkage index 830 831 qw offset*/857 lw psect index 858 qw offset. */ 832 859 833 860 case ETIR_S_C_STC_PS: 834 (*_bfd_error_handler) (_(" ETIR_S_C_STC_PS: not supported"));861 (*_bfd_error_handler) (_("%s: not supported"), cmd_name (cmd)); 835 862 break; 836 863 837 864 /* 205 Store-conditional NOP at address of global 838 arg: */865 arg: none. */ 839 866 840 867 case ETIR_S_C_STC_NOP_GBL: 841 868 842 869 /* 206 Store-conditional NOP at pect + offset 843 arg: */870 arg: none. */ 844 871 845 872 case ETIR_S_C_STC_NOP_PS: 846 873 847 874 /* 207 Store-conditional BSR at global address 848 arg: */875 arg: none. */ 849 876 850 877 case ETIR_S_C_STC_BSR_GBL: 851 878 852 879 /* 208 Store-conditional BSR at pect + offset 853 arg: */880 arg: none. */ 854 881 855 882 case ETIR_S_C_STC_BSR_PS: 856 883 857 884 /* 209 Store-conditional LDA at global address 858 arg: */885 arg: none. */ 859 886 860 887 case ETIR_S_C_STC_LDA_GBL: 861 888 862 889 /* 210 Store-conditional LDA at psect + offset 863 arg: */890 arg: none. */ 864 891 865 892 case ETIR_S_C_STC_LDA_PS: 866 893 867 894 /* 211 Store-conditional BSR or Hint at global address 868 arg: */895 arg: none. */ 869 896 870 897 case ETIR_S_C_STC_BOH_GBL: 871 898 872 899 /* 212 Store-conditional BSR or Hint at pect + offset 873 arg: */900 arg: none. */ 874 901 875 902 case ETIR_S_C_STC_BOH_PS: 876 903 877 904 /* 213 Store-conditional NOP,BSR or HINT at global address 878 arg: */905 arg: none. */ 879 906 880 907 case ETIR_S_C_STC_NBH_GBL: 881 908 882 909 /* 214 Store-conditional NOP,BSR or HINT at psect + offset 883 arg: */910 arg: none. */ 884 911 885 912 case ETIR_S_C_STC_NBH_PS: 886 /* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */ 913 /* FIXME */ 914 #if 0 915 (*_bfd_error_handler) ("%s: not supported", cmd_name (cmd)); 916 #endif 887 917 break; 888 918 889 919 default: 890 920 #if VMS_DEBUG 891 _bfd_vms_debug (3, " Reserved STC cmd %d", cmd);921 _bfd_vms_debug (3, "reserved STC cmd %d", cmd); 892 922 #endif 893 923 break; 894 924 } 895 return true;925 return TRUE; 896 926 } 897 927 … … 906 936 907 937 #if VMS_DEBUG 908 _bfd_vms_debug (5, 938 _bfd_vms_debug (5, "new_section %d\n", idx); 909 939 #endif 910 940 sprintf (sname, SECTION_NAME_TEMPLATE, idx); 911 941 912 name = bfd_malloc ( strlen (sname) + 1);942 name = bfd_malloc ((bfd_size_type) strlen (sname) + 1); 913 943 if (name == 0) 914 944 return 0; 915 945 strcpy (name, sname); 916 946 917 section = bfd_malloc ( sizeof (asection));947 section = bfd_malloc ((bfd_size_type) sizeof (asection)); 918 948 if (section == 0) 919 949 { … … 939 969 unsigned int idx; 940 970 { 941 #if VMS_DEBUG 942 _bfd_vms_debug (4, "alloc_section %d\n", idx); 943 #endif 944 945 PRIV(sections) = ((asection **) 946 bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *))); 947 if (PRIV(sections) == 0) 971 bfd_size_type amt; 972 973 #if VMS_DEBUG 974 _bfd_vms_debug (4, "alloc_section %d\n", idx); 975 #endif 976 977 amt = idx + 1; 978 amt *= sizeof (asection *); 979 PRIV (sections) = (asection **) bfd_realloc (PRIV (sections), amt); 980 if (PRIV (sections) == 0) 948 981 return -1; 949 982 950 while (PRIV (section_count) <= idx)983 while (PRIV (section_count) <= idx) 951 984 { 952 PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count)); 953 if (PRIV(sections)[PRIV(section_count)] == 0) 985 PRIV (sections)[PRIV (section_count)] 986 = new_section (abfd, (int) PRIV (section_count)); 987 if (PRIV (sections)[PRIV (section_count)] == 0) 954 988 return -1; 955 PRIV (section_count)++;989 PRIV (section_count)++; 956 990 } 957 991 … … 959 993 } 960 994 961 /* 962 * tir_sta 963 * 964 * vax stack commands 965 * 966 * handle sta_xxx commands in tir section 967 * ptr points to data area in record 968 * 969 * see table 7-3 of the VAX/VMS linker manual 970 */ 995 /* tir_sta 996 997 vax stack commands 998 999 Handle sta_xxx commands in tir section 1000 ptr points to data area in record 1001 1002 See table 7-3 of the VAX/VMS linker manual. */ 971 1003 972 1004 static unsigned char * … … 981 1013 switch (cmd) 982 1014 { 983 /* stack */ 984 case TIR_S_C_STA_GBL: 985 /* 986 * stack global 987 * arg: cs symbol name 988 * 989 * stack 32 bit value of symbol (high bits set to 0) 990 */ 991 { 992 char *name; 993 vms_symbol_entry *entry; 994 995 name = _bfd_vms_save_counted_string (ptr); 996 997 entry = _bfd_vms_enter_symbol (abfd, name); 998 if (entry == (vms_symbol_entry *)NULL) 999 return 0; 1000 1001 _bfd_vms_push (abfd, (unsigned long) (entry->symbol->value), -1); 1002 ptr += *ptr + 1; 1003 } 1004 break; 1005 1006 case TIR_S_C_STA_SB: 1007 /* 1008 * stack signed byte 1009 * arg: by value 1010 * 1011 * stack byte value, sign extend to 32 bit 1012 */ 1013 _bfd_vms_push (abfd, (long)*ptr++, -1); 1014 break; 1015 1016 case TIR_S_C_STA_SW: 1017 /* 1018 * stack signed short word 1019 * arg: sh value 1020 * 1021 * stack 16 bit value, sign extend to 32 bit 1022 */ 1023 _bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1); 1015 /* stack */ 1016 case TIR_S_C_STA_GBL: 1017 /* stack global 1018 arg: cs symbol name 1019 1020 stack 32 bit value of symbol (high bits set to 0). */ 1021 { 1022 char *name; 1023 vms_symbol_entry *entry; 1024 1025 name = _bfd_vms_save_counted_string (ptr); 1026 1027 entry = _bfd_vms_enter_symbol (abfd, name); 1028 if (entry == (vms_symbol_entry *) NULL) 1029 return 0; 1030 1031 _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1); 1032 ptr += *ptr + 1; 1033 } 1034 break; 1035 1036 case TIR_S_C_STA_SB: 1037 /* stack signed byte 1038 arg: by value 1039 1040 stack byte value, sign extend to 32 bit. */ 1041 _bfd_vms_push (abfd, (uquad) *ptr++, -1); 1042 break; 1043 1044 case TIR_S_C_STA_SW: 1045 /* stack signed short word 1046 arg: sh value 1047 1048 stack 16 bit value, sign extend to 32 bit. */ 1049 _bfd_vms_push (abfd, (uquad) bfd_getl16 (ptr), -1); 1050 ptr += 2; 1051 break; 1052 1053 case TIR_S_C_STA_LW: 1054 /* stack signed longword 1055 arg: lw value 1056 1057 stack 32 bit value. */ 1058 _bfd_vms_push (abfd, (uquad) bfd_getl32 (ptr), -1); 1059 ptr += 4; 1060 break; 1061 1062 case TIR_S_C_STA_PB: 1063 case TIR_S_C_STA_WPB: 1064 /* stack psect base plus byte offset (word index) 1065 arg: by section index 1066 (sh section index) 1067 by signed byte offset. */ 1068 { 1069 unsigned long dummy; 1070 unsigned int psect; 1071 1072 if (cmd == TIR_S_C_STA_PB) 1073 psect = *ptr++; 1074 else 1075 { 1076 psect = bfd_getl16 (ptr); 1077 ptr += 2; 1078 } 1079 1080 if (psect >= PRIV (section_count)) 1081 alloc_section (abfd, psect); 1082 1083 dummy = (long) *ptr++; 1084 dummy += (PRIV (sections)[psect])->vma; 1085 _bfd_vms_push (abfd, (uquad) dummy, (int) psect); 1086 } 1087 break; 1088 1089 case TIR_S_C_STA_PW: 1090 case TIR_S_C_STA_WPW: 1091 /* stack psect base plus word offset (word index) 1092 arg: by section index 1093 (sh section index) 1094 sh signed short offset. */ 1095 { 1096 unsigned long dummy; 1097 unsigned int psect; 1098 1099 if (cmd == TIR_S_C_STA_PW) 1100 psect = *ptr++; 1101 else 1102 { 1103 psect = bfd_getl16 (ptr); 1104 ptr += 2; 1105 } 1106 1107 if (psect >= PRIV (section_count)) 1108 alloc_section (abfd, psect); 1109 1110 dummy = bfd_getl16 (ptr); ptr+=2; 1111 dummy += (PRIV (sections)[psect])->vma; 1112 _bfd_vms_push (abfd, (uquad) dummy, (int) psect); 1113 } 1114 break; 1115 1116 case TIR_S_C_STA_PL: 1117 case TIR_S_C_STA_WPL: 1118 /* stack psect base plus long offset (word index) 1119 arg: by section index 1120 (sh section index) 1121 lw signed longword offset. */ 1122 { 1123 unsigned long dummy; 1124 unsigned int psect; 1125 1126 if (cmd == TIR_S_C_STA_PL) 1127 psect = *ptr++; 1128 else 1129 { 1130 psect = bfd_getl16 (ptr); 1131 ptr += 2; 1132 } 1133 1134 if (psect >= PRIV (section_count)) 1135 alloc_section (abfd, psect); 1136 1137 dummy = bfd_getl32 (ptr); ptr += 4; 1138 dummy += (PRIV (sections)[psect])->vma; 1139 _bfd_vms_push (abfd, (uquad) dummy, (int) psect); 1140 } 1141 break; 1142 1143 case TIR_S_C_STA_UB: 1144 /* stack unsigned byte 1145 arg: by value 1146 1147 stack byte value. */ 1148 _bfd_vms_push (abfd, (uquad) *ptr++, -1); 1149 break; 1150 1151 case TIR_S_C_STA_UW: 1152 /* stack unsigned short word 1153 arg: sh value 1154 1155 stack 16 bit value. */ 1156 _bfd_vms_push (abfd, (uquad) bfd_getl16 (ptr), -1); 1157 ptr += 2; 1158 break; 1159 1160 case TIR_S_C_STA_BFI: 1161 /* stack byte from image 1162 arg: none. */ 1163 /* FALLTHRU */ 1164 case TIR_S_C_STA_WFI: 1165 /* stack byte from image 1166 arg: none. */ 1167 /* FALLTHRU */ 1168 case TIR_S_C_STA_LFI: 1169 /* stack byte from image 1170 arg: none. */ 1171 (*_bfd_error_handler) (_("stack-from-image not implemented")); 1172 return NULL; 1173 1174 case TIR_S_C_STA_EPM: 1175 /* stack entry point mask 1176 arg: cs symbol name 1177 1178 stack (unsigned) entry point mask of symbol 1179 err if symbol is no entry point. */ 1180 { 1181 char *name; 1182 vms_symbol_entry *entry; 1183 1184 name = _bfd_vms_save_counted_string (ptr); 1185 entry = _bfd_vms_enter_symbol (abfd, name); 1186 if (entry == (vms_symbol_entry *) NULL) 1187 return 0; 1188 1189 (*_bfd_error_handler) (_("stack-entry-mask not fully implemented")); 1190 _bfd_vms_push (abfd, (uquad) 0, -1); 1191 ptr += *ptr + 1; 1192 } 1193 break; 1194 1195 case TIR_S_C_STA_CKARG: 1196 /* compare procedure argument 1197 arg: cs symbol name 1198 by argument index 1199 da argument descriptor 1200 1201 compare argument descriptor with symbol argument (ARG$V_PASSMECH) 1202 and stack TRUE (args match) or FALSE (args dont match) value. */ 1203 (*_bfd_error_handler) (_("PASSMECH not fully implemented")); 1204 _bfd_vms_push (abfd, (uquad) 1, -1); 1205 break; 1206 1207 case TIR_S_C_STA_LSY: 1208 /* stack local symbol value 1209 arg: sh environment index 1210 cs symbol name. */ 1211 { 1212 int envidx; 1213 char *name; 1214 vms_symbol_entry *entry; 1215 1216 envidx = bfd_getl16 (ptr); 1024 1217 ptr += 2; 1025 break; 1026 1027 case TIR_S_C_STA_LW: 1028 /* 1029 * stack signed longword 1030 * arg: lw value 1031 * 1032 * stack 32 bit value 1033 */ 1034 _bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1); 1035 ptr += 4; 1036 break; 1037 1038 case TIR_S_C_STA_PB: 1039 case TIR_S_C_STA_WPB: 1040 /* 1041 * stack psect base plus byte offset (word index) 1042 * arg: by section index 1043 * (sh section index) 1044 * by signed byte offset 1045 * 1046 */ 1047 { 1048 unsigned long dummy; 1049 unsigned int psect; 1050 1051 if (cmd == TIR_S_C_STA_PB) 1052 psect = *ptr++; 1053 else 1054 { 1055 psect = bfd_getl16(ptr); 1056 ptr += 2; 1057 } 1058 1059 if (psect >= PRIV(section_count)) 1060 { 1061 alloc_section (abfd, psect); 1062 } 1063 1064 dummy = (long)*ptr++; 1065 dummy += (PRIV(sections)[psect])->vma; 1066 _bfd_vms_push (abfd, dummy, psect); 1067 } 1068 break; 1069 1070 case TIR_S_C_STA_PW: 1071 case TIR_S_C_STA_WPW: 1072 /* 1073 * stack psect base plus word offset (word index) 1074 * arg: by section index 1075 * (sh section index) 1076 * sh signed short offset 1077 * 1078 */ 1079 { 1080 unsigned long dummy; 1081 unsigned int psect; 1082 1083 if (cmd == TIR_S_C_STA_PW) 1084 psect = *ptr++; 1085 else 1086 { 1087 psect = bfd_getl16(ptr); 1088 ptr += 2; 1089 } 1090 1091 if (psect >= PRIV(section_count)) 1092 { 1093 alloc_section (abfd, psect); 1094 } 1095 1096 dummy = bfd_getl16(ptr); ptr+=2; 1097 dummy += (PRIV(sections)[psect])->vma; 1098 _bfd_vms_push (abfd, dummy, psect); 1099 } 1100 break; 1101 1102 case TIR_S_C_STA_PL: 1103 case TIR_S_C_STA_WPL: 1104 /* 1105 * stack psect base plus long offset (word index) 1106 * arg: by section index 1107 * (sh section index) 1108 * lw signed longword offset 1109 * 1110 */ 1111 { 1112 unsigned long dummy; 1113 unsigned int psect; 1114 1115 if (cmd == TIR_S_C_STA_PL) 1116 psect = *ptr++; 1117 else 1118 { 1119 psect = bfd_getl16(ptr); 1120 ptr += 2; 1121 } 1122 1123 if (psect >= PRIV(section_count)) 1124 { 1125 alloc_section (abfd, psect); 1126 } 1127 1128 dummy = bfd_getl32 (ptr); ptr += 4; 1129 dummy += (PRIV(sections)[psect])->vma; 1130 _bfd_vms_push (abfd, dummy, psect); 1131 } 1132 break; 1133 1134 case TIR_S_C_STA_UB: 1135 /* 1136 * stack unsigned byte 1137 * arg: by value 1138 * 1139 * stack byte value 1140 */ 1141 _bfd_vms_push (abfd, (unsigned long)*ptr++, -1); 1142 break; 1143 1144 case TIR_S_C_STA_UW: 1145 /* 1146 * stack unsigned short word 1147 * arg: sh value 1148 * 1149 * stack 16 bit value 1150 */ 1151 _bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1); 1218 name = _bfd_vms_save_counted_string (ptr); 1219 entry = _bfd_vms_enter_symbol (abfd, name); 1220 if (entry == (vms_symbol_entry *) NULL) 1221 return 0; 1222 (*_bfd_error_handler) (_("stack-local-symbol not fully implemented")); 1223 _bfd_vms_push (abfd, (uquad) 0, -1); 1224 ptr += *ptr + 1; 1225 } 1226 break; 1227 1228 case TIR_S_C_STA_LIT: 1229 /* stack literal 1230 arg: by literal index 1231 1232 stack literal. */ 1233 ptr++; 1234 _bfd_vms_push (abfd, (uquad) 0, -1); 1235 (*_bfd_error_handler) (_("stack-literal not fully implemented")); 1236 break; 1237 1238 case TIR_S_C_STA_LEPM: 1239 /* stack local symbol entry point mask 1240 arg: sh environment index 1241 cs symbol name 1242 1243 stack (unsigned) entry point mask of symbol 1244 err if symbol is no entry point. */ 1245 { 1246 int envidx; 1247 char *name; 1248 vms_symbol_entry *entry; 1249 1250 envidx = bfd_getl16 (ptr); 1152 1251 ptr += 2; 1153 break; 1154 1155 case TIR_S_C_STA_BFI: 1156 /* 1157 * stack byte from image 1158 * arg: - 1159 * 1160 */ 1161 /*FALLTHRU*/ 1162 case TIR_S_C_STA_WFI: 1163 /* 1164 * stack byte from image 1165 * arg: - 1166 * 1167 */ 1168 /*FALLTHRU*/ 1169 case TIR_S_C_STA_LFI: 1170 /* 1171 * stack byte from image 1172 * arg: - 1173 * 1174 */ 1175 (*_bfd_error_handler) (_("Stack-from-image not implemented")); 1176 return NULL; 1177 1178 case TIR_S_C_STA_EPM: 1179 /* 1180 * stack entry point mask 1181 * arg: cs symbol name 1182 * 1183 * stack (unsigned) entry point mask of symbol 1184 * err if symbol is no entry point 1185 */ 1186 { 1187 char *name; 1188 vms_symbol_entry *entry; 1189 1190 name = _bfd_vms_save_counted_string (ptr); 1191 entry = _bfd_vms_enter_symbol (abfd, name); 1192 if (entry == (vms_symbol_entry *)NULL) 1193 return 0; 1194 1195 (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented")); 1196 _bfd_vms_push (abfd, 0L, -1); 1197 ptr += *ptr + 1; 1198 } 1199 break; 1200 1201 case TIR_S_C_STA_CKARG: 1202 /* 1203 * compare procedure argument 1204 * arg: cs symbol name 1205 * by argument index 1206 * da argument descriptor 1207 * 1208 * compare argument descriptor with symbol argument (ARG$V_PASSMECH) 1209 * and stack TRUE (args match) or FALSE (args dont match) value 1210 */ 1211 (*_bfd_error_handler) (_("PASSMECH not fully implemented")); 1212 _bfd_vms_push (abfd, 1L, -1); 1213 break; 1214 1215 case TIR_S_C_STA_LSY: 1216 /* 1217 * stack local symbol value 1218 * arg: sh environment index 1219 * cs symbol name 1220 */ 1221 { 1222 int envidx; 1223 char *name; 1224 vms_symbol_entry *entry; 1225 1226 envidx = bfd_getl16(ptr); ptr += 2; 1227 name = _bfd_vms_save_counted_string (ptr); 1228 entry = _bfd_vms_enter_symbol (abfd, name); 1229 if (entry == (vms_symbol_entry *)NULL) 1230 return 0; 1231 (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented")); 1232 _bfd_vms_push (abfd, 0L, -1); 1233 ptr += *ptr + 1; 1234 } 1235 break; 1236 1237 case TIR_S_C_STA_LIT: 1238 /* 1239 * stack literal 1240 * arg: by literal index 1241 * 1242 * stack literal 1243 */ 1244 ptr++; 1245 _bfd_vms_push (abfd, 0L, -1); 1246 (*_bfd_error_handler) (_("Stack-literal not fully implemented")); 1247 break; 1248 1249 case TIR_S_C_STA_LEPM: 1250 /* 1251 * stack local symbol entry point mask 1252 * arg: sh environment index 1253 * cs symbol name 1254 * 1255 * stack (unsigned) entry point mask of symbol 1256 * err if symbol is no entry point 1257 */ 1258 { 1259 int envidx; 1260 char *name; 1261 vms_symbol_entry *entry; 1262 1263 envidx = bfd_getl16(ptr); ptr += 2; 1264 name = _bfd_vms_save_counted_string (ptr); 1265 entry = _bfd_vms_enter_symbol (abfd, name); 1266 if (entry == (vms_symbol_entry *)NULL) 1267 return 0; 1268 (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented")); 1269 _bfd_vms_push (abfd, 0L, -1); 1270 ptr += *ptr + 1; 1271 } 1272 break; 1273 1274 default: 1275 (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]); 1276 return NULL; 1277 break; 1278 } 1252 name = _bfd_vms_save_counted_string (ptr); 1253 entry = _bfd_vms_enter_symbol (abfd, name); 1254 if (entry == (vms_symbol_entry *) NULL) 1255 return 0; 1256 (*_bfd_error_handler) (_("stack-local-symbol-entry-point-mask not fully implemented")); 1257 _bfd_vms_push (abfd, (uquad) 0, -1); 1258 ptr += *ptr + 1; 1259 } 1260 break; 1261 1262 default: 1263 (*_bfd_error_handler) (_("reserved STA cmd %d"), ptr[-1]); 1264 return NULL; 1265 break; 1266 } 1279 1267 1280 1268 return ptr; 1281 1269 } 1282 1270 1283 /* 1284 * tir_sto 1285 * 1286 * vax store commands 1287 * 1288 * handle sto_xxx commands in tir section 1289 * ptr points to data area in record 1290 * 1291 * see table 7-4 of the VAX/VMS linker manual 1292 */ 1271 static const char * 1272 tir_cmd_name (cmd) 1273 int cmd; 1274 { 1275 switch (cmd) 1276 { 1277 case TIR_S_C_STO_RSB: return "TIR_S_C_STO_RSB"; 1278 case TIR_S_C_STO_RSW: return "TIR_S_C_STO_RSW"; 1279 case TIR_S_C_STO_RL: return "TIR_S_C_STO_RL"; 1280 case TIR_S_C_STO_VPS: return "TIR_S_C_STO_VPS"; 1281 case TIR_S_C_STO_USB: return "TIR_S_C_STO_USB"; 1282 case TIR_S_C_STO_USW: return "TIR_S_C_STO_USW"; 1283 case TIR_S_C_STO_RUB: return "TIR_S_C_STO_RUB"; 1284 case TIR_S_C_STO_RUW: return "TIR_S_C_STO_RUW"; 1285 case TIR_S_C_STO_PIRR: return "TIR_S_C_STO_PIRR"; 1286 case TIR_S_C_OPR_INSV: return "TIR_S_C_OPR_INSV"; 1287 case TIR_S_C_OPR_DFLIT: return "TIR_S_C_OPR_DFLIT"; 1288 case TIR_S_C_OPR_REDEF: return "TIR_S_C_OPR_REDEF"; 1289 case TIR_S_C_OPR_ROT: return "TIR_S_C_OPR_ROT"; 1290 case TIR_S_C_OPR_USH: return "TIR_S_C_OPR_USH"; 1291 case TIR_S_C_OPR_ASH: return "TIR_S_C_OPR_ASH"; 1292 case TIR_S_C_CTL_DFLOC: return "TIR_S_C_CTL_DFLOC"; 1293 case TIR_S_C_CTL_STLOC: return "TIR_S_C_CTL_STLOC"; 1294 case TIR_S_C_CTL_STKDL: return "TIR_S_C_CTL_STKDL"; 1295 1296 default: 1297 /* These strings have not been added yet. */ 1298 abort (); 1299 } 1300 } 1301 1302 /* tir_sto 1303 1304 vax store commands 1305 1306 handle sto_xxx commands in tir section 1307 ptr points to data area in record 1308 1309 See table 7-4 of the VAX/VMS linker manual. */ 1293 1310 1294 1311 static unsigned char * … … 1305 1322 switch (*ptr++) 1306 1323 { 1307 case TIR_S_C_STO_SB: 1308 /* 1309 * store signed byte: pop stack, write byte 1310 * arg: - 1311 */ 1312 dummy = _bfd_vms_pop (abfd, &psect); 1313 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */ 1314 break; 1315 1316 case TIR_S_C_STO_SW: 1317 /* 1318 * store signed word: pop stack, write word 1319 * arg: - 1320 */ 1321 dummy = _bfd_vms_pop (abfd, &psect); 1322 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */ 1323 break; 1324 1325 case TIR_S_C_STO_LW: 1326 /* 1327 * store longword: pop stack, write longword 1328 * arg: - 1329 */ 1330 dummy = _bfd_vms_pop (abfd, &psect); 1331 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */ 1332 break; 1333 1334 case TIR_S_C_STO_BD: 1335 /* 1336 * store byte displaced: pop stack, sub lc+1, write byte 1337 * arg: - 1338 */ 1339 dummy = _bfd_vms_pop (abfd, &psect); 1340 dummy -= ((PRIV(sections)[psect])->vma + 1); 1341 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */ 1342 break; 1343 1344 case TIR_S_C_STO_WD: 1345 /* 1346 * store word displaced: pop stack, sub lc+2, write word 1347 * arg: - 1348 */ 1349 dummy = _bfd_vms_pop (abfd, &psect); 1350 dummy -= ((PRIV(sections)[psect])->vma + 2); 1351 image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */ 1352 break; 1353 case TIR_S_C_STO_LD: 1354 /* 1355 * store long displaced: pop stack, sub lc+4, write long 1356 * arg: - 1357 */ 1358 dummy = _bfd_vms_pop (abfd, &psect); 1359 dummy -= ((PRIV(sections)[psect])->vma + 4); 1360 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */ 1361 break; 1362 case TIR_S_C_STO_LI: 1363 /* 1364 * store short literal: pop stack, write byte 1365 * arg: - 1366 */ 1367 dummy = _bfd_vms_pop (abfd, &psect); 1368 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */ 1369 break; 1370 case TIR_S_C_STO_PIDR: 1371 /* 1372 * store position independent data reference: pop stack, write longword 1373 * arg: - 1374 * FIXME: incomplete ! 1375 */ 1376 dummy = _bfd_vms_pop (abfd, &psect); 1377 image_write_l (abfd, dummy & 0xffffffff); 1378 break; 1379 case TIR_S_C_STO_PICR: 1380 /* 1381 * store position independent code reference: pop stack, write longword 1382 * arg: - 1383 * FIXME: incomplete ! 1384 */ 1385 dummy = _bfd_vms_pop (abfd, &psect); 1386 image_write_b (abfd, 0x9f); 1387 image_write_l (abfd, dummy & 0xffffffff); 1388 break; 1389 case TIR_S_C_STO_RIVB: 1390 /* 1391 * store repeated immediate variable bytes 1392 * 1-byte count n field followed by n bytes of data 1393 * pop stack, write n bytes <stack> times 1394 */ 1395 size = *ptr++; 1396 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL); 1397 while (dummy-- > 0L) 1398 image_dump (abfd, ptr, size, 0); 1399 ptr += size; 1400 break; 1401 case TIR_S_C_STO_B: 1402 /* 1403 * store byte from top longword 1404 */ 1405 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL); 1324 case TIR_S_C_STO_SB: 1325 /* store signed byte: pop stack, write byte 1326 arg: none. */ 1327 dummy = _bfd_vms_pop (abfd, &psect); 1328 image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */ 1329 break; 1330 1331 case TIR_S_C_STO_SW: 1332 /* store signed word: pop stack, write word 1333 arg: none. */ 1334 dummy = _bfd_vms_pop (abfd, &psect); 1335 image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */ 1336 break; 1337 1338 case TIR_S_C_STO_LW: 1339 /* store longword: pop stack, write longword 1340 arg: none. */ 1341 dummy = _bfd_vms_pop (abfd, &psect); 1342 image_write_l (abfd, dummy & 0xffffffff); /* FIXME: check top bits */ 1343 break; 1344 1345 case TIR_S_C_STO_BD: 1346 /* store byte displaced: pop stack, sub lc+1, write byte 1347 arg: none. */ 1348 dummy = _bfd_vms_pop (abfd, &psect); 1349 dummy -= ((PRIV (sections)[psect])->vma + 1); 1350 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */ 1351 break; 1352 1353 case TIR_S_C_STO_WD: 1354 /* store word displaced: pop stack, sub lc+2, write word 1355 arg: none. */ 1356 dummy = _bfd_vms_pop (abfd, &psect); 1357 dummy -= ((PRIV (sections)[psect])->vma + 2); 1358 image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */ 1359 break; 1360 1361 case TIR_S_C_STO_LD: 1362 /* store long displaced: pop stack, sub lc+4, write long 1363 arg: none. */ 1364 dummy = _bfd_vms_pop (abfd, &psect); 1365 dummy -= ((PRIV (sections)[psect])->vma + 4); 1366 image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */ 1367 break; 1368 1369 case TIR_S_C_STO_LI: 1370 /* store short literal: pop stack, write byte 1371 arg: none. */ 1372 dummy = _bfd_vms_pop (abfd, &psect); 1373 image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */ 1374 break; 1375 1376 case TIR_S_C_STO_PIDR: 1377 /* store position independent data reference: pop stack, write longword 1378 arg: none. 1379 FIXME: incomplete ! */ 1380 dummy = _bfd_vms_pop (abfd, &psect); 1381 image_write_l (abfd, dummy & 0xffffffff); 1382 break; 1383 1384 case TIR_S_C_STO_PICR: 1385 /* store position independent code reference: pop stack, write longword 1386 arg: none. 1387 FIXME: incomplete ! */ 1388 dummy = _bfd_vms_pop (abfd, &psect); 1389 image_write_b (abfd, 0x9f); 1390 image_write_l (abfd, dummy & 0xffffffff); 1391 break; 1392 1393 case TIR_S_C_STO_RIVB: 1394 /* store repeated immediate variable bytes 1395 1-byte count n field followed by n bytes of data 1396 pop stack, write n bytes <stack> times. */ 1397 size = *ptr++; 1398 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 1399 while (dummy-- > 0L) 1400 image_dump (abfd, ptr, size, 0); 1401 ptr += size; 1402 break; 1403 1404 case TIR_S_C_STO_B: 1405 /* store byte from top longword. */ 1406 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 1407 image_write_b (abfd, dummy & 0xff); 1408 break; 1409 1410 case TIR_S_C_STO_W: 1411 /* store word from top longword. */ 1412 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 1413 image_write_w (abfd, dummy & 0xffff); 1414 break; 1415 1416 case TIR_S_C_STO_RB: 1417 /* store repeated byte from top longword. */ 1418 size = (unsigned long) _bfd_vms_pop (abfd, NULL); 1419 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 1420 while (size-- > 0) 1406 1421 image_write_b (abfd, dummy & 0xff); 1407 break; 1408 case TIR_S_C_STO_W: 1409 /* 1410 * store word from top longword 1411 */ 1412 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL); 1422 break; 1423 1424 case TIR_S_C_STO_RW: 1425 /* store repeated word from top longword. */ 1426 size = (unsigned long) _bfd_vms_pop (abfd, NULL); 1427 dummy = (unsigned long) _bfd_vms_pop (abfd, NULL); 1428 while (size-- > 0) 1413 1429 image_write_w (abfd, dummy & 0xffff); 1414 break; 1415 case TIR_S_C_STO_RB: 1416 /* 1417 * store repeated byte from top longword 1418 */ 1419 size = (unsigned long)_bfd_vms_pop (abfd, NULL); 1420 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL); 1421 while (size-- > 0) 1422 image_write_b (abfd, dummy & 0xff); 1423 break; 1424 case TIR_S_C_STO_RW: 1425 /* 1426 * store repeated word from top longword 1427 */ 1428 size = (unsigned long)_bfd_vms_pop (abfd, NULL); 1429 dummy = (unsigned long)_bfd_vms_pop (abfd, NULL); 1430 while (size-- > 0) 1431 image_write_w (abfd, dummy & 0xffff); 1432 break; 1433 1434 case TIR_S_C_STO_RSB: 1435 case TIR_S_C_STO_RSW: 1436 case TIR_S_C_STO_RL: 1437 case TIR_S_C_STO_VPS: 1438 case TIR_S_C_STO_USB: 1439 case TIR_S_C_STO_USW: 1440 case TIR_S_C_STO_RUB: 1441 case TIR_S_C_STO_RUW: 1442 case TIR_S_C_STO_PIRR: 1443 (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]); 1444 break; 1445 1446 default: 1447 (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]); 1448 break; 1449 } 1430 break; 1431 1432 case TIR_S_C_STO_RSB: 1433 case TIR_S_C_STO_RSW: 1434 case TIR_S_C_STO_RL: 1435 case TIR_S_C_STO_VPS: 1436 case TIR_S_C_STO_USB: 1437 case TIR_S_C_STO_USW: 1438 case TIR_S_C_STO_RUB: 1439 case TIR_S_C_STO_RUW: 1440 case TIR_S_C_STO_PIRR: 1441 (*_bfd_error_handler) (_("%s: not implemented"), tir_cmd_name (ptr[-1])); 1442 break; 1443 1444 default: 1445 (*_bfd_error_handler) (_("reserved STO cmd %d"), ptr[-1]); 1446 break; 1447 } 1450 1448 1451 1449 return ptr; 1452 1450 } 1453 1451 1454 /* 1455 * stack operator commands 1456 * all 32 bit signed arithmetic 1457 * all word just like a stack calculator 1458 * arguments are popped from stack, results are pushed on stack 1459 * 1460 * see table 7-5 of the VAX/VMS linker manual 1461 */ 1452 /* stack operator commands 1453 all 32 bit signed arithmetic 1454 all word just like a stack calculator 1455 arguments are popped from stack, results are pushed on stack 1456 1457 See table 7-5 of the VAX/VMS linker manual. */ 1462 1458 1463 1459 static unsigned char * 1464 tir_opr (bfd *abfd, unsigned char *ptr) 1460 tir_opr (abfd, ptr) 1461 bfd *abfd; 1462 unsigned char *ptr; 1465 1463 { 1466 1464 long op1, op2; … … 1472 1470 switch (*ptr++) 1473 1471 { 1474 /* operation */ 1475 case TIR_S_C_OPR_NOP: 1476 /* 1477 * no-op 1478 */ 1479 break; 1480 1481 case TIR_S_C_OPR_ADD: 1482 /* 1483 * add 1484 */ 1485 op1 = (long)_bfd_vms_pop (abfd, NULL); 1486 op2 = (long)_bfd_vms_pop (abfd, NULL); 1487 _bfd_vms_push (abfd, (unsigned long) (op1 + op2), -1); 1488 break; 1489 1490 case TIR_S_C_OPR_SUB: 1491 /* 1492 * subtract 1493 */ 1494 op1 = (long)_bfd_vms_pop (abfd, NULL); 1495 op2 = (long)_bfd_vms_pop (abfd, NULL); 1496 _bfd_vms_push (abfd, (unsigned long) (op2 - op1), -1); 1497 break; 1498 1499 case TIR_S_C_OPR_MUL: 1500 /* 1501 * multiply 1502 */ 1503 op1 = (long)_bfd_vms_pop (abfd, NULL); 1504 op2 = (long)_bfd_vms_pop (abfd, NULL); 1505 _bfd_vms_push (abfd, (unsigned long) (op1 * op2), -1); 1506 break; 1507 1508 case TIR_S_C_OPR_DIV: 1509 /* 1510 * divide 1511 */ 1512 op1 = (long)_bfd_vms_pop (abfd, NULL); 1513 op2 = (long)_bfd_vms_pop (abfd, NULL); 1514 if (op2 == 0) 1515 _bfd_vms_push (abfd, (unsigned long)0L, -1); 1516 else 1517 _bfd_vms_push (abfd, (unsigned long) (op2 / op1), -1); 1518 break; 1519 1520 case TIR_S_C_OPR_AND: 1521 /* 1522 * logical and 1523 */ 1524 op1 = (long)_bfd_vms_pop (abfd, NULL); 1525 op2 = (long)_bfd_vms_pop (abfd, NULL); 1526 _bfd_vms_push (abfd, (unsigned long) (op1 & op2), -1); 1527 break; 1528 1529 case TIR_S_C_OPR_IOR: 1530 op1 = (long)_bfd_vms_pop (abfd, NULL); 1531 /* 1532 * logical inclusive or 1533 */ 1534 op2 = (long)_bfd_vms_pop (abfd, NULL); 1535 _bfd_vms_push (abfd, (unsigned long) (op1 | op2), -1); 1536 break; 1537 1538 case TIR_S_C_OPR_EOR: 1539 /* 1540 * logical exclusive or 1541 */ 1542 op1 = (long)_bfd_vms_pop (abfd, NULL); 1543 op2 = (long)_bfd_vms_pop (abfd, NULL); 1544 _bfd_vms_push (abfd, (unsigned long) (op1 ^ op2), -1); 1545 break; 1546 1547 case TIR_S_C_OPR_NEG: 1548 /* 1549 * negate 1550 */ 1551 op1 = (long)_bfd_vms_pop (abfd, NULL); 1552 _bfd_vms_push (abfd, (unsigned long) (-op1), -1); 1553 break; 1554 1555 case TIR_S_C_OPR_COM: 1556 /* 1557 * complement 1558 */ 1559 op1 = (long)_bfd_vms_pop (abfd, NULL); 1560 _bfd_vms_push (abfd, (unsigned long) (op1 ^ -1L), -1); 1561 break; 1562 1563 case TIR_S_C_OPR_INSV: 1564 /* 1565 * insert field 1566 */ 1567 (void)_bfd_vms_pop (abfd, NULL); 1568 (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete"); 1569 break; 1570 1571 case TIR_S_C_OPR_ASH: 1572 /* 1573 * arithmetic shift 1574 */ 1575 op1 = (long)_bfd_vms_pop (abfd, NULL); 1576 op2 = (long)_bfd_vms_pop (abfd, NULL); 1577 if (HIGHBIT(op1)) /* shift right */ 1578 op2 >>= op1; 1579 else /* shift left */ 1580 op2 <<= op1; 1581 _bfd_vms_push (abfd, (unsigned long)op2, -1); 1582 (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete")); 1583 break; 1584 1585 case TIR_S_C_OPR_USH: 1586 /* 1587 * unsigned shift 1588 */ 1589 op1 = (long)_bfd_vms_pop (abfd, NULL); 1590 op2 = (long)_bfd_vms_pop (abfd, NULL); 1591 if (HIGHBIT(op1)) /* shift right */ 1592 op2 >>= op1; 1593 else /* shift left */ 1594 op2 <<= op1; 1595 _bfd_vms_push (abfd, (unsigned long)op2, -1); 1596 (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete")); 1597 break; 1598 1599 case TIR_S_C_OPR_ROT: 1600 /* 1601 * rotate 1602 */ 1603 op1 = (long)_bfd_vms_pop (abfd, NULL); 1604 op2 = (long)_bfd_vms_pop (abfd, NULL); 1605 if (HIGHBIT(0)) /* shift right */ 1606 op2 >>= op1; 1607 else /* shift left */ 1608 op2 <<= op1; 1609 _bfd_vms_push (abfd, (unsigned long)op2, -1); 1610 (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete")); 1611 break; 1612 1613 case TIR_S_C_OPR_SEL: 1614 /* 1615 * select 1616 */ 1617 if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L) 1618 (void)_bfd_vms_pop (abfd, NULL); 1619 else 1620 { 1621 op1 = (long)_bfd_vms_pop (abfd, NULL); 1622 (void)_bfd_vms_pop (abfd, NULL); 1623 _bfd_vms_push (abfd, (unsigned long)op1, -1); 1624 } 1625 break; 1626 1627 case TIR_S_C_OPR_REDEF: 1628 /* 1629 * redefine symbol to current location 1630 */ 1631 (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported")); 1632 break; 1633 1634 case TIR_S_C_OPR_DFLIT: 1635 /* 1636 * define a literal 1637 */ 1638 (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported")); 1639 break; 1640 1641 default: 1642 (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]); 1472 /* operation */ 1473 case TIR_S_C_OPR_NOP: /* no-op */ 1474 break; 1475 1476 case TIR_S_C_OPR_ADD: /* add */ 1477 op1 = (long) _bfd_vms_pop (abfd, NULL); 1478 op2 = (long) _bfd_vms_pop (abfd, NULL); 1479 _bfd_vms_push (abfd, (uquad) (op1 + op2), -1); 1480 break; 1481 1482 case TIR_S_C_OPR_SUB: /* subtract */ 1483 op1 = (long) _bfd_vms_pop (abfd, NULL); 1484 op2 = (long) _bfd_vms_pop (abfd, NULL); 1485 _bfd_vms_push (abfd, (uquad) (op2 - op1), -1); 1486 break; 1487 1488 case TIR_S_C_OPR_MUL: /* multiply */ 1489 op1 = (long) _bfd_vms_pop (abfd, NULL); 1490 op2 = (long) _bfd_vms_pop (abfd, NULL); 1491 _bfd_vms_push (abfd, (uquad) (op1 * op2), -1); 1492 break; 1493 1494 case TIR_S_C_OPR_DIV: /* divide */ 1495 op1 = (long) _bfd_vms_pop (abfd, NULL); 1496 op2 = (long) _bfd_vms_pop (abfd, NULL); 1497 if (op2 == 0) 1498 _bfd_vms_push (abfd, (uquad) 0, -1); 1499 else 1500 _bfd_vms_push (abfd, (uquad) (op2 / op1), -1); 1501 break; 1502 1503 case TIR_S_C_OPR_AND: /* logical and */ 1504 op1 = (long) _bfd_vms_pop (abfd, NULL); 1505 op2 = (long) _bfd_vms_pop (abfd, NULL); 1506 _bfd_vms_push (abfd, (uquad) (op1 & op2), -1); 1507 break; 1508 1509 case TIR_S_C_OPR_IOR: /* logical inclusive or */ 1510 op1 = (long) _bfd_vms_pop (abfd, NULL); 1511 op2 = (long) _bfd_vms_pop (abfd, NULL); 1512 _bfd_vms_push (abfd, (uquad) (op1 | op2), -1); 1513 break; 1514 1515 case TIR_S_C_OPR_EOR: /* logical exclusive or */ 1516 op1 = (long) _bfd_vms_pop (abfd, NULL); 1517 op2 = (long) _bfd_vms_pop (abfd, NULL); 1518 _bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1); 1519 break; 1520 1521 case TIR_S_C_OPR_NEG: /* negate */ 1522 op1 = (long) _bfd_vms_pop (abfd, NULL); 1523 _bfd_vms_push (abfd, (uquad) (-op1), -1); 1524 break; 1525 1526 case TIR_S_C_OPR_COM: /* complement */ 1527 op1 = (long) _bfd_vms_pop (abfd, NULL); 1528 _bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1); 1529 break; 1530 1531 case TIR_S_C_OPR_INSV: /* insert field */ 1532 (void) _bfd_vms_pop (abfd, NULL); 1533 (*_bfd_error_handler) (_("%s: not fully implemented"), 1534 tir_cmd_name (ptr[-1])); 1535 break; 1536 1537 case TIR_S_C_OPR_ASH: /* arithmetic shift */ 1538 op1 = (long) _bfd_vms_pop (abfd, NULL); 1539 op2 = (long) _bfd_vms_pop (abfd, NULL); 1540 if (HIGHBIT (op1)) /* shift right */ 1541 op2 >>= op1; 1542 else /* shift left */ 1543 op2 <<= op1; 1544 _bfd_vms_push (abfd, (uquad) op2, -1); 1545 (*_bfd_error_handler) (_("%s: not fully implemented"), 1546 tir_cmd_name (ptr[-1])); 1547 break; 1548 1549 case TIR_S_C_OPR_USH: /* unsigned shift */ 1550 op1 = (long) _bfd_vms_pop (abfd, NULL); 1551 op2 = (long) _bfd_vms_pop (abfd, NULL); 1552 if (HIGHBIT (op1)) /* shift right */ 1553 op2 >>= op1; 1554 else /* shift left */ 1555 op2 <<= op1; 1556 _bfd_vms_push (abfd, (uquad) op2, -1); 1557 (*_bfd_error_handler) (_("%s: not fully implemented"), 1558 tir_cmd_name (ptr[-1])); 1559 break; 1560 1561 case TIR_S_C_OPR_ROT: /* rotate */ 1562 op1 = (long) _bfd_vms_pop (abfd, NULL); 1563 op2 = (long) _bfd_vms_pop (abfd, NULL); 1564 if (HIGHBIT (0)) /* shift right */ 1565 op2 >>= op1; 1566 else /* shift left */ 1567 op2 <<= op1; 1568 _bfd_vms_push (abfd, (uquad) op2, -1); 1569 (*_bfd_error_handler) (_("%s: not fully implemented"), 1570 tir_cmd_name (ptr[-1])); 1571 break; 1572 1573 case TIR_S_C_OPR_SEL: /* select */ 1574 if ((long) _bfd_vms_pop (abfd, NULL) & 0x01L) 1575 (void) _bfd_vms_pop (abfd, NULL); 1576 else 1577 { 1578 op1 = (long) _bfd_vms_pop (abfd, NULL); 1579 (void) _bfd_vms_pop (abfd, NULL); 1580 _bfd_vms_push (abfd, (uquad) op1, -1); 1581 } 1582 break; 1583 1584 case TIR_S_C_OPR_REDEF: /* Redefine symbol to current location. */ 1585 case TIR_S_C_OPR_DFLIT: /* Define a literal. */ 1586 (*_bfd_error_handler) (_("%s: not supported"), 1587 tir_cmd_name (ptr[-1])); 1588 break; 1589 1590 default: 1591 (*_bfd_error_handler) (_("reserved OPR cmd %d"), ptr[-1]); 1643 1592 break; 1644 1593 } … … 1646 1595 return ptr; 1647 1596 } 1597 1598 /* control commands 1599 1600 See table 7-6 of the VAX/VMS linker manual. */ 1648 1601 1649 1602 static unsigned char * 1650 1603 tir_ctl (bfd *abfd, unsigned char *ptr) 1651 /*1652 * control commands1653 *1654 * see table 7-6 of the VAX/VMS linker manual1655 */1656 1604 { 1657 1605 unsigned long dummy; … … 1664 1612 switch (*ptr++) 1665 1613 { 1666 case TIR_S_C_CTL_SETRB: 1667 /* 1668 * set relocation base: pop stack, set image location counter 1669 * arg: - 1670 */ 1671 dummy = _bfd_vms_pop (abfd, &psect); 1672 if (psect >= PRIV(section_count)) 1673 { 1674 alloc_section (abfd, psect); 1675 } 1676 image_set_ptr (abfd, psect, dummy); 1677 break; 1678 case TIR_S_C_CTL_AUGRB: 1679 /* 1680 * augment relocation base: increment image location counter by offset 1681 * arg: lw offset value 1682 */ 1683 dummy = bfd_getl32 (ptr); 1684 image_inc_ptr (abfd, dummy); 1685 break; 1686 case TIR_S_C_CTL_DFLOC: 1687 /* 1688 * define location: pop index, save location counter under index 1689 * arg: - 1690 */ 1691 dummy = _bfd_vms_pop (abfd, NULL); 1692 (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented")); 1693 break; 1694 case TIR_S_C_CTL_STLOC: 1695 /* 1696 * set location: pop index, restore location counter from index 1697 * arg: - 1698 */ 1699 dummy = _bfd_vms_pop (abfd, &psect); 1700 (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented")); 1701 break; 1614 case TIR_S_C_CTL_SETRB: 1615 /* Set relocation base: pop stack, set image location counter 1616 arg: none. */ 1617 dummy = _bfd_vms_pop (abfd, &psect); 1618 if (psect >= PRIV (section_count)) 1619 alloc_section (abfd, psect); 1620 image_set_ptr (abfd, (int) psect, (uquad) dummy); 1621 break; 1622 1623 case TIR_S_C_CTL_AUGRB: 1624 /* Augment relocation base: increment image location counter by offset 1625 arg: lw offset value. */ 1626 dummy = bfd_getl32 (ptr); 1627 image_inc_ptr (abfd, (uquad) dummy); 1628 break; 1629 1630 case TIR_S_C_CTL_DFLOC: 1631 /* Define location: pop index, save location counter under index 1632 arg: none. */ 1633 dummy = _bfd_vms_pop (abfd, NULL); 1634 (*_bfd_error_handler) (_("%s: not fully implemented"), 1635 tir_cmd_name (ptr[-1])); 1636 break; 1637 1638 case TIR_S_C_CTL_STLOC: 1639 /* Set location: pop index, restore location counter from index 1640 arg: none. */ 1641 dummy = _bfd_vms_pop (abfd, &psect); 1642 (*_bfd_error_handler) (_("%s: not fully implemented"), 1643 tir_cmd_name (ptr[-1])); 1644 break; 1645 1702 1646 case TIR_S_C_CTL_STKDL: 1703 /* 1704 * stack defined location: pop index, push location counter from index1705 * arg: - 1706 */ 1707 dummy = _bfd_vms_pop (abfd, &psect);1708 (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));1709 break; 1647 /* Stack defined location: pop index, push location counter from index 1648 arg: none. */ 1649 dummy = _bfd_vms_pop (abfd, &psect); 1650 (*_bfd_error_handler) (_("%s: not fully implemented"), 1651 tir_cmd_name (ptr[-1])); 1652 break; 1653 1710 1654 default: 1711 (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);1712 1713 }1655 (*_bfd_error_handler) (_("reserved CTL cmd %d"), ptr[-1]); 1656 break; 1657 } 1714 1658 return ptr; 1715 1659 } 1716 1660 1717 /* 1718 * handle command from TIR section 1719 */ 1661 /* Handle command from TIR section. */ 1720 1662 1721 1663 static unsigned char * 1722 1664 tir_cmd (bfd *abfd, unsigned char *ptr) 1723 1665 { 1724 struct { 1666 struct 1667 { 1725 1668 int mincod; 1726 1669 int maxcod; 1727 1670 unsigned char * (*explain) (bfd *, unsigned char *); 1728 } tir_table[] = { 1729 { 0, TIR_S_C_MAXSTACOD, tir_sta } 1730 ,{ TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto } 1731 ,{ TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr } 1732 ,{ TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl } 1733 ,{ -1, -1, NULL } 1671 } 1672 tir_table[] = 1673 { 1674 { 0, TIR_S_C_MAXSTACOD, tir_sta }, 1675 { TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto }, 1676 { TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr }, 1677 { TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl }, 1678 { -1, -1, NULL } 1734 1679 }; 1735 1680 int i = 0; … … 1737 1682 #if VMS_DEBUG 1738 1683 _bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr, *ptr); 1739 _bfd_hexdump (8, ptr, 16, (int) ptr);1684 _bfd_hexdump (8, ptr, 16, (int) ptr); 1740 1685 #endif 1741 1686 … … 1751 1696 { 1752 1697 if ( (tir_table[i].mincod <= *ptr) 1753 && (*ptr <= tir_table[i].maxcod))1698 && (*ptr <= tir_table[i].maxcod)) 1754 1699 { 1755 1700 ptr = tir_table[i].explain (abfd, ptr); … … 1760 1705 if (tir_table[i].mincod < 0) 1761 1706 { 1762 (*_bfd_error_handler) (_(" Obj code %d not found"), *ptr);1707 (*_bfd_error_handler) (_("obj code %d not found"), *ptr); 1763 1708 ptr = 0; 1764 1709 } … … 1768 1713 } 1769 1714 1770 /* handle command from ETIR section*/1715 /* Handle command from ETIR section. */ 1771 1716 1772 1717 static int … … 1776 1721 unsigned char *ptr; 1777 1722 { 1778 static struct { 1723 static struct 1724 { 1779 1725 int mincod; 1780 1726 int maxcod; 1781 boolean (*explain) PARAMS((bfd *, int, unsigned char *)); 1782 } etir_table[] = { 1727 bfd_boolean (*explain) PARAMS ((bfd *, int, unsigned char *)); 1728 } 1729 etir_table[] = 1730 { 1783 1731 { ETIR_S_C_MINSTACOD, ETIR_S_C_MAXSTACOD, etir_sta }, 1784 1732 { ETIR_S_C_MINSTOCOD, ETIR_S_C_MAXSTOCOD, etir_sto }, … … 1793 1741 #if VMS_DEBUG 1794 1742 _bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd, cmd); 1795 _bfd_hexdump (8, ptr, 16, (int) ptr);1743 _bfd_hexdump (8, ptr, 16, (int) ptr); 1796 1744 #endif 1797 1745 … … 1799 1747 { 1800 1748 if ( (etir_table[i].mincod <= cmd) 1801 && (cmd <= etir_table[i].maxcod))1749 && (cmd <= etir_table[i].maxcod)) 1802 1750 { 1803 1751 if (!etir_table[i].explain (abfd, cmd, ptr)) … … 1815 1763 1816 1764 /* Text Information and Relocation Records (OBJ$C_TIR) 1817 handle tir record */1765 handle tir record. */ 1818 1766 1819 1767 static int … … 1842 1790 1843 1791 /* Text Information and Relocation Records (EOBJ$C_ETIR) 1844 handle etir record */1792 handle etir record. */ 1845 1793 1846 1794 static int … … 1877 1825 } 1878 1826 1879 /* process ETIR record 1880 1881 return 0 on success, -1 on error */ 1827 /* Process ETIR record 1828 Return 0 on success, -1 on error. */ 1882 1829 1883 1830 int … … 1894 1841 switch (objtype) 1895 1842 { 1896 1897 PRIV(vms_rec) += 4; /* skip type, size */1898 PRIV(rec_size) -= 4;1899 result = analyze_etir (abfd, PRIV(vms_rec), PRIV(rec_size));1900 1901 1902 PRIV(vms_rec) += 1; /* skip type */1903 PRIV(rec_size) -= 1;1904 result = analyze_tir (abfd, PRIV(vms_rec), PRIV(rec_size));1905 1906 1907 1908 1843 case EOBJ_S_C_ETIR: 1844 PRIV (vms_rec) += 4; /* skip type, size */ 1845 PRIV (rec_size) -= 4; 1846 result = analyze_etir (abfd, PRIV (vms_rec), (unsigned) PRIV (rec_size)); 1847 break; 1848 case OBJ_S_C_TIR: 1849 PRIV (vms_rec) += 1; /* skip type */ 1850 PRIV (rec_size) -= 1; 1851 result = analyze_tir (abfd, PRIV (vms_rec), (unsigned) PRIV (rec_size)); 1852 break; 1853 default: 1854 result = -1; 1855 break; 1909 1856 } 1910 1857 … … 1912 1859 } 1913 1860 1914 /* process EDBG record1915 return 0 on success, -1 on error1916 1917 not implemented yet*/1861 /* Process EDBG record 1862 Return 0 on success, -1 on error 1863 1864 Not implemented yet. */ 1918 1865 1919 1866 int … … 1930 1877 } 1931 1878 1932 /* process ETBT record1933 return 0 on success, -1 on error1934 1935 not implemented yet*/1879 /* Process ETBT record 1880 Return 0 on success, -1 on error 1881 1882 Not implemented yet. */ 1936 1883 1937 1884 int … … 1947 1894 } 1948 1895 1949 /* process LNK record1950 return 0 on success, -1 on error1951 1952 not implemented yet*/1896 /* Process LNK record 1897 Return 0 on success, -1 on error 1898 1899 Not implemented yet. */ 1953 1900 1954 1901 int … … 1965 1912 1966 1913 1967 /*----------------------------------------------------------------------*/ 1968 /* */ 1969 /* WRITE ETIR SECTION */ 1970 /* */ 1971 /* this is still under construction and therefore not documented */ 1972 /* */ 1973 /*----------------------------------------------------------------------*/ 1974 1975 static void start_etir_record PARAMS ((bfd *abfd, int index, uquad offset, boolean justoffset)); 1976 static void sto_imm PARAMS ((bfd *abfd, vms_section *sptr, bfd_vma vaddr, int index)); 1977 static void end_etir_record PARAMS ((bfd *abfd)); 1914 /* WRITE ETIR SECTION 1915 1916 This is still under construction and therefore not documented. */ 1917 1918 static void start_etir_record 1919 PARAMS ((bfd *abfd, int index, uquad offset, bfd_boolean justoffset)); 1920 static void sto_imm 1921 PARAMS ((bfd *abfd, vms_section *sptr, bfd_vma vaddr, int index)); 1922 static void end_etir_record 1923 PARAMS ((bfd *abfd)); 1978 1924 1979 1925 static void … … 1990 1936 #if VMS_DEBUG 1991 1937 _bfd_vms_debug (8, "sto_imm %d bytes\n", sptr->size); 1992 _bfd_hexdump (9, sptr->contents, (int) sptr->size, (int)vaddr);1938 _bfd_hexdump (9, sptr->contents, (int) sptr->size, (int) vaddr); 1993 1939 #endif 1994 1940 … … 1998 1944 while (ssize > 0) 1999 1945 { 2000 2001 1946 size = ssize; /* try all the rest */ 2002 1947 … … 2004 1949 { /* doesn't fit, split ! */ 2005 1950 end_etir_record (abfd); 2006 start_etir_record (abfd, index, vaddr, false);1951 start_etir_record (abfd, index, vaddr, FALSE); 2007 1952 size = _bfd_vms_output_check (abfd, 0); /* get max size */ 2008 1953 if (size > ssize) /* more than what's left ? */ … … 2017 1962 #if VMS_DEBUG 2018 1963 _bfd_vms_debug (10, "dumped %d bytes\n", size); 2019 _bfd_hexdump (10, cptr, (int) size, (int)vaddr);1964 _bfd_hexdump (10, cptr, (int) size, (int) vaddr); 2020 1965 #endif 2021 1966 … … 2024 1969 cptr += size; 2025 1970 } 2026 2027 return; 2028 } 2029 2030 /*-------------------------------------------------------------------*/ 2031 2032 /* start ETIR record for section #index at virtual addr offset. */ 1971 } 1972 1973 /* Start ETIR record for section #index at virtual addr offset. */ 2033 1974 2034 1975 static void … … 2037 1978 int index; 2038 1979 uquad offset; 2039 b oolean justoffset;1980 bfd_boolean justoffset; 2040 1981 { 2041 1982 if (!justoffset) … … 2046 1987 2047 1988 _bfd_vms_output_begin (abfd, ETIR_S_C_STA_PQ, -1); /* push start offset */ 2048 _bfd_vms_output_long (abfd, (unsigned long) index);2049 _bfd_vms_output_quad (abfd, (uquad) offset);1989 _bfd_vms_output_long (abfd, (unsigned long) index); 1990 _bfd_vms_output_quad (abfd, (uquad) offset); 2050 1991 _bfd_vms_output_flush (abfd); 2051 1992 2052 1993 _bfd_vms_output_begin (abfd, ETIR_S_C_CTL_SETRB, -1); /* start = pop () */ 2053 1994 _bfd_vms_output_flush (abfd); 2054 2055 return; 2056 } 2057 2058 /* end etir record */ 1995 } 1996 1997 /* End etir record. */ 1998 2059 1999 static void 2060 2000 end_etir_record (abfd) … … 2065 2005 } 2066 2006 2067 /* write section contents for bfd abfd*/2007 /* Write section contents for bfd abfd. */ 2068 2008 2069 2009 int … … 2083 2023 2084 2024 nextoffset = 0; 2085 PRIV (vms_linkage_index) = 1;2086 2087 /* dump all other sections*/2025 PRIV (vms_linkage_index) = 1; 2026 2027 /* Dump all other sections. */ 2088 2028 2089 2029 section = abfd->sections; … … 2093 2033 2094 2034 #if VMS_DEBUG 2095 _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int) (section->_raw_size)); 2035 _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", 2036 section->index, section->name, 2037 (int) (section->_raw_size)); 2096 2038 #endif 2097 2039 … … 2114 2056 { 2115 2057 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n", 2116 2117 2118 2119 2120 bfd_get_reloc_size((*rptr)->howto),2121 2058 (*(*rptr)->sym_ptr_ptr)->name, 2059 (*(*rptr)->sym_ptr_ptr)->section->name, 2060 (long) (*(*rptr)->sym_ptr_ptr)->value, 2061 (*rptr)->address, (*rptr)->addend, 2062 bfd_get_reloc_size ((*rptr)->howto), 2063 (*rptr)->howto->name); 2122 2064 rptr++; 2123 2065 } … … 2127 2069 2128 2070 if ((section->flags & SEC_HAS_CONTENTS) 2129 && (! bfd_is_com_section (section)))2071 && (! bfd_is_com_section (section))) 2130 2072 { 2131 bfd_vma vaddr; /* virtual addr in section*/2073 bfd_vma vaddr; /* Virtual addr in section. */ 2132 2074 2133 2075 sptr = _bfd_get_vms_section (abfd, section->index); … … 2141 2083 2142 2084 start_etir_record (abfd, section->index, (uquad) sptr->offset, 2143 false);2144 2145 while (sptr != NULL) 2085 FALSE); 2086 2087 while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */ 2146 2088 { 2147 2089 2148 if (section->flags & SEC_RELOC) 2090 if (section->flags & SEC_RELOC) /* check for relocs */ 2149 2091 { 2150 2092 arelent **rptr = section->orelocation; 2151 2093 int i = section->reloc_count; 2094 2152 2095 for (;;) 2153 2096 { 2154 2097 bfd_size_type addr = (*rptr)->address; 2155 2098 bfd_size_type len = bfd_get_reloc_size ((*rptr)->howto); 2156 if (sptr->offset < addr) 2099 if (sptr->offset < addr) /* sptr starts before reloc */ 2157 2100 { 2158 2101 bfd_size_type before = addr - sptr->offset; 2159 if (sptr->size <= before) 2102 if (sptr->size <= before) /* complete before */ 2160 2103 { 2161 2104 sto_imm (abfd, sptr, vaddr, section->index); … … 2174 2117 } 2175 2118 } 2176 else if (sptr->offset == addr) 2119 else if (sptr->offset == addr) /* sptr starts at reloc */ 2177 2120 { 2178 2121 asymbol *sym = *(*rptr)->sym_ptr_ptr; … … 2188 2131 if (bfd_is_und_section (sym->section)) 2189 2132 { 2190 if (_bfd_vms_output_check (abfd, 2191 strlen((char *)sym->name)) 2192 < 0) 2133 int slen = strlen ((char *) sym->name); 2134 char *hash; 2135 2136 if (_bfd_vms_output_check (abfd, slen) < 0) 2193 2137 { 2194 2138 end_etir_record (abfd); 2195 2139 start_etir_record (abfd, 2196 2140 section->index, 2197 vaddr, false);2141 vaddr, FALSE); 2198 2142 } 2199 2143 _bfd_vms_output_begin (abfd, 2200 ETIR_S_C_STO_GBL_LW, 2201 -1); 2202 _bfd_vms_output_counted (abfd, 2203 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2144 ETIR_S_C_STO_GBL_LW, 2145 -1); 2146 hash = (_bfd_vms_length_hash_symbol 2147 (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2148 _bfd_vms_output_counted (abfd, hash); 2204 2149 _bfd_vms_output_flush (abfd); 2205 2150 } … … 2211 2156 start_etir_record (abfd, 2212 2157 section->index, 2213 vaddr, false);2158 vaddr, FALSE); 2214 2159 } 2215 2160 _bfd_vms_output_begin (abfd, 2216 2217 2161 ETIR_S_C_STA_LW, 2162 -1); 2218 2163 _bfd_vms_output_quad (abfd, 2219 (uquad)sym->value);2164 (uquad) sym->value); 2220 2165 _bfd_vms_output_flush (abfd); 2221 2166 _bfd_vms_output_begin (abfd, 2222 2223 2167 ETIR_S_C_STO_LW, 2168 -1); 2224 2169 _bfd_vms_output_flush (abfd); 2225 2170 } … … 2231 2176 start_etir_record (abfd, 2232 2177 section->index, 2233 vaddr, false);2178 vaddr, FALSE); 2234 2179 } 2235 2180 _bfd_vms_output_begin (abfd, 2236 2237 2181 ETIR_S_C_STA_PQ, 2182 -1); 2238 2183 _bfd_vms_output_long (abfd, 2239 2184 (unsigned long) (sec->index)); 2240 2185 _bfd_vms_output_quad (abfd, 2241 2242 + (uquad)sym->value));2186 ((uquad) (*rptr)->addend 2187 + (uquad) sym->value)); 2243 2188 _bfd_vms_output_flush (abfd); 2244 2189 _bfd_vms_output_begin (abfd, 2245 2246 2190 ETIR_S_C_STO_LW, 2191 -1); 2247 2192 _bfd_vms_output_flush (abfd); 2248 2193 } … … 2254 2199 if (bfd_is_und_section (sym->section)) 2255 2200 { 2256 i f (_bfd_vms_output_check (abfd,2257 strlen((char *)sym->name))2258 2201 int slen = strlen ((char *) sym->name); 2202 char *hash; 2203 if (_bfd_vms_output_check (abfd, slen) < 0) 2259 2204 { 2260 2205 end_etir_record (abfd); 2261 2206 start_etir_record (abfd, 2262 2207 section->index, 2263 vaddr, false);2208 vaddr, FALSE); 2264 2209 } 2265 2210 _bfd_vms_output_begin (abfd, 2266 ETIR_S_C_STO_GBL, 2267 -1); 2268 _bfd_vms_output_counted (abfd, 2269 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2211 ETIR_S_C_STO_GBL, 2212 -1); 2213 hash = (_bfd_vms_length_hash_symbol 2214 (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2215 _bfd_vms_output_counted (abfd, hash); 2270 2216 _bfd_vms_output_flush (abfd); 2271 2217 } … … 2277 2223 start_etir_record (abfd, 2278 2224 section->index, 2279 vaddr, false);2225 vaddr, FALSE); 2280 2226 } 2281 2227 _bfd_vms_output_begin (abfd, 2282 2283 2228 ETIR_S_C_STA_QW, 2229 -1); 2284 2230 _bfd_vms_output_quad (abfd, 2285 (uquad)sym->value);2231 (uquad) sym->value); 2286 2232 _bfd_vms_output_flush (abfd); 2287 2233 _bfd_vms_output_begin (abfd, 2288 2289 2234 ETIR_S_C_STO_QW, 2235 -1); 2290 2236 _bfd_vms_output_flush (abfd); 2291 2237 } … … 2297 2243 start_etir_record (abfd, 2298 2244 section->index, 2299 vaddr, false);2245 vaddr, FALSE); 2300 2246 } 2301 2247 _bfd_vms_output_begin (abfd, 2302 2303 2248 ETIR_S_C_STA_PQ, 2249 -1); 2304 2250 _bfd_vms_output_long (abfd, 2305 2251 (unsigned long) (sec->index)); 2306 2252 _bfd_vms_output_quad (abfd, 2307 2308 + (uquad)sym->value));2253 ((uquad) (*rptr)->addend 2254 + (uquad) sym->value)); 2309 2255 _bfd_vms_output_flush (abfd); 2310 2256 _bfd_vms_output_begin (abfd, 2311 2312 2257 ETIR_S_C_STO_OFF, 2258 -1); 2313 2259 _bfd_vms_output_flush (abfd); 2314 2260 } … … 2319 2265 { 2320 2266 int hint_size; 2267 char *hash ATTRIBUTE_UNUSED; 2321 2268 2322 2269 hint_size = sptr->size; … … 2325 2272 sptr->size = hint_size; 2326 2273 #if 0 2327 vms_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1); 2328 vms_output_long(abfd, (unsigned long) (sec->index)); 2329 vms_output_quad(abfd, (uquad)addr); 2330 2331 vms_output_counted(abfd, _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2332 vms_output_flush(abfd); 2274 vms_output_begin (abfd, 2275 ETIR_S_C_STO_HINT_GBL, -1); 2276 vms_output_long (abfd, 2277 (unsigned long) (sec->index)); 2278 vms_output_quad (abfd, (uquad) addr); 2279 2280 hash = (_bfd_vms_length_hash_symbol 2281 (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2282 vms_output_counted (abfd, hash); 2283 2284 vms_output_flush (abfd); 2333 2285 #endif 2334 2286 } … … 2336 2288 case ALPHA_R_LINKAGE: 2337 2289 { 2290 char *hash; 2291 2338 2292 if (_bfd_vms_output_check (abfd, 64) < 0) 2339 2293 { 2340 2294 end_etir_record (abfd); 2341 2295 start_etir_record (abfd, section->index, 2342 vaddr, false);2296 vaddr, FALSE); 2343 2297 } 2344 2298 _bfd_vms_output_begin (abfd, 2345 2346 2299 ETIR_S_C_STC_LP_PSB, 2300 -1); 2347 2301 _bfd_vms_output_long (abfd, 2348 (unsigned long)PRIV(vms_linkage_index)); 2349 PRIV(vms_linkage_index) += 2; 2350 _bfd_vms_output_counted (abfd, 2351 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2302 (unsigned long) PRIV (vms_linkage_index)); 2303 PRIV (vms_linkage_index) += 2; 2304 hash = (_bfd_vms_length_hash_symbol 2305 (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2306 _bfd_vms_output_counted (abfd, hash); 2352 2307 _bfd_vms_output_byte (abfd, 0); 2353 2308 _bfd_vms_output_flush (abfd); … … 2357 2312 case ALPHA_R_CODEADDR: 2358 2313 { 2359 i f (_bfd_vms_output_check (abfd,2360 strlen((char *)sym->name))2361 2314 int slen = strlen ((char *) sym->name); 2315 char *hash; 2316 if (_bfd_vms_output_check (abfd, slen) < 0) 2362 2317 { 2363 2318 end_etir_record (abfd); 2364 2319 start_etir_record (abfd, 2365 2320 section->index, 2366 vaddr, false);2321 vaddr, FALSE); 2367 2322 } 2368 2323 _bfd_vms_output_begin (abfd, 2369 ETIR_S_C_STO_CA, 2370 -1); 2371 _bfd_vms_output_counted (abfd, 2372 _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2324 ETIR_S_C_STO_CA, 2325 -1); 2326 hash = (_bfd_vms_length_hash_symbol 2327 (abfd, sym->name, EOBJ_S_C_SYMSIZ)); 2328 _bfd_vms_output_counted (abfd, hash); 2373 2329 _bfd_vms_output_flush (abfd); 2374 2330 } … … 2396 2352 } 2397 2353 } 2398 else 2354 else /* sptr starts after reloc */ 2399 2355 { 2400 i--; 2356 i--; /* check next reloc */ 2401 2357 rptr++; 2402 2358 } 2403 2359 2404 if (i==0) 2360 if (i==0) /* all reloc checked */ 2405 2361 { 2406 2362 if (sptr->size > 0) 2407 2363 { 2408 sto_imm (abfd, sptr, vaddr, section->index); /* dump rest */ 2364 /* dump rest */ 2365 sto_imm (abfd, sptr, vaddr, section->index); 2409 2366 vaddr += sptr->size; 2410 2367 } … … 2413 2370 } /* for (;;) */ 2414 2371 } /* if SEC_RELOC */ 2415 else 2372 else /* no relocs, just dump */ 2416 2373 { 2417 2374 sto_imm (abfd, sptr, vaddr, section->index); … … 2430 2387 } 2431 2388 2432 _bfd_vms_output_alignment (abfd, 2);2389 _bfd_vms_output_alignment (abfd, 2); 2433 2390 return 0; 2434 2391 } 2435 2392 2436 /* write traceback data for bfd abfd*/2393 /* Write traceback data for bfd abfd. */ 2437 2394 2438 2395 int … … 2448 2405 } 2449 2406 2450 /* write debug info for bfd abfd*/2407 /* Write debug info for bfd abfd. */ 2451 2408 2452 2409 int -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.