Changeset 609 for branches/GNU/src/binutils/bfd/i386linux.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/i386linux.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for linux flavored i386 a.out binaries. 2 Copyright 1992, 1993, 1994, 1995, 1996, 1997 2 Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 … … 24 24 #define TEXT_START_ADDR 0x0 25 25 #define N_SHARED_LIB(x) 0 26 #define BYTES_IN_WORD 427 26 28 27 #define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN) … … 37 36 38 37 #define DEFAULT_ARCH bfd_arch_i386 39 #define MY(OP) CAT(i386linux_,OP) 38 39 /* Do not "beautify" the CONCAT* macro args. Traditional C will not 40 remove whitespace added here, and thus will fail to concatenate 41 the tokens. */ 42 #define MY(OP) CONCAT2 (i386linux_,OP) 40 43 #define TARGETNAME "a.out-i386-linux" 41 44 … … 48 51 static void MY_final_link_callback 49 52 PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *)); 50 static b oolean i386linux_bfd_final_link53 static bfd_boolean i386linux_bfd_final_link 51 54 PARAMS ((bfd *, struct bfd_link_info *)); 52 static b oolean i386linux_write_object_contents PARAMS ((bfd *));53 54 static b oolean55 static bfd_boolean i386linux_write_object_contents PARAMS ((bfd *)); 56 57 static bfd_boolean 55 58 i386linux_bfd_final_link (abfd, info) 56 59 bfd *abfd; … … 65 68 /* Set the machine type correctly. */ 66 69 67 static b oolean70 static bfd_boolean 68 71 i386linux_write_object_contents (abfd) 69 72 bfd *abfd; … … 78 81 WRITE_HEADERS(abfd, execp); 79 82 80 return true;83 return TRUE; 81 84 } 82 85 … … 177 180 PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *, 178 181 bfd_vma, int)); 179 static b oolean linux_link_create_dynamic_sections182 static bfd_boolean linux_link_create_dynamic_sections 180 183 PARAMS ((bfd *, struct bfd_link_info *)); 181 static b oolean linux_add_one_symbol184 static bfd_boolean linux_add_one_symbol 182 185 PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *, 183 bfd_vma, const char *, b oolean,boolean,186 bfd_vma, const char *, bfd_boolean, bfd_boolean, 184 187 struct bfd_link_hash_entry **)); 185 static b oolean linux_tally_symbols188 static bfd_boolean linux_tally_symbols 186 189 PARAMS ((struct linux_link_hash_entry *, PTR)); 187 static b oolean linux_finish_dynamic_link190 static bfd_boolean linux_finish_dynamic_link 188 191 PARAMS ((bfd *, struct bfd_link_info *)); 189 192 … … 225 228 { 226 229 struct linux_link_hash_table *ret; 227 228 ret = ((struct linux_link_hash_table *) 229 bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));230 bfd_size_type amt = sizeof (struct linux_link_hash_table); 231 232 ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt); 230 233 if (ret == (struct linux_link_hash_table *) NULL) 231 234 return (struct bfd_link_hash_table *) NULL; … … 257 260 (aout_link_hash_traverse \ 258 261 (&(table)->root, \ 259 (b oolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func),\262 (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \ 260 263 (info))) 261 264 … … 297 300 create it for now. */ 298 301 299 static b oolean302 static bfd_boolean 300 303 linux_link_create_dynamic_sections (abfd, info) 301 304 bfd *abfd; … … 314 317 || ! bfd_set_section_flags (abfd, s, flags) 315 318 || ! bfd_set_section_alignment (abfd, s, 2)) 316 return false;319 return FALSE; 317 320 s->_raw_size = 0; 318 321 s->contents = 0; 319 322 320 return true;323 return TRUE; 321 324 } 322 325 … … 325 328 tweaking needed for dynamic linking support. */ 326 329 327 static b oolean330 static bfd_boolean 328 331 linux_add_one_symbol (info, abfd, name, flags, section, value, string, 329 332 copy, collect, hashp) … … 335 338 bfd_vma value; 336 339 const char *string; 337 b oolean copy;338 b oolean collect;340 bfd_boolean copy; 341 bfd_boolean collect; 339 342 struct bfd_link_hash_entry **hashp; 340 343 { 341 344 struct linux_link_hash_entry *h; 342 b oolean insert;345 bfd_boolean insert; 343 346 344 347 /* Look up and see if we already have this symbol in the hash table. … … 350 353 confusion is possible. */ 351 354 352 insert = false;355 insert = FALSE; 353 356 354 357 if (! info->relocateable … … 359 362 { 360 363 if (! linux_link_create_dynamic_sections (abfd, info)) 361 return false;364 return FALSE; 362 365 linux_hash_table (info)->dynobj = abfd; 363 insert = true;366 insert = TRUE; 364 367 } 365 368 … … 367 370 && abfd->xvec == info->hash->creator) 368 371 { 369 h = linux_link_hash_lookup (linux_hash_table (info), name, false,370 false, false);372 h = linux_link_hash_lookup (linux_hash_table (info), name, FALSE, 373 FALSE, FALSE); 371 374 if (h != NULL 372 375 && (h->root.root.type == bfd_link_hash_defined … … 380 383 f = new_fixup (info, h, value, ! IS_PLT_SYM (name)); 381 384 if (f == NULL) 382 return false;385 return FALSE; 383 386 f->jump = IS_PLT_SYM (name); 384 387 385 return true;388 return TRUE; 386 389 } 387 390 } … … 391 394 value, string, copy, collect, 392 395 hashp)) 393 return false;396 return FALSE; 394 397 395 398 /* Insert a pointer to our table in the set vector. The dynamic … … 407 410 if (! (_bfd_generic_link_add_one_symbol 408 411 (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS, 409 BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL))) 410 return false; 411 } 412 413 return true; 412 BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL, 413 FALSE, FALSE, NULL))) 414 return FALSE; 415 } 416 417 return TRUE; 414 418 } 415 419 … … 424 428 This function is called via linux_link_hash_traverse. */ 425 429 426 static b oolean430 static bfd_boolean 427 431 linux_tally_symbols (h, data) 428 432 struct linux_link_hash_entry *h; … … 433 437 int is_plt; 434 438 struct linux_link_hash_entry *h1, *h2; 435 boolean exists; 439 bfd_boolean exists; 440 441 if (h->root.root.type == bfd_link_hash_warning) 442 h = (struct linux_link_hash_entry *) h->root.root.u.i.link; 436 443 437 444 if (h->root.root.type == bfd_link_hash_undefined … … 446 453 p = strrchr (name, '_'); 447 454 if (p != NULL) 448 alloc = (char *) bfd_malloc ( strlen (name) + 1);455 alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1); 449 456 450 457 if (p == NULL || alloc == NULL) … … 476 483 (h->root.root.root.string 477 484 + sizeof PLT_REF_PREFIX - 1), 478 false, false, true);485 FALSE, FALSE, TRUE); 479 486 /* h2 does not follow indirect symbols. */ 480 h2 = linux_link_hash_lookup (linux_hash_table (info), 487 h2 = linux_link_hash_lookup (linux_hash_table (info), 481 488 (h->root.root.root.string 482 489 + sizeof PLT_REF_PREFIX - 1), 483 false, false, false);490 FALSE, FALSE, FALSE); 484 491 485 492 /* The real symbol must exist but if it is also an ABS symbol, … … 499 506 fixup. In the end, this relaxes some of the requirements 500 507 about the order of performing fixups. */ 501 exists = false;508 exists = FALSE; 502 509 for (f1 = linux_hash_table (info)->fixup_list; 503 510 f1 != NULL; … … 508 515 continue; 509 516 if (f1->h == h1) 510 exists = true;517 exists = TRUE; 511 518 if (! exists 512 519 && bfd_is_abs_section (h->root.root.u.def.section)) … … 518 525 f1->jump = is_plt; 519 526 f1->builtin = 0; 520 exists = true;527 exists = TRUE; 521 528 } 522 529 if (! exists … … 536 543 symtab. */ 537 544 if (bfd_is_abs_section (h->root.root.u.def.section)) 538 h->root.written = true;539 } 540 541 return true;545 h->root.written = TRUE; 546 } 547 548 return TRUE; 542 549 } 543 550 … … 548 555 are required. */ 549 556 550 b oolean557 bfd_boolean 551 558 bfd_i386linux_size_dynamic_sections (output_bfd, info) 552 559 bfd *output_bfd; … … 557 564 558 565 if (output_bfd->xvec != &MY(vec)) 559 return true;566 return TRUE; 560 567 561 568 /* First find the fixups... */ … … 581 588 if (linux_hash_table (info)->fixup_count > 0) 582 589 abort (); 583 return true;590 return TRUE; 584 591 } 585 592 … … 589 596 if (s != NULL) 590 597 { 591 s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8; 592 s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); 598 s->_raw_size = linux_hash_table (info)->fixup_count + 1; 599 s->_raw_size *= 8; 600 s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); 593 601 if (s->contents == NULL) 594 return false; 595 memset (s->contents, 0, (size_t) s->_raw_size); 596 } 597 598 return true; 602 return FALSE; 603 } 604 605 return TRUE; 599 606 } 600 607 … … 603 610 the stuff we need. */ 604 611 605 static b oolean612 static bfd_boolean 606 613 linux_finish_dynamic_link (output_bfd, info) 607 614 bfd *output_bfd; … … 617 624 618 625 if (linux_hash_table (info)->dynobj == NULL) 619 return true;626 return TRUE; 620 627 621 628 s = bfd_get_section_by_name (linux_hash_table (info)->dynobj, … … 626 633 627 634 #ifdef LINUX_LINK_DEBUG 628 printf ("Fixup table file offset: %x VMA: %x\n", 635 printf ("Fixup table file offset: %x VMA: %x\n", 629 636 os->filepos + s->output_offset, 630 637 os->vma + s->output_offset); … … 632 639 633 640 fixup_table = s->contents; 634 bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table); 641 bfd_put_32 (output_bfd, 642 (bfd_vma) linux_hash_table (info)->fixup_count, fixup_table); 635 643 fixup_table += 4; 636 644 … … 662 670 { 663 671 /* Relative address */ 664 new_addr = new_addr - (f->value + 5); 665 bfd_put_32 (output_bfd, new_addr, fixup_table);672 new_addr = new_addr - (f->value + 5); 673 bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table); 666 674 fixup_table += 4; 667 675 bfd_put_32 (output_bfd, f->value + 1, fixup_table); … … 670 678 else 671 679 { 672 bfd_put_32 (output_bfd, new_addr, fixup_table);680 bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table); 673 681 fixup_table += 4; 674 682 bfd_put_32 (output_bfd, f->value, fixup_table); … … 681 689 { 682 690 /* Special marker so we know to switch to the other type of fixup */ 683 bfd_put_32 (output_bfd, 0, fixup_table);691 bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table); 684 692 fixup_table += 4; 685 bfd_put_32 (output_bfd, 0, fixup_table);693 bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table); 686 694 fixup_table += 4; 687 695 ++fixups_written; … … 709 717 #endif 710 718 711 bfd_put_32 (output_bfd, new_addr, fixup_table);719 bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table); 712 720 fixup_table += 4; 713 721 bfd_put_32 (output_bfd, f->value, fixup_table); … … 722 730 while (linux_hash_table (info)->fixup_count > fixups_written) 723 731 { 724 bfd_put_32 (output_bfd, 0, fixup_table);732 bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table); 725 733 fixup_table += 4; 726 bfd_put_32 (output_bfd, 0, fixup_table);734 bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table); 727 735 fixup_table += 4; 728 736 ++fixups_written; … … 730 738 } 731 739 732 h = linux_link_hash_lookup (linux_hash_table (info), 740 h = linux_link_hash_lookup (linux_hash_table (info), 733 741 "__BUILTIN_FIXUPS__", 734 false, false, false);742 FALSE, FALSE, FALSE); 735 743 736 744 if (h != NULL … … 746 754 #endif 747 755 748 bfd_put_32 (output_bfd, new_addr, fixup_table);756 bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table); 749 757 } 750 758 else 751 bfd_put_32 (output_bfd, 0, fixup_table);752 753 if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)754 return false; 755 756 if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd) 757 758 return false;759 760 return true;759 bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table); 760 761 if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset), 762 SEEK_SET) != 0) 763 return FALSE; 764 765 if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size) 766 return FALSE; 767 768 return TRUE; 761 769 } 762 770 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.