Changeset 609 for branches/GNU/src/binutils/bfd/nlmcode.h
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/nlmcode.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* NLM (NetWare Loadable Module) executable support for BFD. 2 Copyright 1993, 1994, 1995, 1998, 2000 Free Software Foundation, Inc. 2 Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002 3 Free Software Foundation, Inc. 3 4 4 5 Written by Fred Fish @ Cygnus Support, using ELF support as the 5 6 template. 6 7 7 This file is part of BFD, the Binary File Descriptor library.8 9 This program is free software; you can redistribute it and/or modify10 it under the terms of the GNU General Public License as published by11 the Free Software Foundation; either version 2 of the License, or12 (at your option) any later version.13 14 This program is distributed in the hope that it will be useful,15 but WITHOUT ANY WARRANTY; without even the implied warranty of16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 GNU General Public License for more details.18 19 You should have received a copy of the GNU General Public License20 along with this program; if not, write to the Free Software21 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. */ 22 23 23 24 #include "bfd.h" … … 57 58 (nlm_swap_fixed_header_out_func(abfd)) (abfd,src,dst) 58 59 59 /* Forward declarations of static functions */60 61 static b oolean add_bfd_section60 /* Forward declarations of static functions. */ 61 62 static bfd_boolean add_bfd_section 62 63 PARAMS ((bfd *, char *, file_ptr, bfd_size_type, flagword)); 63 static b oolean nlm_swap_variable_header_in64 static bfd_boolean nlm_swap_variable_header_in 64 65 PARAMS ((bfd *)); 65 static b oolean nlm_swap_variable_header_out66 static bfd_boolean nlm_swap_variable_header_out 66 67 PARAMS ((bfd *)); 67 static b oolean find_nonzero68 static bfd_boolean find_nonzero 68 69 PARAMS ((PTR, size_t)); 69 static b oolean nlm_swap_auxiliary_headers_in70 static bfd_boolean nlm_swap_auxiliary_headers_in 70 71 PARAMS ((bfd *)); 71 static b oolean nlm_swap_auxiliary_headers_out72 static bfd_boolean nlm_swap_auxiliary_headers_out 72 73 PARAMS ((bfd *)); 73 static b oolean nlm_slurp_symbol_table74 static bfd_boolean nlm_slurp_symbol_table 74 75 PARAMS ((bfd *)); 75 static b oolean nlm_slurp_reloc_fixups76 static bfd_boolean nlm_slurp_reloc_fixups 76 77 PARAMS ((bfd *)); 77 static b oolean nlm_compute_section_file_positions78 static bfd_boolean nlm_compute_section_file_positions 78 79 PARAMS ((bfd *)); 79 80 static int nlm_external_reloc_compare … … 83 84 can be handled by explicitly specifying 32 bits or "the long type". */ 84 85 #if ARCH_SIZE == 64 85 #define put_word bfd_h_put_6486 #define get_word bfd_h_get_6486 #define put_word H_PUT_64 87 #define get_word H_GET_64 87 88 #endif 88 89 #if ARCH_SIZE == 32 89 #define put_word bfd_h_put_3290 #define get_word bfd_h_get_3290 #define put_word H_PUT_32 91 #define get_word H_GET_32 91 92 #endif 92 93 … … 96 97 { 97 98 struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd); 98 b oolean (*backend_object_p) PARAMS ((bfd *));99 bfd_boolean (*backend_object_p) PARAMS ((bfd *)); 99 100 PTR x_fxdhdr = NULL; 100 101 Nlm_Internal_Fixed_Header *i_fxdhdrp; … … 102 103 const char *signature; 103 104 enum bfd_architecture arch; 105 bfd_size_type amt; 104 106 105 107 /* Some NLM formats have a prefix before the standard NLM fixed … … 113 115 114 116 /* Read in the fixed length portion of the NLM header in external format. */ 115 116 x_fxdhdr = (PTR) bfd_malloc ( (size_t) nlm_fixed_header_size (abfd));117 amt = nlm_fixed_header_size (abfd); 118 x_fxdhdr = (PTR) bfd_malloc (amt); 117 119 if (x_fxdhdr == NULL) 118 120 goto got_no_match; 119 121 120 if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) != 121 nlm_fixed_header_size (abfd)) 122 if (bfd_bread ((PTR) x_fxdhdr, amt, abfd) != amt) 122 123 { 123 124 if (bfd_get_error () != bfd_error_system_call) … … 129 130 /* Allocate an instance of the nlm_obj_tdata structure and hook it up to 130 131 the tdata pointer in the bfd. */ 131 132 new_tdata = ((struct nlm_obj_tdata *) 133 bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata))); 132 amt = sizeof (struct nlm_obj_tdata); 133 new_tdata = (struct nlm_obj_tdata *) bfd_zalloc (abfd, amt); 134 134 if (new_tdata == NULL) 135 135 goto got_no_match; … … 144 144 /* Check to see if we have an NLM file for this backend by matching 145 145 the NLM signature. */ 146 147 146 signature = nlm_signature (abfd); 148 147 if (signature != NULL … … 154 153 /* There's no supported way to discover the endianess of an NLM, so test for 155 154 a sane version number after doing byte swapping appropriate for this 156 XVEC. (Hack alert!) */ 157 155 XVEC. (Hack alert!) */ 158 156 if (i_fxdhdrp->version > 0xFFFF) 159 157 goto got_wrong_format_error; … … 161 159 /* There's no supported way to check for 32 bit versus 64 bit addresses, 162 160 so ignore this distinction for now. (FIXME) */ 163 164 161 /* Swap in the rest of the required header. */ 165 162 if (!nlm_swap_variable_header_in (abfd)) … … 176 173 From this point on we assume that we have an NLM, and do not 177 174 treat errors as indicating the wrong format. */ 178 179 175 if (!add_bfd_section (abfd, NLM_CODE_NAME, 180 176 i_fxdhdrp->codeImageOffset, … … 226 222 /* Add a section to the bfd. */ 227 223 228 static b oolean224 static bfd_boolean 229 225 add_bfd_section (abfd, name, offset, size, flags) 230 226 bfd *abfd; … … 238 234 newsect = bfd_make_section (abfd, name); 239 235 if (newsect == NULL) 240 { 241 return (false); 242 } 236 return FALSE; 237 243 238 newsect->vma = 0; /* NLM's are relocatable. */ 244 239 newsect->_raw_size = size; 245 240 newsect->filepos = offset; 246 241 newsect->flags = flags; 247 newsect->alignment_power = bfd_log2 (0); /* FIXME */ 248 return (true); 242 newsect->alignment_power = bfd_log2 ((bfd_vma) 0); /* FIXME */ 243 244 return TRUE; 249 245 } 250 246 … … 252 248 exist in the NLM, and must exist in the order they are read here. */ 253 249 254 static b oolean250 static bfd_boolean 255 251 nlm_swap_variable_header_in (abfd) 256 252 bfd *abfd; 257 253 { 258 254 unsigned char temp[NLM_TARGET_LONG_SIZE]; 255 bfd_size_type amt; 259 256 260 257 /* Read the description length and text members. */ 261 258 262 if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength, 263 sizeof (nlm_variable_header (abfd)->descriptionLength), 264 1, abfd) != 265 sizeof (nlm_variable_header (abfd)->descriptionLength)) 266 return (false); 267 if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText, 268 nlm_variable_header (abfd)->descriptionLength + 1, 269 1, abfd) != 270 (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1) 271 return (false); 259 amt = sizeof (nlm_variable_header (abfd)->descriptionLength); 260 if (bfd_bread ((PTR) &nlm_variable_header (abfd)->descriptionLength, 261 amt, abfd) != amt) 262 return FALSE; 263 amt = nlm_variable_header (abfd)->descriptionLength + 1; 264 if (bfd_bread ((PTR) nlm_variable_header (abfd)->descriptionText, 265 amt, abfd) != amt) 266 return FALSE; 272 267 273 268 /* Read and convert the stackSize field. */ 274 269 275 if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) 276 return (false); 270 amt = sizeof (temp); 271 if (bfd_bread ((PTR) temp, amt, abfd) != amt) 272 return FALSE; 277 273 nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp); 278 274 279 275 /* Read and convert the reserved field. */ 280 276 281 if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) 282 return (false); 277 amt = sizeof (temp); 278 if (bfd_bread ((PTR) temp, amt, abfd) != amt) 279 return FALSE; 283 280 nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp); 284 281 285 282 /* Read the oldThreadName field. This field is a fixed length string. */ 286 283 287 if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName, 288 sizeof (nlm_variable_header (abfd)->oldThreadName), 289 1, abfd) != 290 sizeof (nlm_variable_header (abfd)->oldThreadName)) 291 return (false); 284 amt = sizeof (nlm_variable_header (abfd)->oldThreadName); 285 if (bfd_bread ((PTR) nlm_variable_header (abfd)->oldThreadName, 286 amt, abfd) != amt) 287 return FALSE; 292 288 293 289 /* Read the screen name length and text members. */ 294 290 295 if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength, 296 sizeof (nlm_variable_header (abfd)->screenNameLength), 297 1, abfd) != 298 sizeof (nlm_variable_header (abfd)->screenNameLength)) 299 return (false); 300 if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName, 301 nlm_variable_header (abfd)->screenNameLength + 1, 302 1, abfd) != 303 (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1) 304 return (false); 291 amt = sizeof (nlm_variable_header (abfd)->screenNameLength); 292 if (bfd_bread ((PTR) & nlm_variable_header (abfd)->screenNameLength, 293 amt, abfd) != amt) 294 return FALSE; 295 amt = nlm_variable_header (abfd)->screenNameLength + 1; 296 if (bfd_bread ((PTR) nlm_variable_header (abfd)->screenName, 297 amt, abfd) != amt) 298 return FALSE; 305 299 306 300 /* Read the thread name length and text members. */ 307 301 308 if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength, 309 sizeof (nlm_variable_header (abfd)->threadNameLength), 310 1, abfd) != 311 sizeof (nlm_variable_header (abfd)->threadNameLength)) 312 return (false); 313 if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName, 314 nlm_variable_header (abfd)->threadNameLength + 1, 315 1, abfd) != 316 (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1) 317 return (false); 318 return (true); 302 amt = sizeof (nlm_variable_header (abfd)->threadNameLength); 303 if (bfd_bread ((PTR) & nlm_variable_header (abfd)->threadNameLength, 304 amt, abfd) != amt) 305 return FALSE; 306 amt = nlm_variable_header (abfd)->threadNameLength + 1; 307 if (bfd_bread ((PTR) nlm_variable_header (abfd)->threadName, 308 amt, abfd) != amt) 309 return FALSE; 310 return TRUE; 319 311 } 320 312 … … 322 314 exist in the NLM, and must exist in this order. */ 323 315 324 static b oolean316 static bfd_boolean 325 317 nlm_swap_variable_header_out (abfd) 326 318 bfd *abfd; 327 319 { 328 320 unsigned char temp[NLM_TARGET_LONG_SIZE]; 321 bfd_size_type amt; 329 322 330 323 /* Write the description length and text members. */ 331 332 if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength, 333 sizeof (nlm_variable_header (abfd)->descriptionLength), 334 1, abfd) != 335 sizeof (nlm_variable_header (abfd)->descriptionLength)) 336 return (false); 337 if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText, 338 nlm_variable_header (abfd)->descriptionLength + 1, 339 1, abfd) != 340 (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1) 341 return (false); 324 amt = sizeof (nlm_variable_header (abfd)->descriptionLength); 325 if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->descriptionLength, amt, 326 abfd) != amt) 327 return FALSE; 328 amt = nlm_variable_header (abfd)->descriptionLength + 1; 329 if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->descriptionText, amt, 330 abfd) != amt) 331 return FALSE; 342 332 343 333 /* Convert and write the stackSize field. */ 344 345 334 put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize, 346 335 (bfd_byte *) temp); 347 if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) 348 return (false); 336 amt = sizeof (temp); 337 if (bfd_bwrite ((PTR) temp, amt, abfd) != amt) 338 return FALSE; 349 339 350 340 /* Convert and write the reserved field. */ 351 352 341 put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved, 353 342 (bfd_byte *) temp); 354 if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) 355 return (false); 343 amt = sizeof (temp); 344 if (bfd_bwrite ((PTR) temp, amt, abfd) != amt) 345 return FALSE; 356 346 357 347 /* Write the oldThreadName field. This field is a fixed length string. */ 358 359 if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName, 360 sizeof (nlm_variable_header (abfd)->oldThreadName), 361 1, abfd) != 362 sizeof (nlm_variable_header (abfd)->oldThreadName)) 363 return (false); 348 amt = sizeof (nlm_variable_header (abfd)->oldThreadName); 349 if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->oldThreadName, amt, 350 abfd) != amt) 351 return FALSE; 364 352 365 353 /* Write the screen name length and text members. */ 366 367 if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength, 368 sizeof (nlm_variable_header (abfd)->screenNameLength), 369 1, abfd) != 370 sizeof (nlm_variable_header (abfd)->screenNameLength)) 371 return (false); 372 if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName, 373 nlm_variable_header (abfd)->screenNameLength + 1, 374 1, abfd) != 375 (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1) 376 return (false); 354 amt = sizeof (nlm_variable_header (abfd)->screenNameLength); 355 if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->screenNameLength, amt, 356 abfd) != amt) 357 return FALSE; 358 amt = nlm_variable_header (abfd)->screenNameLength + 1; 359 if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->screenName, amt, 360 abfd) != amt) 361 return FALSE; 377 362 378 363 /* Write the thread name length and text members. */ 379 380 if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength, 381 sizeof (nlm_variable_header (abfd)->threadNameLength), 382 1, abfd) != 383 sizeof (nlm_variable_header (abfd)->threadNameLength)) 384 return (false); 385 if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName, 386 nlm_variable_header (abfd)->threadNameLength + 1, 387 1, abfd) != 388 (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1) 389 return (false); 390 return (true); 364 amt = sizeof (nlm_variable_header (abfd)->threadNameLength); 365 if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->threadNameLength, amt, 366 abfd) != amt) 367 return FALSE; 368 amt = nlm_variable_header (abfd)->threadNameLength + 1; 369 if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->threadName, amt, 370 abfd) != amt) 371 return FALSE; 372 return TRUE; 391 373 } 392 374 … … 400 382 recognize it. */ 401 383 402 static b oolean384 static bfd_boolean 403 385 nlm_swap_auxiliary_headers_in (abfd) 404 386 bfd *abfd; 405 387 { 406 388 char tempstr[16]; 407 long position; 389 file_ptr position; 390 bfd_size_type amt; 408 391 409 392 for (;;) 410 393 { 411 394 position = bfd_tell (abfd); 412 if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=413 sizeof (tempstr))414 return (false);415 if (bfd_seek (abfd, position, SEEK_SET) == -1)416 return (false);395 amt = sizeof (tempstr); 396 if (bfd_bread ((PTR) tempstr, amt, abfd) != amt) 397 return FALSE; 398 if (bfd_seek (abfd, position, SEEK_SET) != 0) 399 return FALSE; 417 400 if (strncmp (tempstr, "VeRsIoN#", 8) == 0) 418 401 { 419 402 Nlm_External_Version_Header thdr; 420 if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) 421 return (false); 403 404 amt = sizeof (thdr); 405 if (bfd_bread ((PTR) &thdr, amt, abfd) != amt) 406 return FALSE; 422 407 memcpy (nlm_version_header (abfd)->stamp, thdr.stamp, 423 408 sizeof (thdr.stamp)); … … 438 423 { 439 424 Nlm_External_Extended_Header thdr; 440 if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) 441 return (false); 425 426 amt = sizeof (thdr); 427 if (bfd_bread ((PTR) &thdr, amt, abfd) != amt) 428 return FALSE; 442 429 memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp, 443 430 sizeof (thdr.stamp)); … … 503 490 else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0) 504 491 { 505 if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp, 506 sizeof (nlm_copyright_header (abfd)->stamp), 507 1, abfd) 508 != sizeof (nlm_copyright_header (abfd)->stamp)) 509 return (false); 510 if (bfd_read ((PTR) & (nlm_copyright_header (abfd) 511 ->copyrightMessageLength), 512 1, 1, abfd) != 1) 513 return (false); 492 amt = sizeof (nlm_copyright_header (abfd)->stamp); 493 if (bfd_bread ((PTR) nlm_copyright_header (abfd)->stamp, 494 amt, abfd) != amt) 495 return FALSE; 496 if (bfd_bread ((PTR) &(nlm_copyright_header (abfd) 497 ->copyrightMessageLength), 498 (bfd_size_type) 1, abfd) != 1) 499 return FALSE; 514 500 /* The copyright message is a variable length string. */ 515 if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage, 516 nlm_copyright_header (abfd)->copyrightMessageLength + 1, 517 1, abfd) != 518 ((bfd_size_type) 519 nlm_copyright_header (abfd)->copyrightMessageLength + 1)) 520 return (false); 501 amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1; 502 if (bfd_bread ((PTR) nlm_copyright_header (abfd)->copyrightMessage, 503 amt, abfd) != amt) 504 return FALSE; 521 505 } 522 506 else if (strncmp (tempstr, "CuStHeAd", 8) == 0) … … 530 514 531 515 /* Read the stamp ("CuStHeAd"). */ 532 if (bfd_read ((PTR) thdr.stamp, 1, sizeof (thdr.stamp), abfd)533 != sizeof (thdr.stamp))534 return false;516 amt = sizeof (thdr.stamp); 517 if (bfd_bread ((PTR) thdr.stamp, amt, abfd) != amt) 518 return FALSE; 535 519 /* Read the length of this custom header. */ 536 if (bfd_read ((PTR) thdr.length, 1, sizeof (thdr.length), abfd)537 != sizeof (thdr.length))538 return false;520 amt = sizeof (thdr.length); 521 if (bfd_bread ((PTR) thdr.length, amt, abfd) != amt) 522 return FALSE; 539 523 hdrLength = get_word (abfd, (bfd_byte *) thdr.length); 540 524 /* Read further fields if we have them. */ … … 543 527 else 544 528 { 545 if (bfd_read ((PTR) thdr.dataOffset, 1, 546 sizeof (thdr.dataOffset), abfd) 547 != sizeof (thdr.dataOffset)) 548 return false; 529 amt = sizeof (thdr.dataOffset); 530 if (bfd_bread ((PTR) thdr.dataOffset, amt, abfd) != amt) 531 return FALSE; 549 532 dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset); 550 533 } … … 553 536 else 554 537 { 555 if (bfd_read ((PTR) thdr.dataLength, 1, 556 sizeof (thdr.dataLength), abfd) 557 != sizeof (thdr.dataLength)) 558 return false; 538 amt = sizeof (thdr.dataLength); 539 if (bfd_bread ((PTR) thdr.dataLength, amt, abfd) != amt) 540 return FALSE; 559 541 dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength); 560 542 } … … 563 545 else 564 546 { 565 if (bfd_read ((PTR) dataStamp, 1, sizeof (dataStamp), abfd)566 != sizeof (dataStamp))567 return false;547 amt = sizeof (dataStamp); 548 if (bfd_bread ((PTR) dataStamp, amt, abfd) != amt) 549 return FALSE; 568 550 } 569 551 … … 579 561 hdr = bfd_alloc (abfd, hdrLength); 580 562 if (hdr == NULL) 581 return false;582 if (bfd_ read (hdr, 1, hdrLength, abfd) != hdrLength)583 return false;563 return FALSE; 564 if (bfd_bread (hdr, hdrLength, abfd) != hdrLength) 565 return FALSE; 584 566 } 585 567 … … 597 579 pos = bfd_tell (abfd); 598 580 if (bfd_seek (abfd, dataOffset, SEEK_SET) != 0) 599 return false;581 return FALSE; 600 582 contents = (bfd_byte *) bfd_alloc (abfd, dataLength); 601 583 if (contents == NULL) 602 return false;603 if (bfd_ read (contents, 1, dataLength, abfd) != dataLength)604 return false;584 return FALSE; 585 if (bfd_bread (contents, dataLength, abfd) != dataLength) 586 return FALSE; 605 587 if (bfd_seek (abfd, pos, SEEK_SET) != 0) 606 return false;588 return FALSE; 607 589 608 590 memcpy (nlm_cygnus_ext_header (abfd), "CyGnUsEx", 8); … … 639 621 name = (char *) p; 640 622 l = strlen (name) + 1; 641 l = (l + 3) &~ 3;623 l = (l + 3) &~ (size_t) 3; 642 624 p += l; 643 filepos = bfd_h_get_32 (abfd, p);625 filepos = H_GET_32 (abfd, p); 644 626 p += 4; 645 size = bfd_h_get_32 (abfd, p);627 size = H_GET_32 (abfd, p); 646 628 p += 4; 647 629 648 630 newsec = bfd_make_section_anyway (abfd, name); 649 631 if (newsec == (asection *) NULL) 650 return false;632 return FALSE; 651 633 newsec->_raw_size = size; 652 634 if (filepos != 0) … … 670 652 } 671 653 else 672 { 673 break; 674 } 675 } 676 return (true); 654 break; 655 } 656 return TRUE; 677 657 } 678 658 679 659 /* Return whether there is a non-zero byte in a memory block. */ 680 660 681 static b oolean661 static bfd_boolean 682 662 find_nonzero (buf, size) 683 663 PTR buf; … … 688 668 while (size-- != 0) 689 669 if (*p++ != 0) 690 return true;691 return false;670 return TRUE; 671 return FALSE; 692 672 } 693 673 … … 696 676 the caller to set up the stamp fields. */ 697 677 698 static b oolean678 static bfd_boolean 699 679 nlm_swap_auxiliary_headers_out (abfd) 700 680 bfd *abfd; 701 681 { 682 bfd_size_type amt; 683 702 684 /* Write out the version header if there is one. */ 703 685 if (find_nonzero ((PTR) nlm_version_header (abfd), … … 719 701 put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day, 720 702 (bfd_byte *) thdr.day); 721 if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) 722 return false; 703 if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd) 704 != sizeof (thdr)) 705 return FALSE; 706 } 707 708 /* Note - the CoPyRiGhT tag is emitted before the MeSsAgEs 709 tag in order to make the NW4.x and NW5.x loaders happy. */ 710 711 /* Write out the copyright header if there is one. */ 712 if (find_nonzero ((PTR) nlm_copyright_header (abfd), 713 sizeof (Nlm_Internal_Copyright_Header))) 714 { 715 Nlm_External_Copyright_Header thdr; 716 717 memcpy (thdr.stamp, "CoPyRiGhT=", 10); 718 amt = sizeof (thdr.stamp); 719 if (bfd_bwrite ((PTR) thdr.stamp, amt, abfd) != amt) 720 return FALSE; 721 thdr.copyrightMessageLength[0] = 722 nlm_copyright_header (abfd)->copyrightMessageLength; 723 amt = 1; 724 if (bfd_bwrite ((PTR) thdr.copyrightMessageLength, amt, abfd) != amt) 725 return FALSE; 726 /* The copyright message is a variable length string. */ 727 amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1; 728 if (bfd_bwrite ((PTR) nlm_copyright_header (abfd)->copyrightMessage, 729 amt, abfd) != amt) 730 return FALSE; 723 731 } 724 732 … … 817 825 (bfd_vma) nlm_extended_header (abfd)->reserved5, 818 826 (bfd_byte *) thdr.reserved5); 819 if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) 820 return false; 821 } 822 823 /* Write out the copyright header if there is one. */ 824 if (find_nonzero ((PTR) nlm_copyright_header (abfd), 825 sizeof (Nlm_Internal_Copyright_Header))) 826 { 827 Nlm_External_Copyright_Header thdr; 828 829 memcpy (thdr.stamp, "CoPyRiGhT=", 10); 830 if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd) 831 != sizeof (thdr.stamp)) 832 return false; 833 thdr.copyrightMessageLength[0] = 834 nlm_copyright_header (abfd)->copyrightMessageLength; 835 if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1) 836 return false; 837 /* The copyright message is a variable length string. */ 838 if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage, 839 nlm_copyright_header (abfd)->copyrightMessageLength + 1, 840 1, abfd) != 841 ((bfd_size_type) 842 nlm_copyright_header (abfd)->copyrightMessageLength + 1)) 843 return false; 827 if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd) 828 != sizeof (thdr)) 829 return FALSE; 844 830 } 845 831 … … 849 835 { 850 836 Nlm_External_Custom_Header thdr; 851 b oolean ds;837 bfd_boolean ds; 852 838 bfd_size_type hdrLength; 853 839 … … 865 851 { 866 852 BFD_ASSERT (nlm_custom_header (abfd)->hdrLength == 0); 867 if (bfd_write ((PTR) &thdr, 1, 868 sizeof (thdr) - sizeof (thdr.dataStamp), abfd) 869 != sizeof (thdr) - sizeof (thdr.dataStamp)) 870 return false; 853 amt = sizeof (thdr) - sizeof (thdr.dataStamp); 854 if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt) 855 return FALSE; 871 856 } 872 857 else … … 874 859 memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp, 875 860 sizeof (thdr.dataStamp)); 876 if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))877 return false;878 if (bfd_write (nlm_custom_header (abfd)->hdr, 1,879 nlm_custom_header (abfd)->hdrLength, abfd)880 != nlm_custom_header (abfd)->hdrLength)881 return false;861 amt = sizeof (thdr); 862 if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt) 863 return FALSE; 864 amt = nlm_custom_header (abfd)->hdrLength; 865 if (bfd_bwrite (nlm_custom_header (abfd)->hdr, amt, abfd) != amt) 866 return FALSE; 882 867 } 883 868 } … … 897 882 (bfd_byte *) thdr.dataLength); 898 883 memcpy (thdr.dataStamp, "CyGnUsEx", 8); 899 if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) 900 return false; 901 } 902 903 return true; 884 amt = sizeof (thdr); 885 if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt) 886 return FALSE; 887 } 888 889 return TRUE; 904 890 } 905 891 … … 917 903 bfd *abfd; 918 904 { 919 Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */905 Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form. */ 920 906 long symcount; 921 907 long symtab_size = 0; … … 940 926 bfd_size_type counter = 0; 941 927 942 if ( nlm_slurp_symbol_table (abfd) == false)928 if (! nlm_slurp_symbol_table (abfd)) 943 929 return -1; 944 930 symbase = nlm_get_symbols (abfd); … … 959 945 bfd *abfd; 960 946 { 961 nlm_symbol_type *new;962 963 new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type)); 947 bfd_size_type amt = sizeof (nlm_symbol_type); 948 nlm_symbol_type *new = (nlm_symbol_type *) bfd_zalloc (abfd, amt); 949 964 950 if (new) 965 951 new->symbol.the_bfd = abfd; … … 982 968 void 983 969 nlm_print_symbol (abfd, afile, symbol, how) 984 bfd *abfd ATTRIBUTE_UNUSED;970 bfd *abfd; 985 971 PTR afile; 986 972 asymbol *symbol; … … 997 983 break; 998 984 case bfd_print_symbol_all: 999 bfd_print_symbol_vandf ( (PTR) file, symbol);985 bfd_print_symbol_vandf (abfd, (PTR) file, symbol); 1000 986 fprintf (file, " %-5s", symbol->section->name); 1001 987 if (symbol->name) … … 1022 1008 1023 1009 When we return, the bfd symcount is either zero or contains the correct 1024 number of symbols. 1025 */ 1026 1027 static boolean 1010 number of symbols. */ 1011 1012 static bfd_boolean 1028 1013 nlm_slurp_symbol_table (abfd) 1029 1014 bfd *abfd; 1030 1015 { 1031 Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */ 1032 bfd_size_type totsymcount; /* Number of NLM symbols */ 1033 bfd_size_type symcount; /* Counter of NLM symbols */ 1034 nlm_symbol_type *sym; /* Pointer to current bfd symbol */ 1035 unsigned char symlength; /* Symbol length read into here */ 1036 unsigned char symtype; /* Type of debugging symbol */ 1037 bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here */ 1038 boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *)); 1039 boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *)); 1016 Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form. */ 1017 bfd_size_type totsymcount; /* Number of NLM symbols. */ 1018 bfd_size_type symcount; /* Counter of NLM symbols. */ 1019 nlm_symbol_type *sym; /* Pointer to current bfd symbol. */ 1020 unsigned char symlength; /* Symbol length read into here. */ 1021 unsigned char symtype; /* Type of debugging symbol. */ 1022 bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here. */ 1023 bfd_boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *)); 1024 bfd_boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *)); 1025 bfd_size_type amt; 1040 1026 1041 1027 if (nlm_get_symbols (abfd) != NULL) 1042 return (true);1028 return TRUE; 1043 1029 1044 1030 /* Read each raw NLM symbol, using the information to create a canonical bfd … … 1056 1042 + i_fxdhdrp->numberOfExternalReferences); 1057 1043 if (totsymcount == 0) 1058 { 1059 return (true); 1060 } 1061 1062 if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1) 1063 return (false); 1064 1065 sym = ((nlm_symbol_type *) 1066 bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type))); 1044 return TRUE; 1045 1046 if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) != 0) 1047 return FALSE; 1048 1049 amt = totsymcount * sizeof (nlm_symbol_type); 1050 sym = ((nlm_symbol_type *) bfd_zalloc (abfd, amt)); 1067 1051 if (!sym) 1068 return false;1052 return FALSE; 1069 1053 nlm_set_symbols (abfd, sym); 1070 1054 … … 1077 1061 while (abfd->symcount < symcount) 1078 1062 { 1079 if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) 1080 != sizeof (symlength)) 1081 return (false); 1063 amt = sizeof (symlength); 1064 if (bfd_bread ((PTR) &symlength, amt, abfd) != amt) 1065 return FALSE; 1066 amt = symlength; 1082 1067 sym->symbol.the_bfd = abfd; 1083 sym->symbol.name = bfd_alloc (abfd, symlength+ 1);1068 sym->symbol.name = bfd_alloc (abfd, amt + 1); 1084 1069 if (!sym->symbol.name) 1085 return false; 1086 if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) 1087 != symlength) 1088 return (false); 1070 return FALSE; 1071 if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt) 1072 return FALSE; 1089 1073 /* Cast away const. */ 1090 1074 ((char *) (sym->symbol.name))[symlength] = '\0'; 1091 if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) 1092 return (false); 1075 amt = sizeof (temp); 1076 if (bfd_bread ((PTR) temp, amt, abfd) != amt) 1077 return FALSE; 1093 1078 sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT; 1094 1079 sym->symbol.value = get_word (abfd, temp); … … 1097 1082 /* Most backends can use the code below, but unfortunately 1098 1083 some use a different scheme. */ 1099 if ( (*set_public_section_func) (abfd, sym) == false)1100 return false;1084 if (! (*set_public_section_func) (abfd, sym)) 1085 return FALSE; 1101 1086 } 1102 1087 else … … 1124 1109 if (i_fxdhdrp->numberOfDebugRecords > 0) 1125 1110 { 1126 if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1)1127 return (false);1111 if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) != 0) 1112 return FALSE; 1128 1113 1129 1114 symcount += i_fxdhdrp->numberOfDebugRecords; 1130 1115 while (abfd->symcount < symcount) 1131 1116 { 1132 if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd) 1133 != sizeof (symtype)) 1134 || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp) 1135 || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) 1136 != sizeof (symlength))) 1137 return false; 1117 amt = sizeof (symtype); 1118 if (bfd_bread ((PTR) &symtype, amt, abfd) != amt) 1119 return FALSE; 1120 amt = sizeof (temp); 1121 if (bfd_bread ((PTR) temp, amt, abfd) != amt) 1122 return FALSE; 1123 amt = sizeof (symlength); 1124 if (bfd_bread ((PTR) &symlength, amt, abfd) != amt) 1125 return FALSE; 1126 amt = symlength; 1138 1127 sym->symbol.the_bfd = abfd; 1139 sym->symbol.name = bfd_alloc (abfd, symlength+ 1);1128 sym->symbol.name = bfd_alloc (abfd, amt + 1); 1140 1129 if (!sym->symbol.name) 1141 return false; 1142 if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) 1143 != symlength) 1144 return (false); 1130 return FALSE; 1131 if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt) 1132 return FALSE; 1145 1133 /* Cast away const. */ 1146 1134 ((char *) (sym->symbol.name))[symlength] = '\0'; … … 1170 1158 /* Read in the import records. We can only do this if we know how 1171 1159 to read relocs for this target. */ 1172 1173 1160 read_import_func = nlm_read_import_func (abfd); 1174 1161 if (read_import_func != NULL) 1175 1162 { 1176 if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) 1177 == -1) 1178 return (false); 1163 if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) != 0) 1164 return FALSE; 1179 1165 1180 1166 symcount += i_fxdhdrp->numberOfExternalReferences; 1181 1167 while (abfd->symcount < symcount) 1182 1168 { 1183 if ( (*read_import_func) (abfd, sym) == false)1184 return false;1169 if (! (*read_import_func) (abfd, sym)) 1170 return FALSE; 1185 1171 sym++; 1186 1172 abfd->symcount++; … … 1188 1174 } 1189 1175 1190 return (true);1176 return TRUE; 1191 1177 } 1192 1178 … … 1205 1191 section. */ 1206 1192 1207 static b oolean1193 static bfd_boolean 1208 1194 nlm_slurp_reloc_fixups (abfd) 1209 1195 bfd *abfd; 1210 1196 { 1211 b oolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **,1212 1213 bfd_size_type count ;1197 bfd_boolean (*read_func) 1198 PARAMS ((bfd *, nlm_symbol_type *, asection **, arelent *)); 1199 bfd_size_type count, amt; 1214 1200 arelent *rels; 1215 1201 asection **secs; 1216 1202 1217 1203 if (nlm_relocation_fixups (abfd) != NULL) 1218 return true;1204 return TRUE; 1219 1205 read_func = nlm_read_reloc_func (abfd); 1220 1206 if (read_func == NULL) 1221 return true;1207 return TRUE; 1222 1208 1223 1209 if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset, 1224 1210 SEEK_SET) != 0) 1225 return false;1211 return FALSE; 1226 1212 1227 1213 count = nlm_fixed_header (abfd)->numberOfRelocationFixups; 1228 rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent)); 1229 secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *)); 1214 amt = count * sizeof (arelent); 1215 rels = (arelent *) bfd_alloc (abfd, amt); 1216 amt = count * sizeof (asection *); 1217 secs = (asection **) bfd_alloc (abfd, amt); 1230 1218 if ((rels == NULL || secs == NULL) && count != 0) 1231 return false;1219 return FALSE; 1232 1220 nlm_relocation_fixups (abfd) = rels; 1233 1221 nlm_relocation_fixup_secs (abfd) = secs; … … 1237 1225 while (count-- != 0) 1238 1226 { 1239 if ( (*read_func) (abfd, (nlm_symbol_type *) NULL, secs, rels) == false)1227 if (! (*read_func) (abfd, (nlm_symbol_type *) NULL, secs, rels)) 1240 1228 { 1241 1229 nlm_relocation_fixups (abfd) = NULL; 1242 1230 nlm_relocation_fixup_secs (abfd) = NULL; 1243 return false;1231 return FALSE; 1244 1232 } 1245 1233 ++secs; … … 1247 1235 } 1248 1236 1249 return true;1237 return TRUE; 1250 1238 } 1251 1239 … … 1273 1261 if (syms == NULL) 1274 1262 { 1275 if ( nlm_slurp_symbol_table (abfd) == false)1263 if (! nlm_slurp_symbol_table (abfd)) 1276 1264 return -1; 1277 1265 syms = nlm_get_symbols (abfd); … … 1308 1296 if (rels == NULL) 1309 1297 { 1310 if ( nlm_slurp_reloc_fixups (abfd) == false)1298 if (! nlm_slurp_reloc_fixups (abfd)) 1311 1299 return -1; 1312 1300 rels = nlm_relocation_fixups (abfd); … … 1373 1361 final values. */ 1374 1362 1375 static b oolean1363 static bfd_boolean 1376 1364 nlm_compute_section_file_positions (abfd) 1377 1365 bfd *abfd; … … 1386 1374 asymbol **sym_ptr_ptr; 1387 1375 1388 if (abfd->output_has_begun == true)1389 return true;1376 if (abfd->output_has_begun) 1377 return TRUE; 1390 1378 1391 1379 /* Make sure we have a section to hold uninitialized data. */ … … 1396 1384 (file_ptr) 0, (bfd_size_type) 0, 1397 1385 SEC_ALLOC)) 1398 return false;1386 return FALSE; 1399 1387 bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME); 1400 1388 } 1401 1389 1402 abfd->output_has_begun = true;1390 abfd->output_has_begun = TRUE; 1403 1391 1404 1392 /* The fixed header. */ … … 1571 1559 } 1572 1560 1573 return true;1561 return TRUE; 1574 1562 } 1575 1563 … … 1579 1567 variable size header information must be known. */ 1580 1568 1581 b oolean1569 bfd_boolean 1582 1570 nlm_set_section_contents (abfd, section, location, offset, count) 1583 1571 bfd *abfd; … … 1587 1575 bfd_size_type count; 1588 1576 { 1589 if ( abfd->output_has_begun == false1590 && nlm_compute_section_file_positions (abfd) == false)1591 return false;1577 if (! abfd->output_has_begun 1578 && ! nlm_compute_section_file_positions (abfd)) 1579 return FALSE; 1592 1580 1593 1581 if (count == 0) 1594 return true;1582 return TRUE; 1595 1583 1596 1584 /* i386 NetWare has a very restricted set of relocs. In order for … … 1600 1588 if (section->reloc_count != 0) 1601 1589 { 1602 b oolean (*mangle_relocs_func) PARAMS ((bfd *, asection *, PTR,1603 1590 bfd_boolean (*mangle_relocs_func) 1591 PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type)); 1604 1592 1605 1593 mangle_relocs_func = nlm_mangle_relocs_func (abfd); … … 1608 1596 if (!(*mangle_relocs_func) (abfd, section, location, 1609 1597 (bfd_vma) offset, count)) 1610 return false;1611 } 1612 } 1613 1614 if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 01615 || bfd_ write (location, 1, count, abfd) != count)1616 return false;1617 1618 return true;1598 return FALSE; 1599 } 1600 } 1601 1602 if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0 1603 || bfd_bwrite (location, count, abfd) != count) 1604 return FALSE; 1605 1606 return TRUE; 1619 1607 } 1620 1608 … … 1670 1658 list of outsymbols. */ 1671 1659 1672 b oolean1660 bfd_boolean 1673 1661 nlm_write_object_contents (abfd) 1674 1662 bfd *abfd; 1675 1663 { 1676 1664 asection *sec; 1677 b oolean (*write_import_func) PARAMS ((bfd *, asection *, arelent *));1665 bfd_boolean (*write_import_func) PARAMS ((bfd *, asection *, arelent *)); 1678 1666 bfd_size_type external_reloc_count, internal_reloc_count, i, c; 1679 1667 struct reloc_and_sec *external_relocs; 1680 1668 asymbol **sym_ptr_ptr; 1681 1669 file_ptr last; 1682 b oolean (*write_prefix_func) PARAMS ((bfd *));1670 bfd_boolean (*write_prefix_func) PARAMS ((bfd *)); 1683 1671 unsigned char *fixed_header = NULL; 1672 file_ptr pos; 1673 bfd_size_type amt; 1684 1674 1685 1675 fixed_header = ((unsigned char *) 1686 bfd_malloc ( (size_t)nlm_fixed_header_size (abfd)));1676 bfd_malloc (nlm_fixed_header_size (abfd))); 1687 1677 if (fixed_header == NULL) 1688 1678 goto error_return; 1689 1679 1690 if ( abfd->output_has_begun == false1691 && nlm_compute_section_file_positions (abfd) == false)1680 if (! abfd->output_has_begun 1681 && ! nlm_compute_section_file_positions (abfd)) 1692 1682 goto error_return; 1693 1683 1694 1684 /* Write out the variable length headers. */ 1695 if (bfd_seek (abfd, 1696 nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd), 1697 SEEK_SET) != 0) 1685 pos = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd); 1686 if (bfd_seek (abfd, pos, SEEK_SET) != 0) 1698 1687 goto error_return; 1699 if ( nlm_swap_variable_header_out (abfd) == false1700 || nlm_swap_auxiliary_headers_out (abfd) == false)1688 if (! nlm_swap_variable_header_out (abfd) 1689 || ! nlm_swap_auxiliary_headers_out (abfd)) 1701 1690 { 1702 1691 bfd_set_error (bfd_error_system_call); … … 1706 1695 /* A weak check on whether the section file positions were 1707 1696 reasonable. */ 1708 if (bfd_tell (abfd) > nlm_fixed_header (abfd)->codeImageOffset)1697 if (bfd_tell (abfd) > (ufile_ptr) nlm_fixed_header (abfd)->codeImageOffset) 1709 1698 { 1710 1699 bfd_set_error (bfd_error_invalid_operation); … … 1759 1748 { 1760 1749 ++internal_reloc_count; 1761 if ( (*write_import_func) (abfd, sec, rel) == false)1750 if (! (*write_import_func) (abfd, sec, rel)) 1762 1751 goto error_return; 1763 1752 } … … 1772 1761 symbol, so we must first gather together all the relocs against 1773 1762 external symbols and sort them. */ 1774 external_relocs = 1775 (struct reloc_and_sec *) bfd_alloc (abfd, 1776 (external_reloc_count 1777 * sizeof (struct reloc_and_sec))); 1763 amt = external_reloc_count * sizeof (struct reloc_and_sec); 1764 external_relocs = (struct reloc_and_sec *) bfd_alloc (abfd, amt); 1778 1765 if (external_relocs == (struct reloc_and_sec *) NULL) 1779 1766 goto error_return; … … 1833 1820 ++cnt; 1834 1821 1835 if ((*nlm_write_external_func (abfd)) (abfd, cnt, sym, 1836 &external_relocs[i]) 1837 == false) 1822 if (! (*nlm_write_external_func (abfd)) (abfd, cnt, sym, 1823 &external_relocs[i])) 1838 1824 goto error_return; 1839 1825 … … 1848 1834 { 1849 1835 bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *)); 1850 b oolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma));1836 bfd_boolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma)); 1851 1837 1852 1838 asymbol **sym_end; … … 1903 1889 if (write_export_func) 1904 1890 { 1905 if ( (*write_export_func) (abfd, sym, offset) == false)1891 if (! (*write_export_func) (abfd, sym, offset)) 1906 1892 goto error_return; 1907 1893 } … … 1909 1895 { 1910 1896 len = strlen (sym->name); 1911 if ((bfd_ write (&len, sizeof (bfd_byte), 1, abfd)1897 if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd) 1912 1898 != sizeof (bfd_byte)) 1913 || bfd_ write (sym->name, len, 1, abfd) != len)1899 || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len) 1914 1900 goto error_return; 1915 1901 1916 1902 put_word (abfd, offset, temp); 1917 if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp)) 1903 if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) 1904 != sizeof (temp)) 1918 1905 goto error_return; 1919 1906 } … … 1974 1961 1975 1962 /* The type is 0 for data, 1 for code, 2 for absolute. */ 1976 if (bfd_ write (&type, sizeof (bfd_byte), 1, abfd)1963 if (bfd_bwrite (&type, (bfd_size_type) sizeof (bfd_byte), abfd) 1977 1964 != sizeof (bfd_byte)) 1978 1965 goto error_return; 1979 1966 1980 1967 put_word (abfd, offset, temp); 1981 if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp)) 1968 if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) 1969 != sizeof (temp)) 1982 1970 goto error_return; 1983 1971 1984 1972 len = strlen (sym->name); 1985 if ((bfd_ write (&len, sizeof (bfd_byte), 1, abfd)1973 if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd) 1986 1974 != sizeof (bfd_byte)) 1987 || bfd_ write (sym->name, len, 1, abfd) != len)1975 || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len) 1988 1976 goto error_return; 1989 1977 } … … 2029 2017 nlm_get_text_low (abfd); 2030 2018 2031 if (bfd_seek (abfd, 0, SEEK_SET) != 0)2019 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 2032 2020 goto error_return; 2033 2021 … … 2035 2023 if (write_prefix_func) 2036 2024 { 2037 if ( (*write_prefix_func) (abfd) == false)2025 if (! (*write_prefix_func) (abfd)) 2038 2026 goto error_return; 2039 2027 } … … 2043 2031 2044 2032 nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header); 2045 if (bfd_ write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)2033 if (bfd_bwrite (fixed_header, nlm_fixed_header_size (abfd), abfd) 2046 2034 != nlm_fixed_header_size (abfd)) 2047 2035 goto error_return; … … 2049 2037 if (fixed_header != NULL) 2050 2038 free (fixed_header); 2051 return true;2039 return TRUE; 2052 2040 2053 2041 error_return: 2054 2042 if (fixed_header != NULL) 2055 2043 free (fixed_header); 2056 return false;2044 return FALSE; 2057 2045 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.