Changeset 609 for branches/GNU/src/binutils/bfd/ieee.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/ieee.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for ieee-695 objects. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001 3 2000, 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 6 6 Written by Steve Chamberlain of Cygnus Support. 7 7 8 This file is part of BFD, the Binary File Descriptor library.9 10 This program is free software; you can redistribute it and/or modify11 it under the terms of the GNU General Public License as published by12 the Free Software Foundation; either version 2 of the License, or13 (at your option) any later version.14 15 This program is distributed in the hope that it will be useful,16 but WITHOUT ANY WARRANTY; without even the implied warranty of17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18 GNU General Public License for more details.19 20 You should have received a copy of the GNU General Public License21 along with this program; if not, write to the Free Software22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */8 This file is part of BFD, the Binary File Descriptor library. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 23 24 24 #define KEEPMINUSPCININST 0 … … 33 33 #include "ieee.h" 34 34 #include "libieee.h" 35 36 #include <ctype.h> 37 38 static boolean ieee_write_byte PARAMS ((bfd *, int)); 39 static boolean ieee_write_2bytes PARAMS ((bfd *, int)); 40 static boolean ieee_write_int PARAMS ((bfd *, bfd_vma)); 41 static boolean ieee_write_id PARAMS ((bfd *, const char *)); 42 static boolean ieee_write_expression 43 PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int)); 44 static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma)); 45 static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma)); 46 static boolean ieee_write_section_part PARAMS ((bfd *)); 47 static boolean do_with_relocs PARAMS ((bfd *, asection *)); 48 static boolean do_as_repeat PARAMS ((bfd *, asection *)); 49 static boolean do_without_relocs PARAMS ((bfd *, asection *)); 50 static boolean ieee_write_external_part PARAMS ((bfd *)); 51 static boolean ieee_write_data_part PARAMS ((bfd *)); 52 static boolean ieee_write_debug_part PARAMS ((bfd *)); 53 static boolean ieee_write_me_part PARAMS ((bfd *)); 54 static boolean ieee_write_processor PARAMS ((bfd *)); 55 56 static boolean ieee_slurp_debug PARAMS ((bfd *)); 57 static boolean ieee_slurp_section_data PARAMS ((bfd *)); 35 #include "safe-ctype.h" 36 37 struct output_buffer_struct 38 { 39 unsigned char *ptrp; 40 int buffer; 41 }; 42 43 static bfd_boolean ieee_write_byte 44 PARAMS ((bfd *, int)); 45 static bfd_boolean ieee_write_2bytes 46 PARAMS ((bfd *, int)); 47 static bfd_boolean ieee_write_int 48 PARAMS ((bfd *, bfd_vma)); 49 static bfd_boolean ieee_write_id 50 PARAMS ((bfd *, const char *)); 51 static unsigned short read_2bytes 52 PARAMS ((common_header_type *)); 53 static void bfd_get_string 54 PARAMS ((common_header_type *, char *, size_t)); 55 static char *read_id 56 PARAMS ((common_header_type *)); 57 static bfd_boolean ieee_write_expression 58 PARAMS ((bfd *, bfd_vma, asymbol *, bfd_boolean, unsigned int)); 59 static void ieee_write_int5 60 PARAMS ((bfd_byte *, bfd_vma)); 61 static bfd_boolean ieee_write_int5_out 62 PARAMS ((bfd *, bfd_vma)); 63 static bfd_boolean parse_int 64 PARAMS ((common_header_type *, bfd_vma *)); 65 static int parse_i 66 PARAMS ((common_header_type *, bfd_boolean *)); 67 static bfd_vma must_parse_int 68 PARAMS ((common_header_type *)); 69 static void parse_expression 70 PARAMS ((ieee_data_type *, bfd_vma *, ieee_symbol_index_type *, 71 bfd_boolean *, unsigned int *, asection **)); 72 static file_ptr ieee_part_after 73 PARAMS ((ieee_data_type *, file_ptr)); 74 static ieee_symbol_type *get_symbol 75 PARAMS ((bfd *, ieee_data_type *, ieee_symbol_type *, unsigned int *, 76 ieee_symbol_type ***, unsigned int *, int)); 77 static bfd_boolean ieee_slurp_external_symbols 78 PARAMS ((bfd *)); 79 static bfd_boolean ieee_slurp_symbol_table 80 PARAMS ((bfd *)); 81 static long ieee_get_symtab_upper_bound 82 PARAMS ((bfd *)); 83 static long ieee_get_symtab 84 PARAMS ((bfd *, asymbol **)); 85 static asection *get_section_entry 86 PARAMS ((bfd *, ieee_data_type *i, unsigned int)); 87 static void ieee_slurp_sections 88 PARAMS ((bfd *)); 89 static bfd_boolean ieee_slurp_debug 90 PARAMS ((bfd *)); 91 const bfd_target *ieee_archive_p 92 PARAMS ((bfd *)); 93 const bfd_target *ieee_object_p 94 PARAMS ((bfd *)); 95 static void ieee_get_symbol_info 96 PARAMS ((bfd *, asymbol *, symbol_info *)); 97 static void ieee_print_symbol 98 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); 99 static bfd_boolean do_one 100 PARAMS ((ieee_data_type *, ieee_per_section_type *, unsigned char *, 101 asection *, int)); 102 static bfd_boolean ieee_slurp_section_data 103 PARAMS ((bfd *)); 104 static bfd_boolean ieee_new_section_hook 105 PARAMS ((bfd *, asection *)); 106 static long ieee_get_reloc_upper_bound 107 PARAMS ((bfd *, sec_ptr)); 108 static bfd_boolean ieee_get_section_contents 109 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); 110 static long ieee_canonicalize_reloc 111 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); 112 static int comp 113 PARAMS ((const PTR, const PTR)); 114 static bfd_boolean ieee_write_section_part 115 PARAMS ((bfd *)); 116 static bfd_boolean do_with_relocs 117 PARAMS ((bfd *, asection *)); 118 static bfd_boolean do_as_repeat 119 PARAMS ((bfd *, asection *)); 120 static bfd_boolean do_without_relocs 121 PARAMS ((bfd *, asection *)); 122 static bfd_boolean ieee_mkobject 123 PARAMS ((bfd *)); 124 static void fill 125 PARAMS ((void)); 126 static void flush 127 PARAMS ((void)); 128 static void write_int 129 PARAMS ((int)); 130 static void copy_id 131 PARAMS ((void)); 132 static void copy_expression 133 PARAMS ((void)); 134 static void fill_int 135 PARAMS ((struct output_buffer_struct *)); 136 static void drop_int 137 PARAMS ((struct output_buffer_struct *)); 138 static void copy_int 139 PARAMS ((void)); 140 static void f1_record 141 PARAMS ((void)); 142 static void f0_record 143 PARAMS ((void)); 144 static void copy_till_end 145 PARAMS ((void)); 146 static void f2_record 147 PARAMS ((void)); 148 static void f8_record 149 PARAMS ((void)); 150 static void e2_record 151 PARAMS ((void)); 152 static void block 153 PARAMS ((void)); 154 static void relocate_debug 155 PARAMS ((bfd *, bfd *)); 156 static bfd_boolean ieee_write_debug_part 157 PARAMS ((bfd *)); 158 static bfd_boolean ieee_write_data_part 159 PARAMS ((bfd *)); 160 static bfd_boolean init_for_output 161 PARAMS ((bfd *)); 162 static bfd_boolean ieee_set_section_contents 163 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); 164 static bfd_boolean ieee_write_external_part 165 PARAMS ((bfd *)); 166 static bfd_boolean ieee_write_me_part 167 PARAMS ((bfd *)); 168 static bfd_boolean ieee_write_processor 169 PARAMS ((bfd *)); 170 static bfd_boolean ieee_write_object_contents 171 PARAMS ((bfd *)); 172 static asymbol *ieee_make_empty_symbol 173 PARAMS ((bfd *)); 174 static bfd *ieee_openr_next_archived_file 175 PARAMS ((bfd *, bfd *)); 176 static bfd_boolean ieee_find_nearest_line 177 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, 178 const char **, unsigned int *)); 179 static int ieee_generic_stat_arch_elt 180 PARAMS ((bfd *, struct stat *)); 181 static int ieee_sizeof_headers 182 PARAMS ((bfd *, bfd_boolean)); 58 183 59 184 /* Functions for writing to ieee files in the strange way that the 60 185 standard requires. */ 61 186 62 static b oolean187 static bfd_boolean 63 188 ieee_write_byte (abfd, barg) 64 189 bfd *abfd; … … 68 193 69 194 byte = barg; 70 if (bfd_ write ((PTR) &byte, 1,1, abfd) != 1)71 return false;72 return true;73 } 74 75 static b oolean195 if (bfd_bwrite ((PTR) &byte, (bfd_size_type) 1, abfd) != 1) 196 return FALSE; 197 return TRUE; 198 } 199 200 static bfd_boolean 76 201 ieee_write_2bytes (abfd, bytes) 77 202 bfd *abfd; … … 82 207 buffer[0] = bytes >> 8; 83 208 buffer[1] = bytes & 0xff; 84 if (bfd_ write ((PTR) buffer, 1,2, abfd) != 2)85 return false;86 return true;87 } 88 89 static b oolean209 if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 2, abfd) != 2) 210 return FALSE; 211 return TRUE; 212 } 213 214 static bfd_boolean 90 215 ieee_write_int (abfd, value) 91 216 bfd *abfd; … … 95 220 { 96 221 if (! ieee_write_byte (abfd, (bfd_byte) value)) 97 return false;222 return FALSE; 98 223 } 99 224 else … … 101 226 unsigned int length; 102 227 103 /* How many significant bytes ? */104 /* FIXME FOR LONGER INTS */228 /* How many significant bytes ? */ 229 /* FIXME FOR LONGER INTS. */ 105 230 if (value & 0xff000000) 106 231 length = 4; … … 115 240 (bfd_byte) ((int) ieee_number_repeat_start_enum 116 241 + length))) 117 return false;242 return FALSE; 118 243 switch (length) 119 244 { 120 245 case 4: 121 246 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24))) 122 return false;247 return FALSE; 123 248 /* Fall through. */ 124 249 case 3: 125 250 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16))) 126 return false;251 return FALSE; 127 252 /* Fall through. */ 128 253 case 2: 129 254 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8))) 130 return false;255 return FALSE; 131 256 /* Fall through. */ 132 257 case 1: 133 258 if (! ieee_write_byte (abfd, (bfd_byte) (value))) 134 return false;259 return FALSE; 135 260 } 136 261 } 137 262 138 return true;139 } 140 141 static b oolean263 return TRUE; 264 } 265 266 static bfd_boolean 142 267 ieee_write_id (abfd, id) 143 268 bfd *abfd; … … 149 274 { 150 275 if (! ieee_write_byte (abfd, (bfd_byte) length)) 151 return false;276 return FALSE; 152 277 } 153 278 else if (length < 255) … … 155 280 if (! ieee_write_byte (abfd, ieee_extension_length_1_enum) 156 281 || ! ieee_write_byte (abfd, (bfd_byte) length)) 157 return false;282 return FALSE; 158 283 } 159 284 else if (length < 65535) … … 161 286 if (! ieee_write_byte (abfd, ieee_extension_length_2_enum) 162 287 || ! ieee_write_2bytes (abfd, (int) length)) 163 return false;288 return FALSE; 164 289 } 165 290 else … … 169 294 bfd_get_filename (abfd), length); 170 295 bfd_set_error (bfd_error_invalid_operation); 171 return false; 172 } 173 174 if (bfd_write ((PTR) id, 1, length, abfd) != length) 175 return false; 176 return true; 177 } 178 179 180 /*************************************************************************** 181 Functions for reading from ieee files in the strange way that the 182 standard requires: 183 */ 296 return FALSE; 297 } 298 299 if (bfd_bwrite ((PTR) id, (bfd_size_type) length, abfd) != length) 300 return FALSE; 301 return TRUE; 302 } 303 304 305 /* Functions for reading from ieee files in the strange way that the 306 standard requires. */ 184 307 185 308 #define this_byte(ieee) *((ieee)->input_p) … … 193 316 unsigned char c1 = this_byte_and_next (ieee); 194 317 unsigned char c2 = this_byte_and_next (ieee); 318 195 319 return (c1 << 8) | c2; 196 320 } … … 203 327 { 204 328 size_t i; 329 205 330 for (i = 0; i < length; i++) 206 { 207 string[i] = this_byte_and_next (ieee); 208 } 331 string[i] = this_byte_and_next (ieee); 209 332 } 210 333 … … 215 338 size_t length; 216 339 char *string; 340 217 341 length = this_byte_and_next (ieee); 218 342 if (length <= 0x7f) 219 343 { 220 /* Simple string of length 0 to 127 */344 /* Simple string of length 0 to 127. */ 221 345 } 222 346 else if (length == 0xde) 223 347 { 224 /* Length is next byte, allowing 0..255 */348 /* Length is next byte, allowing 0..255. */ 225 349 length = this_byte_and_next (ieee); 226 350 } 227 351 else if (length == 0xdf) 228 352 { 229 /* Length is next two bytes, allowing 0..65535 */353 /* Length is next two bytes, allowing 0..65535. */ 230 354 length = this_byte_and_next (ieee); 231 355 length = (length * 256) + this_byte_and_next (ieee); 232 356 } 233 /* Buy memory and read string */ 234 string = bfd_alloc (ieee->abfd, length + 1); 357 358 /* Buy memory and read string. */ 359 string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1); 235 360 if (!string) 236 361 return NULL; … … 240 365 } 241 366 242 static b oolean367 static bfd_boolean 243 368 ieee_write_expression (abfd, value, symbol, pcrel, index) 244 369 bfd *abfd; 245 370 bfd_vma value; 246 371 asymbol *symbol; 247 b oolean pcrel;372 bfd_boolean pcrel; 248 373 unsigned int index; 249 374 { … … 253 378 { 254 379 if (! ieee_write_int (abfd, value)) 255 return false;380 return FALSE; 256 381 term_count++; 257 382 } 258 383 259 if (bfd_is_com_section (symbol->section) 260 || bfd_is_und_section (symbol->section)) 261 { 262 /* Def of a common symbol */ 263 if (! ieee_write_byte (abfd, ieee_variable_X_enum) 264 || ! ieee_write_int (abfd, symbol->value)) 265 return false; 266 term_count++; 267 } 268 else if (! bfd_is_abs_section (symbol->section)) 269 { 270 /* Ref to defined symbol - */ 271 272 if (symbol->flags & BSF_GLOBAL) 384 /* Badly formatted binaries can have a missing symbol, 385 so test here to prevent a seg fault. */ 386 if (symbol != NULL) 387 { 388 if (bfd_is_com_section (symbol->section) 389 || bfd_is_und_section (symbol->section)) 273 390 { 274 if (! ieee_write_byte (abfd, ieee_variable_I_enum) 391 /* Def of a common symbol. */ 392 if (! ieee_write_byte (abfd, ieee_variable_X_enum) 275 393 || ! ieee_write_int (abfd, symbol->value)) 276 return false;277 term_count ++;394 return FALSE; 395 term_count ++; 278 396 } 279 else if ( symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))397 else if (! bfd_is_abs_section (symbol->section)) 280 398 { 281 /* This is a reference to a defined local symbol. We can 282 easily do a local as a section+offset. */ 283 if (! ieee_write_byte (abfd, ieee_variable_R_enum) 284 || ! ieee_write_byte (abfd, 285 (bfd_byte) (symbol->section->index 286 + IEEE_SECTION_NUMBER_BASE))) 287 return false; 288 term_count++; 289 if (symbol->value != 0) 399 /* Ref to defined symbol - */ 400 401 if (symbol->flags & BSF_GLOBAL) 290 402 { 291 if (! ieee_write_int (abfd, symbol->value)) 292 return false; 403 if (! ieee_write_byte (abfd, ieee_variable_I_enum) 404 || ! ieee_write_int (abfd, symbol->value)) 405 return FALSE; 293 406 term_count++; 294 407 } 408 else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM)) 409 { 410 /* This is a reference to a defined local symbol. We can 411 easily do a local as a section+offset. */ 412 if (! ieee_write_byte (abfd, ieee_variable_R_enum) 413 || ! ieee_write_byte (abfd, 414 (bfd_byte) (symbol->section->index 415 + IEEE_SECTION_NUMBER_BASE))) 416 return FALSE; 417 418 term_count++; 419 if (symbol->value != 0) 420 { 421 if (! ieee_write_int (abfd, symbol->value)) 422 return FALSE; 423 term_count++; 424 } 425 } 426 else 427 { 428 (*_bfd_error_handler) 429 (_("%s: unrecognized symbol `%s' flags 0x%x"), 430 bfd_get_filename (abfd), bfd_asymbol_name (symbol), 431 symbol->flags); 432 bfd_set_error (bfd_error_invalid_operation); 433 return FALSE; 434 } 295 435 } 296 else297 {298 (*_bfd_error_handler)299 (_("%s: unrecognized symbol `%s' flags 0x%x"),300 bfd_get_filename (abfd), bfd_asymbol_name (symbol),301 symbol->flags);302 bfd_set_error (bfd_error_invalid_operation);303 return false;304 }305 436 } 306 437 307 438 if (pcrel) 308 439 { 309 /* subtract the pc from here by asking for PC of this section*/440 /* Subtract the pc from here by asking for PC of this section. */ 310 441 if (! ieee_write_byte (abfd, ieee_variable_P_enum) 311 442 || ! ieee_write_byte (abfd, 312 443 (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE)) 313 444 || ! ieee_write_byte (abfd, ieee_function_minus_enum)) 314 return false;445 return FALSE; 315 446 } 316 447 317 448 /* Handle the degenerate case of a 0 address. */ 318 449 if (term_count == 0) 319 { 320 if (! ieee_write_int (abfd, 0)) 321 return false; 322 } 450 if (! ieee_write_int (abfd, (bfd_vma) 0)) 451 return FALSE; 323 452 324 453 while (term_count > 1) 325 454 { 326 455 if (! ieee_write_byte (abfd, ieee_function_plus_enum)) 327 return false;456 return FALSE; 328 457 term_count--; 329 458 } 330 459 331 return true; 332 } 333 334 335 /*****************************************************************************/ 336 337 /* 338 writes any integer into the buffer supplied and always takes 5 bytes 339 */ 460 return TRUE; 461 } 462 463 464 /* Writes any integer into the buffer supplied and always takes 5 bytes. */ 465 340 466 static void 341 467 ieee_write_int5 (buffer, value) … … 350 476 } 351 477 352 static b oolean478 static bfd_boolean 353 479 ieee_write_int5_out (abfd, value) 354 480 bfd *abfd; … … 358 484 359 485 ieee_write_int5 (b, value); 360 if (bfd_ write ((PTR) b, 1,5, abfd) != 5)361 return false;362 return true;363 } 364 365 static b oolean486 if (bfd_bwrite ((PTR) b, (bfd_size_type) 5, abfd) != 5) 487 return FALSE; 488 return TRUE; 489 } 490 491 static bfd_boolean 366 492 parse_int (ieee, value_ptr) 367 493 common_header_type *ieee; … … 370 496 int value = this_byte (ieee); 371 497 int result; 498 372 499 if (value >= 0 && value <= 127) 373 500 { 374 501 *value_ptr = value; 375 502 next_byte (ieee); 376 return true;503 return TRUE; 377 504 } 378 505 else if (value >= 0x80 && value <= 0x88) 379 506 { 380 507 unsigned int count = value & 0xf; 508 381 509 result = 0; 382 510 next_byte (ieee); … … 387 515 } 388 516 *value_ptr = result; 389 return true;390 } 391 return false;517 return TRUE; 518 } 519 return FALSE; 392 520 } 393 521 … … 395 523 parse_i (ieee, ok) 396 524 common_header_type *ieee; 397 b oolean *ok;525 bfd_boolean *ok; 398 526 { 399 527 bfd_vma x; … … 407 535 { 408 536 bfd_vma result; 409 BFD_ASSERT (parse_int (ieee, &result) == true);537 BFD_ASSERT (parse_int (ieee, &result)); 410 538 return result; 411 539 } … … 422 550 423 551 #define SRC_MASK(arg) arg 424 #define PCREL_OFFSET false552 #define PCREL_OFFSET FALSE 425 553 426 554 #else 427 555 428 556 #define SRC_MASK(arg) 0 429 #define PCREL_OFFSET true557 #define PCREL_OFFSET TRUE 430 558 431 559 #endif … … 436 564 2, 437 565 32, 438 false,566 FALSE, 439 567 0, 440 568 complain_overflow_bitfield, 441 569 0, 442 570 "abs32", 443 true,571 TRUE, 444 572 0xffffffff, 445 573 0xffffffff, 446 false);574 FALSE); 447 575 448 576 static reloc_howto_type abs16_howto = … … 451 579 1, 452 580 16, 453 false,581 FALSE, 454 582 0, 455 583 complain_overflow_bitfield, 456 584 0, 457 585 "abs16", 458 true,586 TRUE, 459 587 0x0000ffff, 460 588 0x0000ffff, 461 false);589 FALSE); 462 590 463 591 static reloc_howto_type abs8_howto = … … 466 594 0, 467 595 8, 468 false,596 FALSE, 469 597 0, 470 598 complain_overflow_bitfield, 471 599 0, 472 600 "abs8", 473 true,601 TRUE, 474 602 0x000000ff, 475 603 0x000000ff, 476 false);604 FALSE); 477 605 478 606 static reloc_howto_type rel32_howto = … … 481 609 2, 482 610 32, 483 true,611 TRUE, 484 612 0, 485 613 complain_overflow_signed, 486 614 0, 487 615 "rel32", 488 true,616 TRUE, 489 617 SRC_MASK (0xffffffff), 490 618 0xffffffff, … … 496 624 1, 497 625 16, 498 true,626 TRUE, 499 627 0, 500 628 complain_overflow_signed, 501 629 0, 502 630 "rel16", 503 true,631 TRUE, 504 632 SRC_MASK (0x0000ffff), 505 633 0x0000ffff, … … 511 639 0, 512 640 8, 513 true,641 TRUE, 514 642 0, 515 643 complain_overflow_signed, 516 644 0, 517 645 "rel8", 518 true,646 TRUE, 519 647 SRC_MASK (0x000000ff), 520 648 0x000000ff, … … 528 656 bfd_vma *value; 529 657 ieee_symbol_index_type *symbol; 530 b oolean *pcrel;658 bfd_boolean *pcrel; 531 659 unsigned int *extra; 532 660 asection **section; … … 539 667 #define DEC sp--; 540 668 541 b oolean loop = true;669 bfd_boolean loop = TRUE; 542 670 ieee_value_type stack[10]; 543 671 544 /* The stack pointer always points to the next unused location */672 /* The stack pointer always points to the next unused location. */ 545 673 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; 546 674 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; 547 675 ieee_value_type *sp = stack; 548 549 while (loop) 676 asection *dummy; 677 678 while (loop && ieee->h.input_p < ieee->h.last_byte) 550 679 { 551 680 switch (this_byte (&(ieee->h))) 552 681 { 553 682 case ieee_variable_P_enum: 554 /* P variable, current program counter for section n */683 /* P variable, current program counter for section n. */ 555 684 { 556 685 int section_n; 686 557 687 next_byte (&(ieee->h)); 558 *pcrel = true;688 *pcrel = TRUE; 559 689 section_n = must_parse_int (&(ieee->h)); 560 690 PUSH (NOSYMBOL, bfd_abs_section_ptr, 0); … … 562 692 } 563 693 case ieee_variable_L_enum: 564 /* L variable address of section N */694 /* L variable address of section N. */ 565 695 next_byte (&(ieee->h)); 566 696 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); 567 697 break; 568 698 case ieee_variable_R_enum: 569 /* R variable, logical address of section module */570 /* FIXME, this should be different to L */699 /* R variable, logical address of section module. */ 700 /* FIXME, this should be different to L. */ 571 701 next_byte (&(ieee->h)); 572 702 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); 573 703 break; 574 704 case ieee_variable_S_enum: 575 /* S variable, size in MAUS of section module */705 /* S variable, size in MAUS of section module. */ 576 706 next_byte (&(ieee->h)); 577 707 PUSH (NOSYMBOL, … … 580 710 break; 581 711 case ieee_variable_I_enum: 582 /* Push the address of variable n */712 /* Push the address of variable n. */ 583 713 { 584 714 ieee_symbol_index_type sy; … … 591 721 break; 592 722 case ieee_variable_X_enum: 593 /* Push the address of external variable n */723 /* Push the address of external variable n. */ 594 724 { 595 725 ieee_symbol_index_type sy; … … 640 770 else 641 771 { 642 /* 643 Thats all that we can understand. As far as I can see 644 there is a bug in the Microtec IEEE output which I'm 645 using to scan, whereby the comma operator is omitted 646 sometimes in an expression, giving expressions with too 647 many terms. We can tell if that's the case by ensuring 648 that sp == stack here. If not, then we've pushed 649 something too far, so we keep adding. */ 650 651 while (sp != stack + 1) 652 { 653 asection *section1; 654 ieee_symbol_index_type sy1; 655 POP (sy1, section1, *extra); 656 } 657 { 658 asection *dummy; 659 660 POP (*symbol, dummy, *value); 661 if (section) 662 *section = dummy; 663 } 664 665 loop = false; 772 /* Thats all that we can understand. */ 773 loop = FALSE; 666 774 } 667 775 } 668 776 } 669 777 } 670 } 671 672 673 #define ieee_seek(abfd, offset) \ 674 IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset 675 676 #define ieee_pos(abfd) \ 677 (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte) 778 779 /* As far as I can see there is a bug in the Microtec IEEE output 780 which I'm using to scan, whereby the comma operator is omitted 781 sometimes in an expression, giving expressions with too many 782 terms. We can tell if that's the case by ensuring that 783 sp == stack here. If not, then we've pushed something too far, 784 so we keep adding. */ 785 while (sp != stack + 1) 786 { 787 asection *section1; 788 ieee_symbol_index_type sy1; 789 POP (sy1, section1, *extra); 790 } 791 792 POP (*symbol, dummy, *value); 793 if (section) 794 *section = dummy; 795 } 796 797 798 #define ieee_seek(ieee, offset) \ 799 do \ 800 { \ 801 ieee->h.input_p = ieee->h.first_byte + offset; \ 802 ieee->h.last_byte = (ieee->h.first_byte \ 803 + ieee_part_after (ieee, offset)); \ 804 } \ 805 while (0) 806 807 #define ieee_pos(ieee) \ 808 (ieee->h.input_p - ieee->h.first_byte) 809 810 /* Find the first part of the ieee file after HERE. */ 811 812 static file_ptr 813 ieee_part_after (ieee, here) 814 ieee_data_type *ieee; 815 file_ptr here; 816 { 817 int part; 818 file_ptr after = ieee->w.r.me_record; 819 820 /* File parts can come in any order, except that module end is 821 guaranteed to be last (and the header first). */ 822 for (part = 0; part < N_W_VARIABLES; part++) 823 if (ieee->w.offset[part] > here && after > ieee->w.offset[part]) 824 after = ieee->w.offset[part]; 825 826 return after; 827 } 678 828 679 829 static unsigned int last_index; 680 static char last_type; /* is the index for an X or a D*/830 static char last_type; /* Is the index for an X or a D. */ 681 831 682 832 static ieee_symbol_type * 683 get_symbol (abfd, 684 ieee, 685 last_symbol, 686 symbol_count, 687 pptr, 688 max_index, 689 this_type 690 ) 833 get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) 691 834 bfd *abfd ATTRIBUTE_UNUSED; 692 835 ieee_data_type *ieee; … … 695 838 ieee_symbol_type ***pptr; 696 839 unsigned int *max_index; 697 char this_type 698 ; 699 { 700 /* Need a new symbol */ 840 int this_type; 841 { 842 /* Need a new symbol. */ 701 843 unsigned int new_index = must_parse_int (&(ieee->h)); 844 702 845 if (new_index != last_index || this_type != last_type) 703 846 { 704 ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd, 705 sizeof (ieee_symbol_type)); 847 ieee_symbol_type *new_symbol; 848 bfd_size_type amt = sizeof (ieee_symbol_type); 849 850 new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd, amt); 706 851 if (!new_symbol) 707 852 return NULL; … … 713 858 *pptr = &new_symbol->next; 714 859 if (new_index > *max_index) 715 { 716 *max_index = new_index; 717 } 860 *max_index = new_index; 861 718 862 last_type = this_type; 719 863 new_symbol->symbol.section = bfd_abs_section_ptr; … … 723 867 } 724 868 725 static b oolean869 static bfd_boolean 726 870 ieee_slurp_external_symbols (abfd) 727 871 bfd *abfd; … … 734 878 ieee_symbol_type *symbol = (ieee_symbol_type *) NULL; 735 879 unsigned int symbol_count = 0; 736 b oolean loop = true;880 bfd_boolean loop = TRUE; 737 881 last_index = 0xffffff; 738 ieee->symbol_table_full = true;739 740 ieee_seek ( abfd, offset);882 ieee->symbol_table_full = TRUE; 883 884 ieee_seek (ieee, offset); 741 885 742 886 while (loop) … … 751 895 &ieee->external_symbol_max_index, 'I'); 752 896 if (symbol == NULL) 753 return false;897 return FALSE; 754 898 755 899 symbol->symbol.the_bfd = abfd; … … 765 909 &ieee->external_symbol_max_index, 'D'); 766 910 if (symbol == NULL) 767 return false;911 return FALSE; 768 912 769 913 BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); … … 780 924 unsigned int symbol_attribute_def; 781 925 bfd_vma value; 782 switch (read_2bytes ( ieee))926 switch (read_2bytes (&ieee->h)) 783 927 { 784 928 case ieee_attribute_record_enum: … … 794 938 default: 795 939 (*_bfd_error_handler) 796 (_("%s: unimplemented ATI record 797 bfd_ get_filename (abfd), symbol_attribute_def,940 (_("%s: unimplemented ATI record %u for symbol %u"), 941 bfd_archive_filename (abfd), symbol_attribute_def, 798 942 symbol_name_index); 799 943 bfd_set_error (bfd_error_bad_value); 800 return false;944 return FALSE; 801 945 break; 802 946 } 803 947 break; 804 948 case ieee_external_reference_info_record_enum: 805 /* Skip over ATX record. */949 /* Skip over ATX record. */ 806 950 parse_int (&(ieee->h), &value); 807 951 parse_int (&(ieee->h), &value); … … 812 956 /* We may get call optimization information here, 813 957 which we just ignore. The format is 814 {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs} */958 {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs}. */ 815 959 parse_int (&ieee->h, &value); 816 960 parse_int (&ieee->h, &value); … … 820 964 (*_bfd_error_handler) 821 965 (_("%s: unexpected ATN type %d in external part"), 822 bfd_ get_filename (abfd), (int) value);966 bfd_archive_filename (abfd), (int) value); 823 967 bfd_set_error (bfd_error_bad_value); 824 return false;968 return FALSE; 825 969 } 826 970 parse_int (&ieee->h, &value); … … 832 976 --value; 833 977 834 switch (read_2bytes ( ieee))978 switch (read_2bytes (&ieee->h)) 835 979 { 836 980 case ieee_asn_record_enum: … … 842 986 (*_bfd_error_handler) 843 987 (_("%s: unexpected type after ATN"), 844 bfd_ get_filename (abfd));988 bfd_archive_filename (abfd)); 845 989 bfd_set_error (bfd_error_bad_value); 846 return false;990 return FALSE; 847 991 } 848 992 } … … 854 998 unsigned int symbol_name_index; 855 999 ieee_symbol_index_type symbol_ignore; 856 b oolean pcrel_ignore;1000 bfd_boolean pcrel_ignore; 857 1001 unsigned int extra; 858 1002 next_byte (&(ieee->h)); … … 898 1042 bfd_vma value; 899 1043 next_byte (&(ieee->h)); 900 /* Throw away the external reference index */1044 /* Throw away the external reference index. */ 901 1045 (void) must_parse_int (&(ieee->h)); 902 /* Fetch the default size if not resolved */1046 /* Fetch the default size if not resolved. */ 903 1047 size = must_parse_int (&(ieee->h)); 904 /* Fetch the defautlt value if available */905 if ( parse_int (&(ieee->h), &value) == false)1048 /* Fetch the defautlt value if available. */ 1049 if (! parse_int (&(ieee->h), &value)) 906 1050 { 907 1051 value = 0; 908 1052 } 909 /* This turns into a common */1053 /* This turns into a common. */ 910 1054 symbol->symbol.section = bfd_com_section_ptr; 911 1055 symbol->symbol.value = size; … … 920 1064 &ieee->external_reference_max_index, 'X'); 921 1065 if (symbol == NULL) 922 return false;1066 return FALSE; 923 1067 924 1068 symbol->symbol.the_bfd = abfd; … … 933 1077 934 1078 default: 935 loop = false;1079 loop = FALSE; 936 1080 } 937 1081 } … … 965 1109 { 966 1110 /* There are gaps in the table -- */ 967 ieee->symbol_table_full = false;1111 ieee->symbol_table_full = FALSE; 968 1112 } 969 1113 … … 971 1115 *prev_reference_ptr = (ieee_symbol_type *) NULL; 972 1116 973 return true;974 } 975 976 static b oolean1117 return TRUE; 1118 } 1119 1120 static bfd_boolean 977 1121 ieee_slurp_symbol_table (abfd) 978 1122 bfd *abfd; 979 1123 { 980 if ( IEEE_DATA (abfd)->read_symbols == false)1124 if (! IEEE_DATA (abfd)->read_symbols) 981 1125 { 982 1126 if (! ieee_slurp_external_symbols (abfd)) 983 return false;984 IEEE_DATA (abfd)->read_symbols = true;985 } 986 return true;987 } 988 989 long1127 return FALSE; 1128 IEEE_DATA (abfd)->read_symbols = TRUE; 1129 } 1130 return TRUE; 1131 } 1132 1133 static long 990 1134 ieee_get_symtab_upper_bound (abfd) 991 1135 bfd *abfd; … … 998 1142 } 999 1143 1000 /* 1001 Move from our internal lists to the canon table, and insert in 1002 symbol index order 1003 */ 1144 /* Move from our internal lists to the canon table, and insert in 1145 symbol index order. */ 1004 1146 1005 1147 extern const bfd_target ieee_vec; 1006 1148 1007 long1149 static long 1008 1150 ieee_get_symtab (abfd, location) 1009 1151 bfd *abfd; … … 1032 1174 return -1; 1033 1175 1034 if ( ieee->symbol_table_full == false)1176 if (! ieee->symbol_table_full) 1035 1177 { 1036 /* Arrgh - there are gaps in the table, run through and fill them */1037 /* up with pointers to a null place*/1178 /* Arrgh - there are gaps in the table, run through and fill them 1179 up with pointers to a null place. */ 1038 1180 unsigned int i; 1181 1039 1182 for (i = 0; i < abfd->symcount; i++) 1040 { 1041 location[i] = &empty_symbol; 1042 } 1183 location[i] = &empty_symbol; 1043 1184 } 1044 1185 … … 1047 1188 symp != (ieee_symbol_type *) NULL; 1048 1189 symp = symp->next) 1049 { 1050 /* Place into table at correct index locations */ 1051 location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; 1052 } 1053 1054 /* The external refs are indexed in a bit */ 1190 /* Place into table at correct index locations. */ 1191 location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; 1192 1193 /* The external refs are indexed in a bit. */ 1055 1194 ieee->external_reference_base_offset = 1056 1195 -ieee->external_reference_min_index + ieee->external_symbol_count; … … 1059 1198 symp != (ieee_symbol_type *) NULL; 1060 1199 symp = symp->next) 1061 { 1062 location[symp->index + ieee->external_reference_base_offset] = 1063 &symp->symbol; 1064 1065 } 1066 } 1200 location[symp->index + ieee->external_reference_base_offset] = 1201 &symp->symbol; 1202 } 1203 1067 1204 if (abfd->symcount) 1068 { 1069 location[abfd->symcount] = (asymbol *) NULL; 1070 } 1205 location[abfd->symcount] = (asymbol *) NULL; 1206 1071 1207 return abfd->symcount; 1072 1208 } … … 1082 1218 unsigned int c, i; 1083 1219 asection **n; 1220 bfd_size_type amt; 1084 1221 1085 1222 c = ieee->section_table_size; … … 1089 1226 c *= 2; 1090 1227 1091 n = ((asection **) 1092 bfd_realloc (ieee->section_table, c * sizeof (asection *))); 1228 amt = c; 1229 amt *= sizeof (asection *); 1230 n = (asection **) bfd_realloc (ieee->section_table, amt); 1093 1231 if (n == NULL) 1094 1232 return NULL; … … 1103 1241 if (ieee->section_table[index] == (asection *) NULL) 1104 1242 { 1105 char *tmp = bfd_alloc (abfd, 11);1243 char *tmp = bfd_alloc (abfd, (bfd_size_type) 11); 1106 1244 asection *section; 1107 1245 … … 1124 1262 ieee_data_type *ieee = IEEE_DATA (abfd); 1125 1263 file_ptr offset = ieee->w.r.section_part; 1126 asection *section = (asection *) NULL;1127 1264 char *name; 1128 1265 … … 1130 1267 { 1131 1268 bfd_byte section_type[3]; 1132 ieee_seek ( abfd, offset);1133 while ( true)1269 ieee_seek (ieee, offset); 1270 while (TRUE) 1134 1271 { 1135 1272 switch (this_byte (&(ieee->h))) … … 1137 1274 case ieee_section_type_enum: 1138 1275 { 1276 asection *section; 1139 1277 unsigned int section_index; 1140 1278 next_byte (&(ieee->h)); … … 1146 1284 1147 1285 /* Set minimal section attributes. Attributes are 1148 extended later, based on section contents. */ 1149 1286 extended later, based on section contents. */ 1150 1287 switch (section_type[0]) 1151 1288 { 1152 1289 case 0xC1: 1153 /* Normal attributes for absolute sections 1290 /* Normal attributes for absolute sections. */ 1154 1291 section_type[1] = this_byte (&(ieee->h)); 1155 1292 section->flags = SEC_ALLOC; 1156 1293 switch (section_type[1]) 1157 1294 { 1158 case 0xD3: /* AS Absolute section attributes */1295 case 0xD3: /* AS Absolute section attributes. */ 1159 1296 next_byte (&(ieee->h)); 1160 1297 section_type[2] = this_byte (&(ieee->h)); … … 1162 1299 { 1163 1300 case 0xD0: 1164 /* Normal code */1301 /* Normal code. */ 1165 1302 next_byte (&(ieee->h)); 1166 1303 section->flags |= SEC_CODE; 1167 1304 break; 1168 1305 case 0xC4: 1169 /* Normal data */1306 /* Normal data. */ 1170 1307 next_byte (&(ieee->h)); 1171 1308 section->flags |= SEC_DATA; … … 1173 1310 case 0xD2: 1174 1311 next_byte (&(ieee->h)); 1175 /* Normal rom data */1312 /* Normal rom data. */ 1176 1313 section->flags |= SEC_ROM | SEC_DATA; 1177 1314 break; … … 1181 1318 } 1182 1319 break; 1183 case 0xC3: /* Named relocatable sections (type C) */1320 case 0xC3: /* Named relocatable sections (type C). */ 1184 1321 section_type[1] = this_byte (&(ieee->h)); 1185 1322 section->flags = SEC_ALLOC; 1186 1323 switch (section_type[1]) 1187 1324 { 1188 case 0xD0: /* Normal code (CP) */1325 case 0xD0: /* Normal code (CP). */ 1189 1326 next_byte (&(ieee->h)); 1190 1327 section->flags |= SEC_CODE; 1191 1328 break; 1192 case 0xC4: /* Normal data (CD) */1329 case 0xC4: /* Normal data (CD). */ 1193 1330 next_byte (&(ieee->h)); 1194 1331 section->flags |= SEC_DATA; 1195 1332 break; 1196 case 0xD2: /* Normal rom data (CR) */1333 case 0xD2: /* Normal rom data (CR). */ 1197 1334 next_byte (&(ieee->h)); 1198 1335 section->flags |= SEC_ROM | SEC_DATA; … … 1203 1340 } 1204 1341 1205 /* Read section name, use it if non empty. */1342 /* Read section name, use it if non empty. */ 1206 1343 name = read_id (&ieee->h); 1207 1344 if (name[0]) 1208 1345 section->name = name; 1209 1346 1210 /* Skip these fields, which we don't care about */1347 /* Skip these fields, which we don't care about. */ 1211 1348 { 1212 1349 bfd_vma parent, brother, context; … … 1236 1373 case ieee_e2_first_byte_enum: 1237 1374 { 1238 ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h))); 1239 1375 asection *section; 1376 ieee_record_enum_type t; 1377 1378 t = (ieee_record_enum_type) (read_2bytes (&(ieee->h))); 1240 1379 switch (t) 1241 1380 { … … 1287 1426 out. */ 1288 1427 1289 static b oolean1428 static bfd_boolean 1290 1429 ieee_slurp_debug (abfd) 1291 1430 bfd *abfd; … … 1296 1435 1297 1436 if (ieee->w.r.debug_information_part == 0) 1298 return true;1437 return TRUE; 1299 1438 1300 1439 sec = bfd_make_section (abfd, ".debug"); 1301 1440 if (sec == NULL) 1302 return false;1441 return FALSE; 1303 1442 sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS; 1304 1443 sec->filepos = ieee->w.r.debug_information_part; 1305 1444 1306 debug_end = ieee->w.r.data_part; 1307 if (debug_end == 0) 1308 debug_end = ieee->w.r.trailer_part; 1309 if (debug_end == 0) 1310 debug_end = ieee->w.r.me_record; 1445 debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part); 1311 1446 sec->_raw_size = debug_end - ieee->w.r.debug_information_part; 1312 1447 1313 return true; 1314 } 1315 1316 1317 /*********************************************************************** 1318 * archive stuff 1319 */ 1448 return TRUE; 1449 } 1450 1451 1452 /* Archive stuff. */ 1320 1453 1321 1454 const bfd_target * … … 1329 1462 ieee_ar_data_type *save = abfd->tdata.ieee_ar_data; 1330 1463 ieee_ar_data_type *ieee; 1331 unsigned intalc_elts;1464 bfd_size_type alc_elts; 1332 1465 ieee_ar_obstack_type *elts = NULL; 1333 1334 abfd->tdata.ieee_ar_data = 1335 (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));1466 bfd_size_type amt = sizeof (ieee_ar_data_type); 1467 1468 abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt); 1336 1469 if (!abfd->tdata.ieee_ar_data) 1337 goto error_ret urn;1470 goto error_ret_restore; 1338 1471 ieee = IEEE_AR_DATA (abfd); 1339 1472 1340 /* FIXME: Check return value. I'm not sure whether it needs toread1341 the entire buffer or not. */1342 bfd_ read ((PTR) buffer, 1,sizeof (buffer), abfd);1473 /* Ignore the return value here. It doesn't matter if we don't read 1474 the entire buffer. We might have a very small ieee file. */ 1475 bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); 1343 1476 1344 1477 ieee->h.first_byte = buffer; … … 1400 1533 1401 1534 /* Make sure that we don't go over the end of the buffer. */ 1402 if ((size_t) ieee_pos ( abfd) > sizeof (buffer) / 2)1535 if ((size_t) ieee_pos (IEEE_DATA (abfd)) > sizeof (buffer) / 2) 1403 1536 { 1404 1537 /* Past half way, reseek and reprime. */ 1405 buffer_offset += ieee_pos ( abfd);1538 buffer_offset += ieee_pos (IEEE_DATA (abfd)); 1406 1539 if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0) 1407 1540 goto error_return; 1408 1541 1409 /* FIXME: Check return value. I'm not sure whether it needs 1410 to read the entire buffer or not. */ 1411 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); 1542 /* Again ignore return value of bfd_bread. */ 1543 bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); 1412 1544 ieee->h.first_byte = buffer; 1413 1545 ieee->h.input_p = buffer; … … 1415 1547 } 1416 1548 1417 ieee->elements = ((ieee_ar_obstack_type *)1418 bfd_alloc (abfd, 1419 ieee->element_count * sizeof *ieee->elements));1549 amt = ieee->element_count; 1550 amt *= sizeof *ieee->elements; 1551 ieee->elements = (ieee_ar_obstack_type *) bfd_alloc (abfd, amt); 1420 1552 if (ieee->elements == NULL) 1421 1553 goto error_return; 1422 1554 1423 memcpy (ieee->elements, elts, 1424 ieee->element_count * sizeof *ieee->elements); 1555 memcpy (ieee->elements, elts, (size_t) amt); 1425 1556 free (elts); 1426 1557 elts = NULL; … … 1432 1563 goto error_return; 1433 1564 1434 /* FIXME: Check return value. I'm not sure whether it needs to 1435 read the entire buffer or not. */ 1436 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); 1565 /* Again ignore return value of bfd_bread. */ 1566 bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); 1437 1567 ieee->h.first_byte = buffer; 1438 1568 ieee->h.input_p = buffer; … … 1441 1571 next_byte (&(ieee->h)); /* Drop 14. */ 1442 1572 must_parse_int (&(ieee->h)); /* Drop size of block. */ 1443 1573 1444 1574 if (must_parse_int (&(ieee->h)) != 0) 1445 1575 /* This object has been deleted. */ … … 1454 1584 1455 1585 got_wrong_format_error: 1456 bfd_release (abfd, ieee);1457 abfd->tdata.ieee_ar_data = save;1458 1586 bfd_set_error (bfd_error_wrong_format); 1459 1460 1587 error_return: 1461 1588 if (elts != NULL) 1462 1589 free (elts); 1590 bfd_release (abfd, ieee); 1591 error_ret_restore: 1592 abfd->tdata.ieee_ar_data = save; 1463 1593 1464 1594 return NULL; 1465 }1466 1467 static boolean1468 ieee_mkobject (abfd)1469 bfd *abfd;1470 {1471 abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));1472 return abfd->tdata.ieee_data ? true : false;1473 1595 } 1474 1596 … … 1482 1604 unsigned char buffer[300]; 1483 1605 ieee_data_type *save = IEEE_DATA (abfd); 1606 bfd_size_type amt; 1484 1607 1485 1608 abfd->tdata.ieee_data = 0; … … 1489 1612 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 1490 1613 goto fail; 1491 /* Read the first few bytes in to see if it makes sense */ 1492 /* FIXME: Check return value. I'm not sure whether it needs to read 1493 the entire buffer or not. */ 1494 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); 1614 /* Read the first few bytes in to see if it makes sense. Ignore 1615 bfd_bread return value; The file might be very small. */ 1616 bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); 1495 1617 1496 1618 ieee->h.input_p = buffer; … … 1498 1620 goto got_wrong_format; 1499 1621 1500 ieee->read_symbols = false;1501 ieee->read_data = false;1622 ieee->read_symbols = FALSE; 1623 ieee->read_data = FALSE; 1502 1624 ieee->section_count = 0; 1503 1625 ieee->external_symbol_max_index = 0; … … 1513 1635 goto got_wrong_format; 1514 1636 ieee->mb.module_name = read_id (&(ieee->h)); 1515 if (abfd->filename == (CONST char *) NULL) 1516 { 1517 abfd->filename = ieee->mb.module_name; 1518 } 1519 /* Determine the architecture and machine type of the object file. 1520 */ 1637 if (abfd->filename == (const char *) NULL) 1638 abfd->filename = ieee->mb.module_name; 1639 1640 /* Determine the architecture and machine type of the object file. */ 1521 1641 { 1522 1642 const bfd_arch_info_type *arch; … … 1557 1677 } 1558 1678 } 1559 else if ( toupper (processor[3]) == 'F')/* 68F333 */1560 strcpy (family, "68332"); /* CPU32 */1561 else if (( toupper (processor[3]) == 'C') /* Embedded controllers*/1562 && (( toupper(processor[2]) == 'E')1563 || ( toupper(processor[2]) == 'H')1564 || ( toupper(processor[2]) == 'L')))1679 else if (TOUPPER (processor[3]) == 'F') /* 68F333 */ 1680 strcpy (family, "68332"); /* CPU32 */ 1681 else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */ 1682 && ((TOUPPER (processor[2]) == 'E') 1683 || (TOUPPER (processor[2]) == 'H') 1684 || (TOUPPER (processor[2]) == 'L'))) 1565 1685 { 1566 1686 strcpy (family, "68"); … … 1568 1688 family[9] = '\0'; 1569 1689 } 1570 else /* "Regular" processors */1690 else /* "Regular" processors. */ 1571 1691 { 1572 1692 strncpy (family, processor, 9); … … 1590 1710 1591 1711 if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum) 1592 { 1593 goto fail; 1594 } 1712 goto fail; 1713 1595 1714 next_byte (&(ieee->h)); 1596 1715 1597 if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false) 1598 { 1599 goto fail; 1600 } 1601 if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false) 1602 { 1603 goto fail; 1604 } 1605 1606 /* If there is a byte order info, take it */ 1607 if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum || 1608 this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) 1716 if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau)) 1717 goto fail; 1718 1719 if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address)) 1720 goto fail; 1721 1722 /* If there is a byte order info, take it. */ 1723 if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum 1724 || this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) 1609 1725 next_byte (&(ieee->h)); 1610 1726 1611 1727 for (part = 0; part < N_W_VARIABLES; part++) 1612 1728 { 1613 boolean ok; 1729 bfd_boolean ok; 1730 1614 1731 if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) 1615 { 1616 goto fail; 1617 } 1732 goto fail; 1733 1618 1734 if (this_byte_and_next (&(ieee->h)) != part) 1619 { 1620 goto fail; 1621 } 1735 goto fail; 1622 1736 1623 1737 ieee->w.offset[part] = parse_i (&(ieee->h), &ok); 1624 if (ok == false) 1625 { 1626 goto fail; 1627 } 1628 1738 if (! ok) 1739 goto fail; 1629 1740 } 1630 1741 … … 1635 1746 the whole thing into memory so that we can run up and down it 1636 1747 quickly. We can work out how big the file is from the trailer 1637 record */ 1638 1748 record. */ 1749 1750 amt = ieee->w.r.me_record + 1; 1639 1751 IEEE_DATA (abfd)->h.first_byte = 1640 (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);1752 (unsigned char *) bfd_alloc (ieee->h.abfd, amt); 1641 1753 if (!IEEE_DATA (abfd)->h.first_byte) 1642 1754 goto fail; … … 1645 1757 /* FIXME: Check return value. I'm not sure whether it needs to read 1646 1758 the entire buffer or not. */ 1647 bfd_ read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,1648 ieee->w.r.me_record + 1, abfd);1759 bfd_bread ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1760 (bfd_size_type) ieee->w.r.me_record + 1, abfd); 1649 1761 1650 1762 ieee_slurp_sections (abfd); … … 1655 1767 /* Parse section data to activate file and section flags implied by 1656 1768 section contents. */ 1657 1658 1769 if (! ieee_slurp_section_data (abfd)) 1659 1770 goto fail; 1660 1771 1661 1772 return abfd->xvec; 1662 1773 got_wrong_format: 1663 1774 bfd_set_error (bfd_error_wrong_format); 1664 1775 fail: 1665 (void)bfd_release (abfd, ieee);1776 bfd_release (abfd, ieee); 1666 1777 abfd->tdata.ieee_data = save; 1667 1778 return (const bfd_target *) NULL; 1668 1779 } 1669 1780 1670 void1781 static void 1671 1782 ieee_get_symbol_info (ignore_abfd, symbol, ret) 1672 1783 bfd *ignore_abfd ATTRIBUTE_UNUSED; … … 1681 1792 } 1682 1793 1683 void1684 ieee_print_symbol ( ignore_abfd, afile, symbol, how)1685 bfd * ignore_abfd ATTRIBUTE_UNUSED;1794 static void 1795 ieee_print_symbol (abfd, afile, symbol, how) 1796 bfd *abfd; 1686 1797 PTR afile; 1687 1798 asymbol *symbol; … … 1708 1819 ? "*abs" 1709 1820 : symbol->section->name); 1821 1710 1822 if (symbol->name[0] == ' ') 1711 1823 { … … 1714 1826 else 1715 1827 { 1716 bfd_print_symbol_vandf ( (PTR) file, symbol);1828 bfd_print_symbol_vandf (abfd, (PTR) file, symbol); 1717 1829 1718 1830 fprintf (file, " %-5s %04x %02x %s", … … 1727 1839 } 1728 1840 1729 static b oolean1841 static bfd_boolean 1730 1842 do_one (ieee, current_map, location_ptr, s, iterations) 1731 1843 ieee_data_type *ieee; … … 1741 1853 unsigned int number_of_maus; 1742 1854 unsigned int i; 1855 1743 1856 next_byte (&(ieee->h)); 1744 1857 number_of_maus = must_parse_int (&(ieee->h)); … … 1754 1867 case ieee_load_with_relocation_enum: 1755 1868 { 1756 boolean loop = true; 1869 bfd_boolean loop = TRUE; 1870 1757 1871 next_byte (&(ieee->h)); 1758 1872 while (loop) … … 1767 1881 { 1768 1882 unsigned int extra = 4; 1769 b oolean pcrel = false;1883 bfd_boolean pcrel = FALSE; 1770 1884 asection *section; 1771 ieee_reloc_type *r = 1772 (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, 1773 sizeof (ieee_reloc_type)); 1885 ieee_reloc_type *r; 1886 bfd_size_type amt = sizeof (ieee_reloc_type); 1887 1888 r = (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, amt); 1774 1889 if (!r) 1775 return false;1890 return FALSE; 1776 1891 1777 1892 *(current_map->reloc_tail_ptr) = r; … … 1795 1910 { 1796 1911 next_byte (&(ieee->h)); 1797 /* Fetch number of bytes to pad */1912 /* Fetch number of bytes to pad. */ 1798 1913 extra = must_parse_int (&(ieee->h)); 1799 1914 }; … … 1813 1928 break; 1814 1929 } 1815 /* Build a relocation entry for this type */1930 /* Build a relocation entry for this type. */ 1816 1931 /* If pc rel then stick -ve pc into instruction 1817 1932 and take out of reloc .. … … 1825 1940 case 4: 1826 1941 1827 if (pcrel == true)1942 if (pcrel) 1828 1943 { 1829 1944 #if KEEPMINUSPCININST 1830 bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr +1831 current_map->pc);1945 bfd_put_32 (ieee->h.abfd, -current_map->pc, 1946 location_ptr + current_map->pc); 1832 1947 r->relent.howto = &rel32_howto; 1833 r->relent.addend -= 1834 current_map->pc; 1948 r->relent.addend -= current_map->pc; 1835 1949 #else 1836 bfd_put_32 (ieee->h.abfd, 0, location_ptr +1950 bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, location_ptr + 1837 1951 current_map->pc); 1838 1952 r->relent.howto = &rel32_howto; … … 1841 1955 else 1842 1956 { 1843 bfd_put_32 (ieee->h.abfd, 0, location_ptr +1844 current_map->pc);1957 bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, 1958 location_ptr + current_map->pc); 1845 1959 r->relent.howto = &abs32_howto; 1846 1960 } … … 1848 1962 break; 1849 1963 case 2: 1850 if (pcrel == true)1964 if (pcrel) 1851 1965 { 1852 1966 #if KEEPMINUSPCININST 1853 bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc); 1967 bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc, 1968 location_ptr + current_map->pc); 1854 1969 r->relent.addend -= current_map->pc; 1855 1970 r->relent.howto = &rel16_howto; 1856 1971 #else 1857 1972 1858 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc); 1973 bfd_put_16 (ieee->h.abfd, (bfd_vma) 0, 1974 location_ptr + current_map->pc); 1859 1975 r->relent.howto = &rel16_howto; 1860 1976 #endif … … 1863 1979 else 1864 1980 { 1865 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc); 1981 bfd_put_16 (ieee->h.abfd, (bfd_vma) 0, 1982 location_ptr + current_map->pc); 1866 1983 r->relent.howto = &abs16_howto; 1867 1984 } … … 1869 1986 break; 1870 1987 case 1: 1871 if (pcrel == true)1988 if (pcrel) 1872 1989 { 1873 1990 #if KEEPMINUSPCININST … … 1890 2007 default: 1891 2008 BFD_FAIL (); 1892 return false;2009 return FALSE; 1893 2010 } 1894 2011 } … … 1897 2014 { 1898 2015 bfd_vma this_size; 1899 if (parse_int (&(ieee->h), &this_size) == true)2016 if (parse_int (&(ieee->h), &this_size)) 1900 2017 { 1901 2018 unsigned int i; … … 1908 2025 else 1909 2026 { 1910 loop = false;2027 loop = FALSE; 1911 2028 } 1912 2029 } … … 1916 2033 from being repeated (MRI convention). */ 1917 2034 if (iterations != 1) 1918 loop = false;2035 loop = FALSE; 1919 2036 } 1920 2037 } 1921 2038 } 1922 return true; 1923 } 1924 1925 /* Read in all the section data and relocation stuff too */ 1926 static boolean 2039 return TRUE; 2040 } 2041 2042 /* Read in all the section data and relocation stuff too. */ 2043 2044 static bfd_boolean 1927 2045 ieee_slurp_section_data (abfd) 1928 2046 bfd *abfd; … … 1934 2052 ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; 1935 2053 asection *s; 1936 /* Seek to the start of the data area */ 1937 if (ieee->read_data == true) 1938 return true; 1939 ieee->read_data = true; 1940 ieee_seek (abfd, ieee->w.r.data_part); 1941 1942 /* Allocate enough space for all the section contents */ 1943 2054 /* Seek to the start of the data area. */ 2055 if (ieee->read_data) 2056 return TRUE; 2057 ieee->read_data = TRUE; 2058 ieee_seek (ieee, ieee->w.r.data_part); 2059 2060 /* Allocate enough space for all the section contents. */ 1944 2061 for (s = abfd->sections; s != (asection *) NULL; s = s->next) 1945 2062 { 1946 ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;2063 ieee_per_section_type *per = ieee_per_section (s); 1947 2064 if ((s->flags & SEC_DEBUGGING) != 0) 1948 2065 continue; 1949 2066 per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size); 1950 2067 if (!per->data) 1951 return false; 1952 /*SUPPRESS 68*/ 2068 return FALSE; 1953 2069 per->reloc_tail_ptr = 1954 2070 (ieee_reloc_type **) & (s->relocation); 1955 2071 } 1956 2072 1957 while ( true)2073 while (TRUE) 1958 2074 { 1959 2075 switch (this_byte (&(ieee->h))) 1960 2076 { 1961 /* IF we see anything strange then quit */2077 /* IF we see anything strange then quit. */ 1962 2078 default: 1963 return true;2079 return TRUE; 1964 2080 1965 2081 case ieee_set_current_section_enum: … … 1968 2084 s = ieee->section_table[section_number]; 1969 2085 s->flags |= SEC_LOAD | SEC_HAS_CONTENTS; 1970 current_map = (ieee_per_section_type *) s->used_by_bfd;2086 current_map = ieee_per_section (s); 1971 2087 location_ptr = current_map->data - s->vma; 1972 /* The document I have says that Microtec's compilers reset */1973 /* this after a sec section, even though the standard says not */1974 /* to. SO ..*/2088 /* The document I have says that Microtec's compilers reset 2089 this after a sec section, even though the standard says not 2090 to, SO... */ 1975 2091 current_map->pc = s->vma; 1976 2092 break; … … 1985 2101 ieee_symbol_index_type symbol; 1986 2102 unsigned int extra; 1987 boolean pcrel; 2103 bfd_boolean pcrel; 2104 1988 2105 next_byte (&(ieee->h)); 1989 must_parse_int (&(ieee->h)); /* Th ow away section #*/2106 must_parse_int (&(ieee->h)); /* Throw away section #. */ 1990 2107 parse_expression (ieee, &value, 1991 2108 &symbol, … … 2002 2119 next_byte (&(ieee->h)); 2003 2120 abfd->start_address = must_parse_int (&(ieee->h)); 2004 /* We've got to the end of the data now - */2005 return true;2121 /* We've got to the end of the data now - */ 2122 return TRUE; 2006 2123 default: 2007 2124 BFD_FAIL (); 2008 return false;2125 return FALSE; 2009 2126 } 2010 2127 break; … … 2012 2129 { 2013 2130 /* Repeat the following LD or LR n times - we do this by 2014 remembering the stream pointer before running it and 2015 resetting it and running it n times. We special case 2016 the repetition of a repeat_data/load_constant 2017 */ 2018 2131 remembering the stream pointer before running it and 2132 resetting it and running it n times. We special case 2133 the repetition of a repeat_data/load_constant. */ 2019 2134 unsigned int iterations; 2020 2135 unsigned char *start; 2136 2021 2137 next_byte (&(ieee->h)); 2022 2138 iterations = must_parse_int (&(ieee->h)); 2023 2139 start = ieee->h.input_p; 2024 if (start[0] == (int) ieee_load_constant_bytes_enum &&2025 start[1] == 1)2140 if (start[0] == (int) ieee_load_constant_bytes_enum 2141 && start[1] == 1) 2026 2142 { 2027 2143 while (iterations != 0) … … 2040 2156 ieee->h.input_p = start; 2041 2157 if (!do_one (ieee, current_map, location_ptr, s, 2042 iterations))2043 return false;2158 (int) iterations)) 2159 return FALSE; 2044 2160 iterations--; 2045 2161 } … … 2049 2165 case ieee_load_constant_bytes_enum: 2050 2166 case ieee_load_with_relocation_enum: 2051 { 2052 if (!do_one (ieee, current_map, location_ptr, s, 1)) 2053 return false; 2054 } 2167 if (!do_one (ieee, current_map, location_ptr, s, 1)) 2168 return FALSE; 2055 2169 } 2056 2170 } 2057 2171 } 2058 2172 2059 boolean2173 static bfd_boolean 2060 2174 ieee_new_section_hook (abfd, newsect) 2061 2175 bfd *abfd; 2062 2176 asection *newsect; 2063 2177 { 2064 newsect->used_by_bfd = (PTR)2065 bfd_alloc (abfd,sizeof (ieee_per_section_type));2178 newsect->used_by_bfd 2179 = (PTR) bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type)); 2066 2180 if (!newsect->used_by_bfd) 2067 return false;2181 return FALSE; 2068 2182 ieee_per_section (newsect)->data = (bfd_byte *) NULL; 2069 2183 ieee_per_section (newsect)->section = newsect; 2070 return true;2071 } 2072 2073 long2184 return TRUE; 2185 } 2186 2187 static long 2074 2188 ieee_get_reloc_upper_bound (abfd, asect) 2075 2189 bfd *abfd; … … 2083 2197 } 2084 2198 2085 static b oolean2199 static bfd_boolean 2086 2200 ieee_get_section_contents (abfd, section, location, offset, count) 2087 2201 bfd *abfd; … … 2091 2205 bfd_size_type count; 2092 2206 { 2093 ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;2207 ieee_per_section_type *p = ieee_per_section (section); 2094 2208 if ((section->flags & SEC_DEBUGGING) != 0) 2095 2209 return _bfd_generic_get_section_contents (abfd, section, location, … … 2097 2211 ieee_slurp_section_data (abfd); 2098 2212 (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count); 2099 return true;2100 } 2101 2102 long2213 return TRUE; 2214 } 2215 2216 static long 2103 2217 ieee_canonicalize_reloc (abfd, section, relptr, symbols) 2104 2218 bfd *abfd; … … 2107 2221 asymbol **symbols; 2108 2222 { 2109 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/2110 2223 ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); 2111 2224 ieee_data_type *ieee = IEEE_DATA (abfd); … … 2116 2229 while (src != (ieee_reloc_type *) NULL) 2117 2230 { 2118 /* Work out which symbol to attach it this reloc to */2231 /* Work out which symbol to attach it this reloc to. */ 2119 2232 switch (src->symbol.letter) 2120 2233 { … … 2145 2258 static int 2146 2259 comp (ap, bp) 2147 CONSTPTR ap;2148 CONSTPTR bp;2260 const PTR ap; 2261 const PTR bp; 2149 2262 { 2150 2263 arelent *a = *((arelent **) ap); … … 2155 2268 /* Write the section headers. */ 2156 2269 2157 static b oolean2270 static bfd_boolean 2158 2271 ieee_write_section_part (abfd) 2159 2272 bfd *abfd; … … 2171 2284 (bfd_byte) (s->index 2172 2285 + IEEE_SECTION_NUMBER_BASE))) 2173 return false;2286 return FALSE; 2174 2287 2175 2288 if (abfd->flags & EXEC_P) 2176 2289 { 2177 /* This image is executable, so output absolute sections */2290 /* This image is executable, so output absolute sections. */ 2178 2291 if (! ieee_write_byte (abfd, ieee_variable_A_enum) 2179 2292 || ! ieee_write_byte (abfd, ieee_variable_S_enum)) 2180 return false;2293 return FALSE; 2181 2294 } 2182 2295 else 2183 2296 { 2184 2297 if (! ieee_write_byte (abfd, ieee_variable_C_enum)) 2185 return false;2298 return FALSE; 2186 2299 } 2187 2300 … … 2191 2304 case SEC_CODE: 2192 2305 if (! ieee_write_byte (abfd, ieee_variable_P_enum)) 2193 return false;2306 return FALSE; 2194 2307 break; 2195 2308 case SEC_DATA: 2196 2309 default: 2197 2310 if (! ieee_write_byte (abfd, ieee_variable_D_enum)) 2198 return false;2311 return FALSE; 2199 2312 break; 2200 2313 case SEC_ROM: … … 2203 2316 case SEC_ROM | SEC_DATA | SEC_LOAD: 2204 2317 if (! ieee_write_byte (abfd, ieee_variable_R_enum)) 2205 return false;2318 return FALSE; 2206 2319 } 2207 2320 2208 2321 2209 2322 if (! ieee_write_id (abfd, s->name)) 2210 return false;2323 return FALSE; 2211 2324 #if 0 2212 2325 ieee_write_int (abfd, 0); /* Parent */ … … 2214 2327 ieee_write_int (abfd, 0); /* Context */ 2215 2328 #endif 2216 /* Alignment */2329 /* Alignment. */ 2217 2330 if (! ieee_write_byte (abfd, ieee_section_alignment_enum) 2218 2331 || ! ieee_write_byte (abfd, 2219 2332 (bfd_byte) (s->index 2220 2333 + IEEE_SECTION_NUMBER_BASE)) 2221 || ! ieee_write_int (abfd, 1 << s->alignment_power))2222 return false;2223 2224 /* Size */2334 || ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power)) 2335 return FALSE; 2336 2337 /* Size. */ 2225 2338 if (! ieee_write_2bytes (abfd, ieee_section_size_enum) 2226 2339 || ! ieee_write_byte (abfd, … … 2228 2341 + IEEE_SECTION_NUMBER_BASE)) 2229 2342 || ! ieee_write_int (abfd, s->_raw_size)) 2230 return false;2343 return FALSE; 2231 2344 if (abfd->flags & EXEC_P) 2232 2345 { 2233 /* Relocateable sections don't have asl records */2234 /* Vma */2346 /* Relocateable sections don't have asl records. */ 2347 /* Vma. */ 2235 2348 if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum) 2236 2349 || ! ieee_write_byte (abfd, … … 2239 2352 + IEEE_SECTION_NUMBER_BASE))) 2240 2353 || ! ieee_write_int (abfd, s->lma)) 2241 return false;2354 return FALSE; 2242 2355 } 2243 2356 } 2244 2357 } 2245 2358 2246 return true;2247 } 2248 2249 2250 static b oolean2359 return TRUE; 2360 } 2361 2362 2363 static bfd_boolean 2251 2364 do_with_relocs (abfd, s) 2252 2365 bfd *abfd; … … 2265 2378 comp); 2266 2379 2267 /* Output the section preheader */2380 /* Output the section preheader. */ 2268 2381 if (! ieee_write_byte (abfd, ieee_set_current_section_enum) 2269 2382 || ! ieee_write_byte (abfd, … … 2272 2385 || ! ieee_write_byte (abfd, 2273 2386 (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))) 2274 return false; 2387 return FALSE; 2388 2275 2389 if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0) 2276 2390 { 2277 2391 if (! ieee_write_int (abfd, s->lma)) 2278 return false;2392 return FALSE; 2279 2393 } 2280 2394 else 2281 2395 { 2282 if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))2283 return false;2396 if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) 2397 return FALSE; 2284 2398 } 2285 2399 … … 2287 2401 { 2288 2402 /* If there aren't any relocations then output the load constant 2289 byte opcode rather than the load with relocation opcode */ 2290 2403 byte opcode rather than the load with relocation opcode. */ 2291 2404 while (current_byte_index < s->_raw_size) 2292 2405 { 2293 2406 bfd_size_type run; 2294 2407 unsigned int MAXRUN = 127; 2408 2295 2409 run = MAXRUN; 2296 2410 if (run > s->_raw_size - current_byte_index) 2297 { 2298 run = s->_raw_size - current_byte_index; 2299 } 2411 run = s->_raw_size - current_byte_index; 2300 2412 2301 2413 if (run != 0) 2302 2414 { 2303 2415 if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)) 2304 return false;2305 /* Output a stream of bytes */2416 return FALSE; 2417 /* Output a stream of bytes. */ 2306 2418 if (! ieee_write_int (abfd, run)) 2307 return false; 2308 if (bfd_write ((PTR) (stream + current_byte_index), 2309 1, 2310 run, 2311 abfd) 2419 return FALSE; 2420 if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) 2312 2421 != run) 2313 return false;2422 return FALSE; 2314 2423 current_byte_index += run; 2315 2424 } … … 2319 2428 { 2320 2429 if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum)) 2321 return false;2430 return FALSE; 2322 2431 2323 2432 /* Output the data stream as the longest sequence of bytes … … 2327 2436 if ((PTR) stream == (PTR) NULL) 2328 2437 { 2329 /* Outputting a section without data, fill it up */2330 stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));2438 /* Outputting a section without data, fill it up. */ 2439 stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size); 2331 2440 if (!stream) 2332 return false; 2333 memset ((PTR) stream, 0, (size_t) s->_raw_size); 2441 return FALSE; 2334 2442 } 2335 2443 while (current_byte_index < s->_raw_size) … … 2337 2445 bfd_size_type run; 2338 2446 unsigned int MAXRUN = 127; 2447 2339 2448 if (relocs_to_go) 2340 2449 { … … 2344 2453 } 2345 2454 else 2346 { 2347 run = MAXRUN; 2348 } 2455 run = MAXRUN; 2456 2349 2457 if (run > s->_raw_size - current_byte_index) 2350 { 2351 run = s->_raw_size - current_byte_index; 2352 } 2458 run = s->_raw_size - current_byte_index; 2353 2459 2354 2460 if (run != 0) 2355 2461 { 2356 /* Output a stream of bytes */2462 /* Output a stream of bytes. */ 2357 2463 if (! ieee_write_int (abfd, run)) 2358 return false; 2359 if (bfd_write ((PTR) (stream + current_byte_index), 2360 1, 2361 run, 2362 abfd) 2464 return FALSE; 2465 if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) 2363 2466 != run) 2364 return false;2467 return FALSE; 2365 2468 current_byte_index += run; 2366 2469 } 2367 /* Output any relocations here */ 2470 2471 /* Output any relocations here. */ 2368 2472 if (relocs_to_go && (*p) && (*p)->address == current_byte_index) 2369 2473 { … … 2373 2477 arelent *r = *p; 2374 2478 bfd_signed_vma ov; 2375 2376 2479 #if 0 2377 2480 if (r->howto->pc_relative) 2378 { 2379 r->addend += current_byte_index; 2380 } 2481 r->addend += current_byte_index; 2381 2482 #endif 2382 2383 2483 switch (r->howto->size) 2384 2484 { … … 2402 2502 ov = 0; 2403 2503 BFD_FAIL (); 2404 return false;2504 return FALSE; 2405 2505 } 2406 2506 … … 2413 2513 if (! ieee_write_byte (abfd, 2414 2514 ieee_function_either_open_b_enum)) 2415 return false;2515 return FALSE; 2416 2516 2417 2517 /* abort();*/ … … 2422 2522 *(r->sym_ptr_ptr), 2423 2523 r->howto->pc_relative, 2424 s->index))2425 return false;2524 (unsigned) s->index)) 2525 return FALSE; 2426 2526 } 2427 2527 else … … 2430 2530 (asymbol *) NULL, 2431 2531 r->howto->pc_relative, 2432 s->index))2433 return false;2532 (unsigned) s->index)) 2533 return FALSE; 2434 2534 } 2435 2535 … … 2437 2537 != bfd_get_reloc_size (r->howto)) 2438 2538 { 2439 if (! ieee_write_int (abfd,2440 bfd_get_reloc_size (r->howto)))2441 return false;2539 bfd_vma rsize = bfd_get_reloc_size (r->howto); 2540 if (! ieee_write_int (abfd, rsize)) 2541 return FALSE; 2442 2542 } 2443 2543 if (! ieee_write_byte (abfd, 2444 2544 ieee_function_either_close_b_enum)) 2445 return false;2545 return FALSE; 2446 2546 2447 2547 relocs_to_go--; … … 2453 2553 } 2454 2554 2455 return true;2555 return TRUE; 2456 2556 } 2457 2557 … … 2460 2560 bytes. */ 2461 2561 2462 static b oolean2562 static bfd_boolean 2463 2563 do_as_repeat (abfd, s) 2464 2564 bfd *abfd; … … 2475 2575 || ! ieee_write_byte (abfd, 2476 2576 (bfd_byte) (s->index 2477 + IEEE_SECTION_NUMBER_BASE)) 2478 || ! ieee_write_int (abfd, s->lma) 2479 || ! ieee_write_byte (abfd, ieee_repeat_data_enum) 2577 + IEEE_SECTION_NUMBER_BASE))) 2578 return FALSE; 2579 2580 if ((abfd->flags & EXEC_P) != 0) 2581 { 2582 if (! ieee_write_int (abfd, s->lma)) 2583 return FALSE; 2584 } 2585 else 2586 { 2587 if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0)) 2588 return FALSE; 2589 } 2590 2591 if (! ieee_write_byte (abfd, ieee_repeat_data_enum) 2480 2592 || ! ieee_write_int (abfd, s->_raw_size) 2481 2593 || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) 2482 2594 || ! ieee_write_byte (abfd, 1) 2483 2595 || ! ieee_write_byte (abfd, 0)) 2484 return false;2485 } 2486 2487 return true;2488 } 2489 2490 static b oolean2596 return FALSE; 2597 } 2598 2599 return TRUE; 2600 } 2601 2602 static bfd_boolean 2491 2603 do_without_relocs (abfd, s) 2492 2604 bfd *abfd; … … 2498 2610 { 2499 2611 if (! do_as_repeat (abfd, s)) 2500 return false;2612 return FALSE; 2501 2613 } 2502 2614 else 2503 2615 { 2504 2616 unsigned int i; 2617 2505 2618 for (i = 0; i < s->_raw_size; i++) 2506 2619 { … … 2508 2621 { 2509 2622 if (! do_with_relocs (abfd, s)) 2510 return false;2511 return true;2623 return FALSE; 2624 return TRUE; 2512 2625 } 2513 2626 } 2514 2627 if (! do_as_repeat (abfd, s)) 2515 return false;2516 } 2517 2518 return true;2628 return FALSE; 2629 } 2630 2631 return TRUE; 2519 2632 } 2520 2633 … … 2530 2643 static int output_buffer; 2531 2644 2645 static bfd_boolean 2646 ieee_mkobject (abfd) 2647 bfd *abfd; 2648 { 2649 bfd_size_type amt; 2650 2651 output_ptr_start = NULL; 2652 output_ptr = NULL; 2653 output_ptr_end = NULL; 2654 input_ptr_start = NULL; 2655 input_ptr = NULL; 2656 input_ptr_end = NULL; 2657 input_bfd = NULL; 2658 output_bfd = NULL; 2659 output_buffer = 0; 2660 amt = sizeof (ieee_data_type); 2661 abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, amt); 2662 return abfd->tdata.ieee_data != NULL; 2663 } 2664 2532 2665 static void 2533 2666 fill () 2534 2667 { 2668 bfd_size_type amt = input_ptr_end - input_ptr_start; 2535 2669 /* FIXME: Check return value. I'm not sure whether it needs to read 2536 2670 the entire buffer or not. */ 2537 bfd_ read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);2671 bfd_bread ((PTR) input_ptr_start, amt, input_bfd); 2538 2672 input_ptr = input_ptr_start; 2539 2673 } 2674 2540 2675 static void 2541 2676 flush () 2542 2677 { 2543 if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,2544 output_bfd) 2545 != (bfd_size_type) (output_ptr - output_ptr_start))2678 bfd_size_type amt = output_ptr - output_ptr_start; 2679 2680 if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt) 2546 2681 abort (); 2547 2682 output_ptr = output_ptr_start; … … 2564 2699 { 2565 2700 unsigned int length; 2566 /* How many significant bytes ? */2567 /* FIXME FOR LONGER INTS */2701 /* How many significant bytes ? */ 2702 /* FIXME FOR LONGER INTS. */ 2568 2703 if (value & 0xff000000) 2569 { 2570 length = 4; 2571 } 2704 length = 4; 2572 2705 else if (value & 0x00ff0000) 2573 { 2574 length = 3; 2575 } 2706 length = 3; 2576 2707 else if (value & 0x0000ff00) 2577 { 2578 length = 2; 2579 } 2708 length = 2; 2580 2709 else 2581 2710 length = 1; … … 2593 2722 OUT (value); 2594 2723 } 2595 2596 2724 } 2597 2725 } … … 2602 2730 int length = THIS (); 2603 2731 char ch; 2732 2604 2733 OUT (length); 2605 2734 NEXT (); … … 2618 2747 int stack[10]; 2619 2748 int *tos = stack; 2620 int value = 0; 2749 int value; 2750 2621 2751 while (1) 2622 2752 { … … 2666 2796 if (THIS () > 0x84) 2667 2797 { 2668 /* Not a number, just bug out with the answer */2798 /* Not a number, just bug out with the answer. */ 2669 2799 write_int (*(--tos)); 2670 2800 return; … … 2672 2802 *tos++ = THIS (); 2673 2803 NEXT (); 2674 value = 0;2675 2804 break; 2676 2805 case 0xa5: 2677 /* PLUS anything */ 2678 { 2679 int value = *(--tos); 2680 value += *(--tos); 2681 *tos++ = value; 2682 NEXT (); 2683 } 2806 /* PLUS anything. */ 2807 value = *(--tos); 2808 value += *(--tos); 2809 *tos++ = value; 2810 NEXT (); 2684 2811 break; 2685 2812 case VAR ('R'): … … 2688 2815 ieee_data_type *ieee; 2689 2816 asection *s; 2817 2690 2818 NEXT (); 2691 2819 section_number = THIS (); … … 2694 2822 ieee = IEEE_DATA (input_bfd); 2695 2823 s = ieee->section_table[section_number]; 2824 value = 0; 2696 2825 if (s->output_section) 2697 { 2698 value = s->output_section->lma; 2699 } 2700 else 2701 { 2702 value = 0; 2703 } 2826 value = s->output_section->lma; 2704 2827 value += s->output_offset; 2705 2828 *tos++ = value; 2706 value = 0;2707 2829 } 2708 2830 break; … … 2713 2835 OUT (0x90); 2714 2836 return; 2715 2716 2837 } 2717 2838 } 2718 2839 } 2719 2720 2840 } 2721 2841 2722 2842 /* Drop the int in the buffer, and copy a null into the gap, which we 2723 2843 will overwrite later */ 2724 2725 struct output_buffer_struct2726 {2727 unsigned char *ptrp;2728 int buffer;2729 };2730 2844 2731 2845 static void … … 2735 2849 if (buf->buffer == output_buffer) 2736 2850 { 2737 /* Still a chance to output the size */2851 /* Still a chance to output the size. */ 2738 2852 int value = output_ptr - buf->ptrp + 3; 2739 2853 buf->ptrp[0] = value >> 24; … … 2750 2864 int type = THIS (); 2751 2865 int ch; 2866 2752 2867 if (type <= 0x84) 2753 2868 { … … 2816 2931 #define INT copy_int() 2817 2932 #define EXP copy_expression() 2818 static void copy_till_end ();2819 2933 #define INTn(q) copy_int() 2820 2934 #define EXPn(q) copy_expression() … … 2824 2938 { 2825 2939 int ch; 2826 /* ATN record */ 2940 2941 /* ATN record. */ 2827 2942 NEXT (); 2828 2943 ch = THIS (); … … 2864 2979 break; 2865 2980 case 0xd8: 2866 /* EXternal ref */2981 /* EXternal ref. */ 2867 2982 NEXT (); 2868 2983 OUT (0xf1); … … 2918 3033 } 2919 3034 } 2920 2921 3035 } 2922 3036 … … 2924 3038 f0_record () 2925 3039 { 2926 /* Attribute record */3040 /* Attribute record. */ 2927 3041 NEXT (); 2928 3042 OUT (0xf0); … … 2935 3049 { 2936 3050 int ch = THIS (); 3051 2937 3052 while (1) 2938 3053 { … … 2982 3097 2983 3098 2984 static void block ();2985 3099 static void 2986 3100 f8_record () … … 2994 3108 case 0x02: 2995 3109 case 0x03: 2996 /* Unique typedefs for module */2997 /* GLobal typedefs */2998 /* High level module scope beginning */3110 /* Unique typedefs for module. */ 3111 /* GLobal typedefs. */ 3112 /* High level module scope beginning. */ 2999 3113 { 3000 3114 struct output_buffer_struct ob; 3115 3001 3116 NEXT (); 3002 3117 OUT (0xf8); … … 3013 3128 break; 3014 3129 case 0x04: 3015 /* Global function */3130 /* Global function. */ 3016 3131 { 3017 3132 struct output_buffer_struct ob; 3133 3018 3134 NEXT (); 3019 3135 OUT (0xf8); … … 3035 3151 3036 3152 case 0x05: 3037 /* File name for source line numbers */3153 /* File name for source line numbers. */ 3038 3154 { 3039 3155 struct output_buffer_struct ob; 3156 3040 3157 NEXT (); 3041 3158 OUT (0xf8); … … 3057 3174 3058 3175 case 0x06: 3059 /* Local function */3176 /* Local function. */ 3060 3177 { 3061 3178 struct output_buffer_struct ob; 3179 3062 3180 NEXT (); 3063 3181 OUT (0xf8); … … 3077 3195 3078 3196 case 0x0a: 3079 /* Assembler module scope beginning - */3197 /* Assembler module scope beginning - */ 3080 3198 { 3081 3199 struct output_buffer_struct ob; … … 3106 3224 { 3107 3225 struct output_buffer_struct ob; 3226 3108 3227 NEXT (); 3109 3228 OUT (0xf8); … … 3142 3261 { 3143 3262 int ch; 3263 3144 3264 while (1) 3145 3265 { … … 3173 3293 3174 3294 3175 3176 /* relocate_debug, 3177 moves all the debug information from the source bfd to the output 3178 bfd, and relocates any expressions it finds 3179 */ 3295 /* Moves all the debug information from the source bfd to the output 3296 bfd, and relocates any expressions it finds. */ 3180 3297 3181 3298 static void … … 3193 3310 /* FIXME: Check return value. I'm not sure whether it needs to read 3194 3311 the entire buffer or not. */ 3195 bfd_ read ((PTR) input_ptr_start, 1,IBS, input);3312 bfd_bread ((PTR) input_ptr_start, (bfd_size_type) IBS, input); 3196 3313 block (); 3197 3314 } … … 3200 3317 one place, relocating it and emitting it as we go. */ 3201 3318 3202 static b oolean3319 static bfd_boolean 3203 3320 ieee_write_debug_part (abfd) 3204 3321 bfd *abfd; … … 3206 3323 ieee_data_type *ieee = IEEE_DATA (abfd); 3207 3324 bfd_chain_type *chain = ieee->chain_root; 3208 unsigned char o utput_buffer[OBS];3209 b oolean some_debug = false;3325 unsigned char obuff[OBS]; 3326 bfd_boolean some_debug = FALSE; 3210 3327 file_ptr here = bfd_tell (abfd); 3211 3328 3212 output_ptr_start = output_ptr = o utput_buffer;3213 output_ptr_end = o utput_buffer+ OBS;3214 output_ptr = o utput_buffer;3329 output_ptr_start = output_ptr = obuff; 3330 output_ptr_end = obuff + OBS; 3331 output_ptr = obuff; 3215 3332 output_bfd = abfd; 3216 3333 … … 3225 3342 { 3226 3343 ieee->w.r.debug_information_part = 0; 3227 return true;3344 return TRUE; 3228 3345 } 3229 3346 3230 3347 ieee->w.r.debug_information_part = here; 3231 if (bfd_ write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)3232 return false;3348 if (bfd_bwrite (s->contents, s->_raw_size, abfd) != s->_raw_size) 3349 return FALSE; 3233 3350 } 3234 3351 else … … 3238 3355 bfd *entry = chain->this; 3239 3356 ieee_data_type *entry_ieee = IEEE_DATA (entry); 3357 3240 3358 if (entry_ieee->w.r.debug_information_part) 3241 3359 { 3242 3360 if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, 3243 SEEK_SET) 3244 != 0) 3245 return false; 3361 SEEK_SET) != 0) 3362 return FALSE; 3246 3363 relocate_debug (abfd, entry); 3247 3364 } … … 3249 3366 chain = chain->next; 3250 3367 } 3368 3251 3369 if (some_debug) 3252 { 3253 ieee->w.r.debug_information_part = here; 3254 } 3370 ieee->w.r.debug_information_part = here; 3255 3371 else 3256 { 3257 ieee->w.r.debug_information_part = 0; 3258 } 3372 ieee->w.r.debug_information_part = 0; 3259 3373 3260 3374 flush (); 3261 3375 } 3262 3376 3263 return true;3377 return TRUE; 3264 3378 } 3265 3379 3266 3380 /* Write the data in an ieee way. */ 3267 3381 3268 static b oolean3382 static bfd_boolean 3269 3383 ieee_write_data_part (abfd) 3270 3384 bfd *abfd; 3271 3385 { 3272 3386 asection *s; 3387 3273 3388 ieee_data_type *ieee = IEEE_DATA (abfd); 3274 3389 ieee->w.r.data_part = bfd_tell (abfd); 3390 3275 3391 for (s = abfd->sections; s != (asection *) NULL; s = s->next) 3276 3392 { … … 3285 3401 { 3286 3402 if (! do_with_relocs (abfd, s)) 3287 return false;3403 return FALSE; 3288 3404 } 3289 3405 else 3290 3406 { 3291 3407 if (! do_without_relocs (abfd, s)) 3292 return false;3408 return FALSE; 3293 3409 } 3294 3410 } 3295 3411 3296 return true;3297 } 3298 3299 3300 static b oolean3412 return TRUE; 3413 } 3414 3415 3416 static bfd_boolean 3301 3417 init_for_output (abfd) 3302 3418 bfd *abfd; 3303 3419 { 3304 3420 asection *s; 3421 3305 3422 for (s = abfd->sections; s != (asection *) NULL; s = s->next) 3306 3423 { … … 3309 3426 if (s->_raw_size != 0) 3310 3427 { 3311 ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size)); 3428 bfd_size_type size = s->_raw_size; 3429 ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size)); 3312 3430 if (!ieee_per_section (s)->data) 3313 return false;3431 return FALSE; 3314 3432 } 3315 3433 } 3316 return true;3317 } 3318 3319 3320 /* * exec and core file sections*/3321 3322 /* set section contents is complicated with IEEE since the format is3323 * not a byte image, but a record stream. 3324 */ 3325 boolean3434 return TRUE; 3435 } 3436 3437 3438 /* Exec and core file sections. */ 3439 3440 /* Set section contents is complicated with IEEE since the format is 3441 not a byte image, but a record stream. */ 3442 3443 static bfd_boolean 3326 3444 ieee_set_section_contents (abfd, section, location, offset, count) 3327 3445 bfd *abfd; … … 3335 3453 if (section->contents == NULL) 3336 3454 { 3337 section->contents = ((unsigned char *)3338 bfd_alloc (abfd, section->_raw_size));3455 bfd_size_type size = section->_raw_size; 3456 section->contents = (unsigned char *) bfd_alloc (abfd, size); 3339 3457 if (section->contents == NULL) 3340 return false;3458 return FALSE; 3341 3459 } 3342 3460 /* bfd_set_section_contents has already checked that everything 3343 3461 is within range. */ 3344 memcpy (section->contents + offset, location, count);3345 return true;3462 memcpy (section->contents + offset, location, (size_t) count); 3463 return TRUE; 3346 3464 } 3347 3465 … … 3349 3467 { 3350 3468 if (!init_for_output (abfd)) 3351 return false;3469 return FALSE; 3352 3470 } 3353 3471 memcpy ((PTR) (ieee_per_section (section)->data + offset), 3354 3472 (PTR) location, 3355 3473 (unsigned int) count); 3356 return true;3474 return TRUE; 3357 3475 } 3358 3476 … … 3362 3480 symbol values into indexes from the right base. */ 3363 3481 3364 static b oolean3482 static bfd_boolean 3365 3483 ieee_write_external_part (abfd) 3366 3484 bfd *abfd; … … 3368 3486 asymbol **q; 3369 3487 ieee_data_type *ieee = IEEE_DATA (abfd); 3370 3371 3488 unsigned int reference_index = IEEE_REFERENCE_BASE; 3372 3489 unsigned int public_index = IEEE_PUBLIC_BASE + 2; 3373 3490 file_ptr here = bfd_tell (abfd); 3374 boolean hadone = false; 3491 bfd_boolean hadone = FALSE; 3492 3375 3493 if (abfd->outsymbols != (asymbol **) NULL) 3376 3494 { … … 3379 3497 { 3380 3498 asymbol *p = *q; 3499 3381 3500 if (bfd_is_und_section (p->section)) 3382 3501 { 3383 /* This must be a symbol reference ..*/3502 /* This must be a symbol reference. */ 3384 3503 if (! ieee_write_byte (abfd, ieee_external_reference_enum) 3385 || ! ieee_write_int (abfd, reference_index)3504 || ! ieee_write_int (abfd, (bfd_vma) reference_index) 3386 3505 || ! ieee_write_id (abfd, p->name)) 3387 return false;3506 return FALSE; 3388 3507 p->value = reference_index; 3389 3508 reference_index++; 3390 hadone = true;3509 hadone = TRUE; 3391 3510 } 3392 3511 else if (bfd_is_com_section (p->section)) 3393 3512 { 3394 /* This is a weak reference */3513 /* This is a weak reference. */ 3395 3514 if (! ieee_write_byte (abfd, ieee_external_reference_enum) 3396 || ! ieee_write_int (abfd, reference_index)3515 || ! ieee_write_int (abfd, (bfd_vma) reference_index) 3397 3516 || ! ieee_write_id (abfd, p->name) 3398 3517 || ! ieee_write_byte (abfd, 3399 3518 ieee_weak_external_reference_enum) 3400 || ! ieee_write_int (abfd, reference_index)3519 || ! ieee_write_int (abfd, (bfd_vma) reference_index) 3401 3520 || ! ieee_write_int (abfd, p->value)) 3402 return false;3521 return FALSE; 3403 3522 p->value = reference_index; 3404 3523 reference_index++; 3405 hadone = true;3524 hadone = TRUE; 3406 3525 } 3407 3526 else if (p->flags & BSF_GLOBAL) 3408 3527 { 3409 /* This must be a symbol definition */ 3410 3528 /* This must be a symbol definition. */ 3411 3529 if (! ieee_write_byte (abfd, ieee_external_symbol_enum) 3412 || ! ieee_write_int (abfd, public_index)3530 || ! ieee_write_int (abfd, (bfd_vma) public_index) 3413 3531 || ! ieee_write_id (abfd, p->name) 3414 3532 || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum) 3415 || ! ieee_write_int (abfd, public_index)3533 || ! ieee_write_int (abfd, (bfd_vma) public_index) 3416 3534 || ! ieee_write_byte (abfd, 15) /* instruction address */ 3417 3535 || ! ieee_write_byte (abfd, 19) /* static symbol */ 3418 3536 || ! ieee_write_byte (abfd, 1)) /* one of them */ 3419 return false;3420 3421 /* Write out the value */3537 return FALSE; 3538 3539 /* Write out the value. */ 3422 3540 if (! ieee_write_2bytes (abfd, ieee_value_record_enum) 3423 || ! ieee_write_int (abfd, public_index))3424 return false;3541 || ! ieee_write_int (abfd, (bfd_vma) public_index)) 3542 return FALSE; 3425 3543 if (! bfd_is_abs_section (p->section)) 3426 3544 { … … 3428 3546 { 3429 3547 /* If fully linked, then output all symbols 3430 relocated */3548 relocated. */ 3431 3549 if (! (ieee_write_int 3432 3550 (abfd, … … 3434 3552 + p->section->output_offset 3435 3553 + p->section->output_section->vma)))) 3436 return false;3554 return FALSE; 3437 3555 } 3438 3556 else … … 3442 3560 p->value + p->section->output_offset, 3443 3561 p->section->output_section->symbol, 3444 false, 0)))3445 return false;3562 FALSE, 0))) 3563 return FALSE; 3446 3564 } 3447 3565 } … … 3451 3569 p->value, 3452 3570 bfd_abs_section_ptr->symbol, 3453 false, 0))3454 return false;3571 FALSE, 0)) 3572 return FALSE; 3455 3573 } 3456 3574 p->value = public_index; 3457 3575 public_index++; 3458 hadone = true;3576 hadone = TRUE; 3459 3577 } 3460 3578 else 3461 3579 { 3462 /* This can happen - when there are gaps in the symbols read */3463 /* from an input ieee file*/3580 /* This can happen - when there are gaps in the symbols read 3581 from an input ieee file. */ 3464 3582 } 3465 3583 } … … 3468 3586 ieee->w.r.external_part = here; 3469 3587 3470 return true;3471 } 3472 3473 3474 static CONSTunsigned char exten[] =3588 return TRUE; 3589 } 3590 3591 3592 static const unsigned char exten[] = 3475 3593 { 3476 3594 0xf0, 0x20, 0x00, 3477 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 3478 0xf1, 0xce, 0x20, 0x00, 39, 2, /* keep symbol in original case*/3479 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x*/3595 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3. */ 3596 0xf1, 0xce, 0x20, 0x00, 39, 2, /* Keep symbol in original case. */ 3597 0xf1, 0xce, 0x20, 0x00, 38 /* Set object type relocateable to x. */ 3480 3598 }; 3481 3599 3482 static CONSTunsigned char envi[] =3600 static const unsigned char envi[] = 3483 3601 { 3484 3602 0xf0, 0x21, 0x00, … … 3493 3611 }; 3494 3612 3495 static b oolean3613 static bfd_boolean 3496 3614 ieee_write_me_part (abfd) 3497 3615 bfd *abfd; … … 3505 3623 || ! ieee_write_int (abfd, abfd->start_address) 3506 3624 || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum)) 3507 return false;3625 return FALSE; 3508 3626 } 3509 3627 ieee->w.r.me_record = bfd_tell (abfd); 3510 3628 if (! ieee_write_byte (abfd, ieee_module_end_enum)) 3511 return false;3512 return true;3629 return FALSE; 3630 return TRUE; 3513 3631 } 3514 3632 3515 3633 /* Write out the IEEE processor ID. */ 3516 3634 3517 static b oolean3635 static bfd_boolean 3518 3636 ieee_write_processor (abfd) 3519 3637 bfd *abfd; … … 3526 3644 default: 3527 3645 if (! ieee_write_id (abfd, bfd_printable_name (abfd))) 3528 return false;3646 return FALSE; 3529 3647 break; 3530 3648 3531 3649 case bfd_arch_a29k: 3532 3650 if (! ieee_write_id (abfd, "29000")) 3533 return false;3651 return FALSE; 3534 3652 break; 3535 3653 3536 3654 case bfd_arch_h8300: 3537 3655 if (! ieee_write_id (abfd, "H8/300")) 3538 return false;3656 return FALSE; 3539 3657 break; 3540 3658 3541 3659 case bfd_arch_h8500: 3542 3660 if (! ieee_write_id (abfd, "H8/500")) 3543 return false;3661 return FALSE; 3544 3662 break; 3545 3663 … … 3551 3669 case bfd_mach_i960_ka_sa: 3552 3670 if (! ieee_write_id (abfd, "80960KA")) 3553 return false;3671 return FALSE; 3554 3672 break; 3555 3673 3556 3674 case bfd_mach_i960_kb_sb: 3557 3675 if (! ieee_write_id (abfd, "80960KB")) 3558 return false;3676 return FALSE; 3559 3677 break; 3560 3678 3561 3679 case bfd_mach_i960_ca: 3562 3680 if (! ieee_write_id (abfd, "80960CA")) 3563 return false;3681 return FALSE; 3564 3682 break; 3565 3683 … … 3567 3685 case bfd_mach_i960_xa: 3568 3686 if (! ieee_write_id (abfd, "80960MC")) 3569 return false;3687 return FALSE; 3570 3688 break; 3571 3689 } … … 3594 3712 3595 3713 if (! ieee_write_id (abfd, id)) 3596 return false;3714 return FALSE; 3597 3715 } 3598 3716 break; 3599 3717 } 3600 3718 3601 return true;3602 } 3603 3604 boolean3719 return TRUE; 3720 } 3721 3722 static bfd_boolean 3605 3723 ieee_write_object_contents (abfd) 3606 3724 bfd *abfd; … … 3610 3728 file_ptr old; 3611 3729 3612 /* Fast forward over the header area */3730 /* Fast forward over the header area. */ 3613 3731 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 3614 return false;3732 return FALSE; 3615 3733 3616 3734 if (! ieee_write_byte (abfd, ieee_module_beginning_enum) 3617 3735 || ! ieee_write_processor (abfd) 3618 3736 || ! ieee_write_id (abfd, abfd->filename)) 3619 return false;3620 3621 /* Fast forward over the variable bits */3737 return FALSE; 3738 3739 /* Fast forward over the variable bits. */ 3622 3740 if (! ieee_write_byte (abfd, ieee_address_descriptor_enum)) 3623 return false;3624 3625 /* Bits per MAU */3741 return FALSE; 3742 3743 /* Bits per MAU. */ 3626 3744 if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd)))) 3627 return false;3628 /* MAU's per address */3745 return FALSE; 3746 /* MAU's per address. */ 3629 3747 if (! ieee_write_byte (abfd, 3630 3748 (bfd_byte) (bfd_arch_bits_per_address (abfd) 3631 3749 / bfd_arch_bits_per_byte (abfd)))) 3632 return false;3750 return FALSE; 3633 3751 3634 3752 old = bfd_tell (abfd); 3635 3753 if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) 3636 return false;3754 return FALSE; 3637 3755 3638 3756 ieee->w.r.extension_record = bfd_tell (abfd); 3639 if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten)) 3640 return false; 3757 if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd) 3758 != sizeof (exten)) 3759 return FALSE; 3641 3760 if (abfd->flags & EXEC_P) 3642 3761 { 3643 3762 if (! ieee_write_byte (abfd, 0x1)) /* Absolute */ 3644 return false;3763 return FALSE; 3645 3764 } 3646 3765 else 3647 3766 { 3648 3767 if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */ 3649 return false;3768 return FALSE; 3650 3769 } 3651 3770 3652 3771 ieee->w.r.environmental_record = bfd_tell (abfd); 3653 if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi)) 3654 return false; 3772 if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd) 3773 != sizeof (envi)) 3774 return FALSE; 3655 3775 3656 3776 /* The HP emulator database requires a timestamp in the file. */ … … 3665 3785 || ! ieee_write_byte (abfd, 0) 3666 3786 || ! ieee_write_byte (abfd, 50) 3667 || ! ieee_write_int (abfd, t->tm_year + 1900)3668 || ! ieee_write_int (abfd, t->tm_mon + 1)3669 || ! ieee_write_int (abfd, t->tm_mday)3670 || ! ieee_write_int (abfd, t->tm_hour)3671 || ! ieee_write_int (abfd, t->tm_min)3672 || ! ieee_write_int (abfd, t->tm_sec))3673 return false;3787 || ! ieee_write_int (abfd, (bfd_vma) (t->tm_year + 1900)) 3788 || ! ieee_write_int (abfd, (bfd_vma) (t->tm_mon + 1)) 3789 || ! ieee_write_int (abfd, (bfd_vma) t->tm_mday) 3790 || ! ieee_write_int (abfd, (bfd_vma) t->tm_hour) 3791 || ! ieee_write_int (abfd, (bfd_vma) t->tm_min) 3792 || ! ieee_write_int (abfd, (bfd_vma) t->tm_sec)) 3793 return FALSE; 3674 3794 } 3675 3795 … … 3679 3799 3680 3800 if (! ieee_write_section_part (abfd)) 3681 return false;3801 return FALSE; 3682 3802 /* First write the symbols. This changes their values into table 3683 3803 indeces so we cant use it after this point. */ 3684 3804 if (! ieee_write_external_part (abfd)) 3685 return false; 3686 3687 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ 3688 3689 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ 3690 3805 return FALSE; 3691 3806 3692 3807 /* Write any debugs we have been told about. */ 3693 3808 if (! ieee_write_debug_part (abfd)) 3694 return false;3809 return FALSE; 3695 3810 3696 3811 /* Can only write the data once the symbols have been written, since … … 3698 3813 symbols. */ 3699 3814 if (! ieee_write_data_part (abfd)) 3700 return false;3815 return FALSE; 3701 3816 3702 3817 /* At the end we put the end! */ 3703 3818 if (! ieee_write_me_part (abfd)) 3704 return false;3705 3706 /* Generate the header */3819 return FALSE; 3820 3821 /* Generate the header. */ 3707 3822 if (bfd_seek (abfd, old, SEEK_SET) != 0) 3708 return false;3823 return FALSE; 3709 3824 3710 3825 for (i = 0; i < N_W_VARIABLES; i++) … … 3712 3827 if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum) 3713 3828 || ! ieee_write_byte (abfd, (bfd_byte) i) 3714 || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))3715 return false;3716 } 3717 3718 return true;3829 || ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i])) 3830 return FALSE; 3831 } 3832 3833 return TRUE; 3719 3834 } 3720 3835 … … 3724 3839 /* We read the symbols into a buffer, which is discarded when this 3725 3840 function exits. We read the strings into a buffer large enough to 3726 hold them all plus all the cached symbol entries. */3727 3728 asymbol *3841 hold them all plus all the cached symbol entries. */ 3842 3843 static asymbol * 3729 3844 ieee_make_empty_symbol (abfd) 3730 3845 bfd *abfd; 3731 3846 { 3732 ieee_symbol_type *new = 3733 (ieee_symbol_type *) bfd_zalloc (abfd, sizeof (ieee_symbol_type)); 3847 bfd_size_type amt = sizeof (ieee_symbol_type); 3848 ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt); 3849 3734 3850 if (!new) 3735 3851 return NULL; … … 3744 3860 { 3745 3861 ieee_ar_data_type *ar = IEEE_AR_DATA (arch); 3746 /* take the next one from the arch state, or reset */ 3862 3863 /* Take the next one from the arch state, or reset. */ 3747 3864 if (prev == (bfd *) NULL) 3748 { 3749 /* Reset the index - the first two entries are bogus*/ 3750 ar->element_index = 2; 3751 } 3752 while (true) 3865 /* Reset the index - the first two entries are bogus. */ 3866 ar->element_index = 2; 3867 3868 while (TRUE) 3753 3869 { 3754 3870 ieee_ar_obstack_type *p = ar->elements + ar->element_index; 3871 3755 3872 ar->element_index++; 3756 3873 if (ar->element_index <= ar->element_count) … … 3771 3888 return (bfd *) NULL; 3772 3889 } 3773 3774 } 3775 } 3776 3777 static boolean 3778 ieee_find_nearest_line (abfd, 3779 section, 3780 symbols, 3781 offset, 3782 filename_ptr, 3783 functionname_ptr, 3784 line_ptr) 3890 } 3891 } 3892 3893 static bfd_boolean 3894 ieee_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 3895 functionname_ptr, line_ptr) 3785 3896 bfd *abfd ATTRIBUTE_UNUSED; 3786 3897 asection *section ATTRIBUTE_UNUSED; … … 3791 3902 unsigned int *line_ptr ATTRIBUTE_UNUSED; 3792 3903 { 3793 return false;3904 return FALSE; 3794 3905 } 3795 3906 … … 3829 3940 ieee_sizeof_headers (abfd, x) 3830 3941 bfd *abfd ATTRIBUTE_UNUSED; 3831 b oolean x ATTRIBUTE_UNUSED;3942 bfd_boolean x ATTRIBUTE_UNUSED; 3832 3943 { 3833 3944 return 0; … … 3854 3965 3855 3966 /* Add this section to the list of sections we have debug info for, to 3856 be ready to output it at close time 3857 */ 3967 be ready to output it at close time. */ 3858 3968 static void 3859 3969 ieee_bfd_debug_info_accumulate (abfd, section) … … 3863 3973 ieee_data_type *ieee = IEEE_DATA (section->owner); 3864 3974 ieee_data_type *output_ieee = IEEE_DATA (abfd); 3865 /* can only accumulate data from other ieee bfds */ 3975 3976 /* Can only accumulate data from other ieee bfds. */ 3866 3977 if (section->owner->xvec != abfd->xvec) 3867 3978 return; 3868 /* Only bother once per bfd */3869 if (ieee->done_debug == true)3979 /* Only bother once per bfd. */ 3980 if (ieee->done_debug) 3870 3981 return; 3871 ieee->done_debug = true;3872 3873 /* Don't bother if there is no debug info */3982 ieee->done_debug = TRUE; 3983 3984 /* Don't bother if there is no debug info. */ 3874 3985 if (ieee->w.r.debug_information_part == 0) 3875 3986 return; 3876 3987 3877 3878 /* Add to chain */ 3988 /* Add to chain. */ 3879 3989 { 3880 bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type)); 3990 bfd_size_type amt = sizeof (bfd_chain_type); 3991 bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, amt); 3992 3881 3993 if (!n) 3882 3994 abort (); /* FIXME */ … … 3885 3997 3886 3998 if (output_ieee->chain_head) 3887 { 3888 output_ieee->chain_head->next = n; 3889 } 3999 output_ieee->chain_head->next = n; 3890 4000 else 3891 { 3892 output_ieee->chain_root = n; 3893 3894 } 4001 output_ieee->chain_root = n; 4002 3895 4003 output_ieee->chain_head = n; 3896 4004 } … … 3905 4013 #define ieee_slurp_extended_name_table bfd_true 3906 4014 #define ieee_construct_extended_name_table \ 3907 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ 4015 ((bfd_boolean (*) \ 4016 PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ 3908 4017 bfd_true) 3909 4018 #define ieee_truncate_arname bfd_dont_truncate_arname 3910 4019 #define ieee_write_armap \ 3911 ((b oolean (*) \4020 ((bfd_boolean (*) \ 3912 4021 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \ 3913 4022 bfd_true) … … 3932 4041 #define ieee_bfd_relax_section bfd_generic_relax_section 3933 4042 #define ieee_bfd_gc_sections bfd_generic_gc_sections 4043 #define ieee_bfd_merge_sections bfd_generic_merge_sections 4044 #define ieee_bfd_discard_group bfd_generic_discard_group 3934 4045 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 4046 #define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 3935 4047 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols 4048 #define ieee_bfd_link_just_syms _bfd_generic_link_just_syms 3936 4049 #define ieee_bfd_final_link _bfd_generic_final_link 3937 4050 #define ieee_bfd_link_split_section _bfd_generic_link_split_section 3938 4051 3939 /*SUPPRESS 460 */3940 4052 const bfd_target ieee_vec = 3941 4053 { … … 3977 4089 }, 3978 4090 4091 /* ieee_close_and_cleanup, ieee_bfd_free_cached_info, ieee_new_section_hook, 4092 ieee_get_section_contents, ieee_get_section_contents_in_window */ 3979 4093 BFD_JUMP_TABLE_GENERIC (ieee), 4094 3980 4095 BFD_JUMP_TABLE_COPY (_bfd_generic), 3981 4096 BFD_JUMP_TABLE_CORE (_bfd_nocore), 4097 4098 /* ieee_slurp_armap, ieee_slurp_extended_name_table, 4099 ieee_construct_extended_name_table, ieee_truncate_arname, 4100 ieee_write_armap, ieee_read_ar_hdr, ieee_openr_next_archived_file, 4101 ieee_get_elt_at_index, ieee_generic_stat_arch_elt, 4102 ieee_update_armap_timestamp */ 3982 4103 BFD_JUMP_TABLE_ARCHIVE (ieee), 4104 4105 /* ieee_get_symtab_upper_bound, ieee_get_symtab, ieee_make_empty_symbol, 4106 ieee_print_symbol, ieee_get_symbol_info, ieee_bfd_is_local_label_name, 4107 ieee_get_lineno, ieee_find_nearest_line, ieee_bfd_make_debug_symbol, 4108 ieee_read_minisymbols, ieee_minisymbol_to_symbol */ 3983 4109 BFD_JUMP_TABLE_SYMBOLS (ieee), 4110 4111 /* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc, 4112 ieee_bfd_reloc_type_lookup */ 3984 4113 BFD_JUMP_TABLE_RELOCS (ieee), 4114 4115 /* ieee_set_arch_mach, ieee_set_section_contents */ 3985 4116 BFD_JUMP_TABLE_WRITE (ieee), 4117 4118 /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents, 4119 ieee_bfd_relax_section, ieee_bfd_link_hash_table_create, 4120 _bfd_generic_link_hash_table_free, 4121 ieee_bfd_link_add_symbols, ieee_bfd_final_link, 4122 ieee_bfd_link_split_section, ieee_bfd_gc_sections, 4123 ieee_bfd_merge_sections */ 3986 4124 BFD_JUMP_TABLE_LINK (ieee), 4125 3987 4126 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), 3988 4127 3989 4128 NULL, 3990 4129 3991 4130 (PTR) 0 3992 4131 }; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.