1 // inremental.h -- incremental linking support for gold -*- C++ -*- 2 3 // Copyright 2009, 2010, 2011 Free Software Foundation, Inc. 4 // Written by Mikolaj Zalewski <mikolajz@google.com>. 5 6 // This file is part of gold. 7 8 // This program is free software; you can redistribute it and/or modify 9 // it under the terms of the GNU General Public License as published by 10 // the Free Software Foundation; either version 3 of the License, or 11 // (at your option) any later version. 12 13 // This program is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU General Public License for more details. 17 18 // You should have received a copy of the GNU General Public License 19 // along with this program; if not, write to the Free Software 20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21 // MA 02110-1301, USA. 22 23 #ifndef GOLD_INCREMENTAL_H 24 #define GOLD_INCREMENTAL_H 25 26 #include <map> 27 #include <vector> 28 29 #include "elfcpp_file.h" 30 #include "stringpool.h" 31 #include "workqueue.h" 32 #include "fileread.h" 33 #include "output.h" 34 #include "archive.h" 35 36 namespace gold 37 { 38 39 class Input_argument; 40 class Incremental_inputs_checker; 41 class Incremental_script_entry; 42 class Incremental_object_entry; 43 class Incremental_dynobj_entry; 44 class Incremental_archive_entry; 45 class Incremental_inputs; 46 class Incremental_binary; 47 class Incremental_library; 48 class Object; 49 50 // Incremental input type as stored in .gnu_incremental_inputs. 51 52 enum Incremental_input_type 53 { 54 INCREMENTAL_INPUT_OBJECT = 1, 55 INCREMENTAL_INPUT_ARCHIVE_MEMBER = 2, 56 INCREMENTAL_INPUT_ARCHIVE = 3, 57 INCREMENTAL_INPUT_SHARED_LIBRARY = 4, 58 INCREMENTAL_INPUT_SCRIPT = 5 59 }; 60 61 // Incremental input file flags. 62 // The input file type is stored in the lower eight bits. 63 64 enum Incremental_input_flags 65 { 66 INCREMENTAL_INPUT_IN_SYSTEM_DIR = 0x8000, 67 INCREMENTAL_INPUT_AS_NEEDED = 0x4000 68 }; 69 70 // Symbol flags for the incremental symbol table. 71 // These flags are stored in the top two bits of 72 // the symbol index field. 73 74 enum Incremental_shlib_symbol_flags 75 { 76 // Symbol is defined in this library. 77 INCREMENTAL_SHLIB_SYM_DEF = 2, 78 // Symbol is defined in this library, with a COPY relocation. 79 INCREMENTAL_SHLIB_SYM_COPY = 3 80 }; 81 82 static const int INCREMENTAL_SHLIB_SYM_FLAGS_SHIFT = 30; 83 84 // Return TRUE if a section of type SH_TYPE can be updated in place 85 // during an incremental update. 86 bool 87 can_incremental_update(unsigned int sh_type); 88 89 // Create an Incremental_binary object for FILE. Returns NULL is this is not 90 // possible, e.g. FILE is not an ELF file or has an unsupported target. 91 92 Incremental_binary* 93 open_incremental_binary(Output_file* file); 94 95 // Base class for recording each input file. 96 97 class Incremental_input_entry 98 { 99 public: 100 Incremental_input_entry(Stringpool::Key filename_key, unsigned int arg_serial, 101 Timespec mtime) 102 : filename_key_(filename_key), file_index_(0), offset_(0), info_offset_(0), 103 arg_serial_(arg_serial), mtime_(mtime), is_in_system_directory_(false), 104 as_needed_(false) 105 { } 106 107 virtual 108 ~Incremental_input_entry() 109 { } 110 111 // Return the type of input file. 112 Incremental_input_type 113 type() const 114 { return this->do_type(); } 115 116 // Set the index and section offset of this input file entry. 117 void 118 set_offset(unsigned int file_index, unsigned int offset) 119 { 120 this->file_index_ = file_index; 121 this->offset_ = offset; 122 } 123 124 // Set the section offset of the supplemental information for this entry. 125 void 126 set_info_offset(unsigned int info_offset) 127 { this->info_offset_ = info_offset; } 128 129 // Get the index of this input file entry. 130 unsigned int 131 get_file_index() const 132 { return this->file_index_; } 133 134 // Get the section offset of this input file entry. 135 unsigned int 136 get_offset() const 137 { return this->offset_; } 138 139 // Get the section offset of the supplemental information for this entry. 140 unsigned int 141 get_info_offset() const 142 { return this->info_offset_; } 143 144 // Get the stringpool key for the input filename. 145 Stringpool::Key 146 get_filename_key() const 147 { return this->filename_key_; } 148 149 // Get the serial number of the input file. 150 unsigned int 151 arg_serial() const 152 { return this->arg_serial_; } 153 154 // Get the modification time of the input file. 155 const Timespec& 156 get_mtime() const 157 { return this->mtime_; } 158 159 // Record that the file was found in a system directory. 160 void 161 set_is_in_system_directory() 162 { this->is_in_system_directory_ = true; } 163 164 // Return TRUE if the file was found in a system directory. 165 bool 166 is_in_system_directory() const 167 { return this->is_in_system_directory_; } 168 169 // Record that the file was linked with --as-needed. 170 void 171 set_as_needed() 172 { this->as_needed_ = true; } 173 174 // Return TRUE if the file was linked with --as-needed. 175 bool 176 as_needed() const 177 { return this->as_needed_; } 178 179 // Return a pointer to the derived Incremental_script_entry object. 180 // Return NULL for input entries that are not script files. 181 Incremental_script_entry* 182 script_entry() 183 { return this->do_script_entry(); } 184 185 // Return a pointer to the derived Incremental_object_entry object. 186 // Return NULL for input entries that are not object files. 187 Incremental_object_entry* 188 object_entry() 189 { return this->do_object_entry(); } 190 191 // Return a pointer to the derived Incremental_dynobj_entry object. 192 // Return NULL for input entries that are not shared object files. 193 Incremental_dynobj_entry* 194 dynobj_entry() 195 { return this->do_dynobj_entry(); } 196 197 // Return a pointer to the derived Incremental_archive_entry object. 198 // Return NULL for input entries that are not archive files. 199 Incremental_archive_entry* 200 archive_entry() 201 { return this->do_archive_entry(); } 202 203 protected: 204 // Return the type of input file. 205 virtual Incremental_input_type 206 do_type() const = 0; 207 208 // Return a pointer to the derived Incremental_script_entry object. 209 // Return NULL for input entries that are not script files. 210 virtual Incremental_script_entry* 211 do_script_entry() 212 { return NULL; } 213 214 // Return a pointer to the derived Incremental_object_entry object. 215 // Return NULL for input entries that are not object files. 216 virtual Incremental_object_entry* 217 do_object_entry() 218 { return NULL; } 219 220 // Return a pointer to the derived Incremental_dynobj_entry object. 221 // Return NULL for input entries that are not shared object files. 222 virtual Incremental_dynobj_entry* 223 do_dynobj_entry() 224 { return NULL; } 225 226 // Return a pointer to the derived Incremental_archive_entry object. 227 // Return NULL for input entries that are not archive files. 228 virtual Incremental_archive_entry* 229 do_archive_entry() 230 { return NULL; } 231 232 private: 233 // Key of the filename string in the section stringtable. 234 Stringpool::Key filename_key_; 235 236 // Index of the entry in the output section. 237 unsigned int file_index_; 238 239 // Offset of the entry in the output section. 240 unsigned int offset_; 241 242 // Offset of the extra information in the output section. 243 unsigned int info_offset_; 244 245 // Serial number of the file in the argument list. 246 unsigned int arg_serial_; 247 248 // Last modification time of the file. 249 Timespec mtime_; 250 251 // TRUE if the file was found in a system directory. 252 bool is_in_system_directory_; 253 254 // TRUE if the file was linked with --as-needed. 255 bool as_needed_; 256 }; 257 258 // Information about a script input that will persist during the whole linker 259 // run. Needed only during an incremental build to retrieve the input files 260 // added by this script. 261 262 class Script_info 263 { 264 public: 265 Script_info(const std::string& filename) 266 : filename_(filename), input_file_index_(0), 267 incremental_script_entry_(NULL) 268 { } 269 270 Script_info(const std::string& filename, unsigned int input_file_index) 271 : filename_(filename), input_file_index_(input_file_index), 272 incremental_script_entry_(NULL) 273 { } 274 275 // Store a pointer to the incremental information for this script. 276 void 277 set_incremental_info(Incremental_script_entry* entry) 278 { this->incremental_script_entry_ = entry; } 279 280 // Return the filename. 281 const std::string& 282 filename() const 283 { return this->filename_; } 284 285 // Return the input file index. 286 unsigned int 287 input_file_index() const 288 { return this->input_file_index_; } 289 290 // Return the pointer to the incremental information for this script. 291 Incremental_script_entry* 292 incremental_info() const 293 { return this->incremental_script_entry_; } 294 295 private: 296 const std::string filename_; 297 unsigned int input_file_index_; 298 Incremental_script_entry* incremental_script_entry_; 299 }; 300 301 // Class for recording input scripts. 302 303 class Incremental_script_entry : public Incremental_input_entry 304 { 305 public: 306 Incremental_script_entry(Stringpool::Key filename_key, 307 unsigned int arg_serial, Script_info* script, 308 Timespec mtime) 309 : Incremental_input_entry(filename_key, arg_serial, mtime), 310 script_(script), objects_() 311 { } 312 313 // Add a member object to the archive. 314 void 315 add_object(Incremental_input_entry* obj_entry) 316 { 317 this->objects_.push_back(obj_entry); 318 } 319 320 // Return the number of objects included by this script. 321 unsigned int 322 get_object_count() 323 { return this->objects_.size(); } 324 325 // Return the Nth object. 326 Incremental_input_entry* 327 get_object(unsigned int n) 328 { 329 gold_assert(n < this->objects_.size()); 330 return this->objects_[n]; 331 } 332 333 protected: 334 virtual Incremental_input_type 335 do_type() const 336 { return INCREMENTAL_INPUT_SCRIPT; } 337 338 // Return a pointer to the derived Incremental_script_entry object. 339 virtual Incremental_script_entry* 340 do_script_entry() 341 { return this; } 342 343 private: 344 // Information about the script file. 345 Script_info* script_; 346 // Objects that have been included by this script. 347 std::vector<Incremental_input_entry*> objects_; 348 }; 349 350 // Class for recording input object files. 351 352 class Incremental_object_entry : public Incremental_input_entry 353 { 354 public: 355 Incremental_object_entry(Stringpool::Key filename_key, Object* obj, 356 unsigned int arg_serial, Timespec mtime) 357 : Incremental_input_entry(filename_key, arg_serial, mtime), obj_(obj), 358 is_member_(false), sections_(), groups_() 359 { this->sections_.reserve(obj->shnum()); } 360 361 // Get the object. 362 Object* 363 object() const 364 { return this->obj_; } 365 366 // Record that this object is an archive member. 367 void 368 set_is_member() 369 { this->is_member_ = true; } 370 371 // Return true if this object is an archive member. 372 bool 373 is_member() const 374 { return this->is_member_; } 375 376 // Add an input section. 377 void 378 add_input_section(unsigned int shndx, Stringpool::Key name_key, off_t sh_size) 379 { this->sections_.push_back(Input_section(shndx, name_key, sh_size)); } 380 381 // Return the number of input sections in this object. 382 unsigned int 383 get_input_section_count() const 384 { return this->sections_.size(); } 385 386 // Return the input section index for the Nth input section. 387 Stringpool::Key 388 get_input_section_index(unsigned int n) const 389 { return this->sections_[n].shndx_; } 390 391 // Return the stringpool key of the Nth input section. 392 Stringpool::Key 393 get_input_section_name_key(unsigned int n) const 394 { return this->sections_[n].name_key_; } 395 396 // Return the size of the Nth input section. 397 off_t 398 get_input_section_size(unsigned int n) const 399 { return this->sections_[n].sh_size_; } 400 401 // Add a kept COMDAT group. 402 void 403 add_comdat_group(Stringpool::Key signature_key) 404 { this->groups_.push_back(signature_key); } 405 406 // Return the number of COMDAT groups. 407 unsigned int 408 get_comdat_group_count() const 409 { return this->groups_.size(); } 410 411 // Return the stringpool key for the signature of the Nth comdat group. 412 Stringpool::Key 413 get_comdat_signature_key(unsigned int n) const 414 { return this->groups_[n]; } 415 416 protected: 417 virtual Incremental_input_type 418 do_type() const 419 { 420 return (this->is_member_ 421 ? INCREMENTAL_INPUT_ARCHIVE_MEMBER 422 : INCREMENTAL_INPUT_OBJECT); 423 } 424 425 // Return a pointer to the derived Incremental_object_entry object. 426 virtual Incremental_object_entry* 427 do_object_entry() 428 { return this; } 429 430 private: 431 // The object file itself. 432 Object* obj_; 433 434 // Whether this object is an archive member. 435 bool is_member_; 436 437 // Input sections. 438 struct Input_section 439 { 440 Input_section(unsigned int shndx, Stringpool::Key name_key, off_t sh_size) 441 : shndx_(shndx), name_key_(name_key), sh_size_(sh_size) 442 { } 443 unsigned int shndx_; 444 Stringpool::Key name_key_; 445 off_t sh_size_; 446 }; 447 std::vector<Input_section> sections_; 448 449 // COMDAT groups. 450 std::vector<Stringpool::Key> groups_; 451 }; 452 453 // Class for recording shared library input files. 454 455 class Incremental_dynobj_entry : public Incremental_input_entry 456 { 457 public: 458 Incremental_dynobj_entry(Stringpool::Key filename_key, 459 Stringpool::Key soname_key, Object* obj, 460 unsigned int arg_serial, Timespec mtime) 461 : Incremental_input_entry(filename_key, arg_serial, mtime), 462 soname_key_(soname_key), obj_(obj) 463 { } 464 465 // Get the object. 466 Object* 467 object() const 468 { return this->obj_; } 469 470 // Get the stringpool key for the soname. 471 Stringpool::Key 472 get_soname_key() const 473 { return this->soname_key_; } 474 475 protected: 476 virtual Incremental_input_type 477 do_type() const 478 { return INCREMENTAL_INPUT_SHARED_LIBRARY; } 479 480 // Return a pointer to the derived Incremental_dynobj_entry object. 481 virtual Incremental_dynobj_entry* 482 do_dynobj_entry() 483 { return this; } 484 485 private: 486 // Key of the soname string in the section stringtable. 487 Stringpool::Key soname_key_; 488 489 // The object file itself. 490 Object* obj_; 491 }; 492 493 // Class for recording archive library input files. 494 495 class Incremental_archive_entry : public Incremental_input_entry 496 { 497 public: 498 Incremental_archive_entry(Stringpool::Key filename_key, 499 unsigned int arg_serial, Timespec mtime) 500 : Incremental_input_entry(filename_key, arg_serial, mtime), members_(), 501 unused_syms_() 502 { } 503 504 // Add a member object to the archive. 505 void 506 add_object(Incremental_object_entry* obj_entry) 507 { 508 this->members_.push_back(obj_entry); 509 obj_entry->set_is_member(); 510 } 511 512 // Add an unused global symbol to the archive. 513 void 514 add_unused_global_symbol(Stringpool::Key symbol_key) 515 { this->unused_syms_.push_back(symbol_key); } 516 517 // Return the number of member objects included in the link. 518 unsigned int 519 get_member_count() 520 { return this->members_.size(); } 521 522 // Return the Nth member object. 523 Incremental_object_entry* 524 get_member(unsigned int n) 525 { return this->members_[n]; } 526 527 // Return the number of unused global symbols in this archive. 528 unsigned int 529 get_unused_global_symbol_count() 530 { return this->unused_syms_.size(); } 531 532 // Return the Nth unused global symbol. 533 Stringpool::Key 534 get_unused_global_symbol(unsigned int n) 535 { return this->unused_syms_[n]; } 536 537 protected: 538 virtual Incremental_input_type 539 do_type() const 540 { return INCREMENTAL_INPUT_ARCHIVE; } 541 542 // Return a pointer to the derived Incremental_archive_entry object. 543 virtual Incremental_archive_entry* 544 do_archive_entry() 545 { return this; } 546 547 private: 548 // Members of the archive that have been included in the link. 549 std::vector<Incremental_object_entry*> members_; 550 551 // Unused global symbols from this archive. 552 std::vector<Stringpool::Key> unused_syms_; 553 }; 554 555 // This class contains the information needed during an incremental 556 // build about the inputs necessary to build the .gnu_incremental_inputs. 557 558 class Incremental_inputs 559 { 560 public: 561 typedef std::vector<Incremental_input_entry*> Input_list; 562 563 Incremental_inputs() 564 : inputs_(), command_line_(), command_line_key_(0), 565 strtab_(new Stringpool()), current_object_(NULL), 566 current_object_entry_(NULL), inputs_section_(NULL), 567 symtab_section_(NULL), relocs_section_(NULL), 568 reloc_count_(0) 569 { } 570 571 ~Incremental_inputs() { delete this->strtab_; } 572 573 // Record the command line. 574 void 575 report_command_line(int argc, const char* const* argv); 576 577 // Record the initial info for archive file ARCHIVE. 578 void 579 report_archive_begin(Library_base* arch, unsigned int arg_serial, 580 Script_info* script_info); 581 582 // Record the final info for archive file ARCHIVE. 583 void 584 report_archive_end(Library_base* arch); 585 586 // Record the info for object file OBJ. If ARCH is not NULL, 587 // attach the object file to the archive. 588 void 589 report_object(Object* obj, unsigned int arg_serial, Library_base* arch, 590 Script_info* script_info); 591 592 // Record an input section belonging to object file OBJ. 593 void 594 report_input_section(Object* obj, unsigned int shndx, const char* name, 595 off_t sh_size); 596 597 // Record a kept COMDAT group belonging to object file OBJ. 598 void 599 report_comdat_group(Object* obj, const char* name); 600 601 // Record the info for input script SCRIPT. 602 void 603 report_script(Script_info* script, unsigned int arg_serial, 604 Timespec mtime); 605 606 // Return the running count of incremental relocations. 607 unsigned int 608 get_reloc_count() const 609 { return this->reloc_count_; } 610 611 // Update the running count of incremental relocations. 612 void 613 set_reloc_count(unsigned int count) 614 { this->reloc_count_ = count; } 615 616 // Prepare for layout. Called from Layout::finalize. 617 void 618 finalize(); 619 620 // Create the .gnu_incremental_inputs and related sections. 621 void 622 create_data_sections(Symbol_table* symtab); 623 624 // Return the .gnu_incremental_inputs section. 625 Output_section_data* 626 inputs_section() const 627 { return this->inputs_section_; } 628 629 // Return the .gnu_incremental_symtab section. 630 Output_data_space* 631 symtab_section() const 632 { return this->symtab_section_; } 633 634 // Return the .gnu_incremental_relocs section. 635 Output_data_space* 636 relocs_section() const 637 { return this->relocs_section_; } 638 639 // Return the .gnu_incremental_got_plt section. 640 Output_data_space* 641 got_plt_section() const 642 { return this->got_plt_section_; } 643 644 // Return the .gnu_incremental_strtab stringpool. 645 Stringpool* 646 get_stringpool() const 647 { return this->strtab_; } 648 649 // Return the canonical form of the command line, as will be stored in 650 // .gnu_incremental_strtab. 651 const std::string& 652 command_line() const 653 { return this->command_line_; } 654 655 // Return the stringpool key of the command line. 656 Stringpool::Key 657 command_line_key() const 658 { return this->command_line_key_; } 659 660 // Return the number of input files. 661 int 662 input_file_count() const 663 { return this->inputs_.size(); } 664 665 // Return the input files. 666 const Input_list& 667 input_files() const 668 { return this->inputs_; } 669 670 // Return the sh_entsize value for the .gnu_incremental_relocs section. 671 unsigned int 672 relocs_entsize() const; 673 674 private: 675 // The list of input files. 676 Input_list inputs_; 677 678 // Canonical form of the command line, as will be stored in 679 // .gnu_incremental_strtab. 680 std::string command_line_; 681 682 // The key of the command line string in the string pool. 683 Stringpool::Key command_line_key_; 684 685 // The .gnu_incremental_strtab string pool associated with the 686 // .gnu_incremental_inputs. 687 Stringpool* strtab_; 688 689 // Keep track of the object currently being processed. 690 Object* current_object_; 691 Incremental_object_entry* current_object_entry_; 692 693 // The .gnu_incremental_inputs section. 694 Output_section_data* inputs_section_; 695 696 // The .gnu_incremental_symtab section. 697 Output_data_space* symtab_section_; 698 699 // The .gnu_incremental_relocs section. 700 Output_data_space* relocs_section_; 701 702 // The .gnu_incremental_got_plt section. 703 Output_data_space* got_plt_section_; 704 705 // Total count of incremental relocations. Updated during Scan_relocs 706 // phase at the completion of each object file. 707 unsigned int reloc_count_; 708 }; 709 710 // Reader class for global symbol info from an object file entry in 711 // the .gnu_incremental_inputs section. 712 713 template<bool big_endian> 714 class Incremental_global_symbol_reader 715 { 716 private: 717 typedef elfcpp::Swap<32, big_endian> Swap32; 718 719 public: 720 Incremental_global_symbol_reader(const unsigned char* p) 721 : p_(p) 722 { } 723 724 unsigned int 725 output_symndx() const 726 { return Swap32::readval(this->p_); } 727 728 unsigned int 729 shndx() const 730 { return Swap32::readval(this->p_ + 4); } 731 732 unsigned int 733 next_offset() const 734 { return Swap32::readval(this->p_ + 8); } 735 736 unsigned int 737 reloc_count() const 738 { return Swap32::readval(this->p_ + 12); } 739 740 unsigned int 741 reloc_offset() const 742 { return Swap32::readval(this->p_ + 16); } 743 744 private: 745 // Base address of the symbol entry. 746 const unsigned char* p_; 747 }; 748 749 // Reader class for .gnu_incremental_inputs section. 750 751 template<int size, bool big_endian> 752 class Incremental_inputs_reader 753 { 754 private: 755 typedef elfcpp::Swap<size, big_endian> Swap; 756 typedef elfcpp::Swap<16, big_endian> Swap16; 757 typedef elfcpp::Swap<32, big_endian> Swap32; 758 typedef elfcpp::Swap<64, big_endian> Swap64; 759 760 public: 761 // Size of the .gnu_incremental_inputs header. 762 // (3 x 4-byte fields, plus 4 bytes padding.) 763 static const unsigned int header_size = 16; 764 // Size of an input file entry. 765 // (2 x 4-byte fields, 1 x 12-byte field, 2 x 2-byte fields.) 766 static const unsigned int input_entry_size = 24; 767 // Size of the first part of the supplemental info block for 768 // relocatable objects and archive members. 769 // (7 x 4-byte fields, plus 4 bytes padding.) 770 static const unsigned int object_info_size = 32; 771 // Size of an input section entry. 772 // (2 x 4-byte fields, 2 x address-sized fields.) 773 static const unsigned int input_section_entry_size = 8 + 2 * size / 8; 774 // Size of a global symbol entry in the supplemental info block. 775 // (5 x 4-byte fields.) 776 static const unsigned int global_sym_entry_size = 20; 777 778 Incremental_inputs_reader() 779 : p_(NULL), strtab_(NULL, 0), input_file_count_(0) 780 { } 781 782 Incremental_inputs_reader(const unsigned char* p, 783 const elfcpp::Elf_strtab& strtab) 784 : p_(p), strtab_(strtab) 785 { this->input_file_count_ = Swap32::readval(this->p_ + 4); } 786 787 // Return the version number. 788 unsigned int 789 version() const 790 { return Swap32::readval(this->p_); } 791 792 // Return the count of input file entries. 793 unsigned int 794 input_file_count() const 795 { return this->input_file_count_; } 796 797 // Return the command line. 798 const char* 799 command_line() const 800 { 801 unsigned int offset = Swap32::readval(this->p_ + 8); 802 return this->get_string(offset); 803 } 804 805 // Reader class for an input file entry and its supplemental info. 806 class Incremental_input_entry_reader 807 { 808 private: 809 static const unsigned int object_info_size = 810 Incremental_inputs_reader<size, big_endian>::object_info_size; 811 static const unsigned int input_section_entry_size = 812 Incremental_inputs_reader<size, big_endian>::input_section_entry_size; 813 static const unsigned int global_sym_entry_size = 814 Incremental_inputs_reader<size, big_endian>::global_sym_entry_size; 815 816 public: 817 Incremental_input_entry_reader(const Incremental_inputs_reader* inputs, 818 unsigned int offset) 819 : inputs_(inputs), offset_(offset) 820 { 821 this->info_offset_ = Swap32::readval(inputs->p_ + offset + 4); 822 this->flags_ = Swap16::readval(this->inputs_->p_ + offset + 20); 823 } 824 825 // Return the filename. 826 const char* 827 filename() const 828 { 829 unsigned int offset = Swap32::readval(this->inputs_->p_ + this->offset_); 830 return this->inputs_->get_string(offset); 831 } 832 833 // Return the argument serial number. 834 unsigned int 835 arg_serial() const 836 { 837 return Swap16::readval(this->inputs_->p_ + this->offset_ + 22); 838 } 839 840 // Return the timestamp. 841 Timespec 842 get_mtime() const 843 { 844 Timespec t; 845 const unsigned char* p = this->inputs_->p_ + this->offset_ + 8; 846 t.seconds = Swap64::readval(p); 847 t.nanoseconds = Swap32::readval(p+8); 848 return t; 849 } 850 851 // Return the type of input file. 852 Incremental_input_type 853 type() const 854 { return static_cast<Incremental_input_type>(this->flags_ & 0xff); } 855 856 // Return TRUE if the file was found in a system directory. 857 bool 858 is_in_system_directory() const 859 { return (this->flags_ & INCREMENTAL_INPUT_IN_SYSTEM_DIR) != 0; } 860 861 // Return TRUE if the file was linked with --as-needed. 862 bool 863 as_needed() const 864 { return (this->flags_ & INCREMENTAL_INPUT_AS_NEEDED) != 0; } 865 866 // Return the input section count -- for objects only. 867 unsigned int 868 get_input_section_count() const 869 { 870 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 871 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 872 return Swap32::readval(this->inputs_->p_ + this->info_offset_); 873 } 874 875 // Return the soname -- for shared libraries only. 876 const char* 877 get_soname() const 878 { 879 gold_assert(this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY); 880 unsigned int offset = Swap32::readval(this->inputs_->p_ 881 + this->info_offset_); 882 return this->inputs_->get_string(offset); 883 } 884 885 // Return the offset of the supplemental info for symbol SYMNDX -- 886 // for objects only. 887 unsigned int 888 get_symbol_offset(unsigned int symndx) const 889 { 890 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 891 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 892 893 unsigned int section_count = this->get_input_section_count(); 894 return (this->info_offset_ 895 + this->object_info_size 896 + section_count * this->input_section_entry_size 897 + symndx * this->global_sym_entry_size); 898 } 899 900 // Return the global symbol count -- for objects & shared libraries only. 901 unsigned int 902 get_global_symbol_count() const 903 { 904 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 905 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER 906 || this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY); 907 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 4); 908 } 909 910 // Return the offset of the first local symbol -- for objects only. 911 unsigned int 912 get_local_symbol_offset() const 913 { 914 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 915 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 916 917 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 8); 918 } 919 920 // Return the local symbol count -- for objects only. 921 unsigned int 922 get_local_symbol_count() const 923 { 924 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 925 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 926 927 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 12); 928 } 929 930 // Return the index of the first dynamic relocation -- for objects only. 931 unsigned int 932 get_first_dyn_reloc() const 933 { 934 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 935 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 936 937 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 16); 938 } 939 940 // Return the dynamic relocation count -- for objects only. 941 unsigned int 942 get_dyn_reloc_count() const 943 { 944 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 945 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 946 947 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 20); 948 } 949 950 // Return the COMDAT group count -- for objects only. 951 unsigned int 952 get_comdat_group_count() const 953 { 954 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 955 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 956 957 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 24); 958 } 959 960 // Return the object count -- for scripts only. 961 unsigned int 962 get_object_count() const 963 { 964 gold_assert(this->type() == INCREMENTAL_INPUT_SCRIPT); 965 return Swap32::readval(this->inputs_->p_ + this->info_offset_); 966 } 967 968 // Return the input file offset for object N -- for scripts only. 969 unsigned int 970 get_object_offset(unsigned int n) const 971 { 972 gold_assert(this->type() == INCREMENTAL_INPUT_SCRIPT); 973 return Swap32::readval(this->inputs_->p_ + this->info_offset_ 974 + 4 + n * 4); 975 } 976 977 // Return the member count -- for archives only. 978 unsigned int 979 get_member_count() const 980 { 981 gold_assert(this->type() == INCREMENTAL_INPUT_ARCHIVE); 982 return Swap32::readval(this->inputs_->p_ + this->info_offset_); 983 } 984 985 // Return the unused symbol count -- for archives only. 986 unsigned int 987 get_unused_symbol_count() const 988 { 989 gold_assert(this->type() == INCREMENTAL_INPUT_ARCHIVE); 990 return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 4); 991 } 992 993 // Return the input file offset for archive member N -- for archives only. 994 unsigned int 995 get_member_offset(unsigned int n) const 996 { 997 gold_assert(this->type() == INCREMENTAL_INPUT_ARCHIVE); 998 return Swap32::readval(this->inputs_->p_ + this->info_offset_ 999 + 8 + n * 4); 1000 } 1001 1002 // Return the Nth unused global symbol -- for archives only. 1003 const char* 1004 get_unused_symbol(unsigned int n) const 1005 { 1006 gold_assert(this->type() == INCREMENTAL_INPUT_ARCHIVE); 1007 unsigned int member_count = this->get_member_count(); 1008 unsigned int offset = Swap32::readval(this->inputs_->p_ 1009 + this->info_offset_ + 8 1010 + member_count * 4 1011 + n * 4); 1012 return this->inputs_->get_string(offset); 1013 } 1014 1015 // Information about an input section. 1016 struct Input_section_info 1017 { 1018 const char* name; 1019 unsigned int output_shndx; 1020 off_t sh_offset; 1021 off_t sh_size; 1022 }; 1023 1024 // Return info about the Nth input section -- for objects only. 1025 Input_section_info 1026 get_input_section(unsigned int n) const 1027 { 1028 Input_section_info info; 1029 const unsigned char* p = (this->inputs_->p_ 1030 + this->info_offset_ 1031 + this->object_info_size 1032 + n * this->input_section_entry_size); 1033 unsigned int name_offset = Swap32::readval(p); 1034 info.name = this->inputs_->get_string(name_offset); 1035 info.output_shndx = Swap32::readval(p + 4); 1036 info.sh_offset = Swap::readval(p + 8); 1037 info.sh_size = Swap::readval(p + 8 + size / 8); 1038 return info; 1039 } 1040 1041 // Return info about the Nth global symbol -- for objects only. 1042 Incremental_global_symbol_reader<big_endian> 1043 get_global_symbol_reader(unsigned int n) const 1044 { 1045 gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT 1046 || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); 1047 unsigned int section_count = this->get_input_section_count(); 1048 const unsigned char* p = (this->inputs_->p_ 1049 + this->info_offset_ 1050 + this->object_info_size 1051 + section_count * this->input_section_entry_size 1052 + n * this->global_sym_entry_size); 1053 return Incremental_global_symbol_reader<big_endian>(p); 1054 } 1055 1056 // Return the signature of the Nth comdat group -- for objects only. 1057 const char* 1058 get_comdat_group_signature(unsigned int n) const 1059 { 1060 unsigned int section_count = this->get_input_section_count(); 1061 unsigned int symbol_count = this->get_global_symbol_count(); 1062 const unsigned char* p = (this->inputs_->p_ 1063 + this->info_offset_ 1064 + this->object_info_size 1065 + section_count * this->input_section_entry_size 1066 + symbol_count * this->global_sym_entry_size 1067 + n * 4); 1068 unsigned int name_offset = Swap32::readval(p); 1069 return this->inputs_->get_string(name_offset); 1070 } 1071 1072 // Return the output symbol index for the Nth global symbol -- for shared 1073 // libraries only. Sets *IS_DEF to TRUE if the symbol is defined in this 1074 // input file. Sets *IS_COPY to TRUE if the symbol was copied from this 1075 // input file with a COPY relocation. 1076 unsigned int 1077 get_output_symbol_index(unsigned int n, bool* is_def, bool* is_copy) 1078 { 1079 gold_assert(this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY); 1080 const unsigned char* p = (this->inputs_->p_ 1081 + this->info_offset_ + 8 1082 + n * 4); 1083 unsigned int output_symndx = Swap32::readval(p); 1084 unsigned int flags = output_symndx >> INCREMENTAL_SHLIB_SYM_FLAGS_SHIFT; 1085 output_symndx &= ((1U << INCREMENTAL_SHLIB_SYM_FLAGS_SHIFT) - 1); 1086 switch (flags) 1087 { 1088 case INCREMENTAL_SHLIB_SYM_DEF: 1089 *is_def = true; 1090 *is_copy = false; 1091 break; 1092 case INCREMENTAL_SHLIB_SYM_COPY: 1093 *is_def = true; 1094 *is_copy = true; 1095 break; 1096 default: 1097 *is_def = false; 1098 *is_copy = false; 1099 } 1100 return output_symndx; 1101 } 1102 1103 private: 1104 // The reader instance for the containing section. 1105 const Incremental_inputs_reader* inputs_; 1106 // The flags, including the type of input file. 1107 unsigned int flags_; 1108 // Section offset to the input file entry. 1109 unsigned int offset_; 1110 // Section offset to the supplemental info for the input file. 1111 unsigned int info_offset_; 1112 }; 1113 1114 // Return the offset of an input file entry given its index N. 1115 unsigned int 1116 input_file_offset(unsigned int n) const 1117 { 1118 gold_assert(n < this->input_file_count_); 1119 return this->header_size + n * this->input_entry_size; 1120 } 1121 1122 // Return the index of an input file entry given its OFFSET. 1123 unsigned int 1124 input_file_index(unsigned int offset) const 1125 { 1126 int n = ((offset - this->header_size) / this->input_entry_size); 1127 gold_assert(input_file_offset(n) == offset); 1128 return n; 1129 } 1130 1131 // Return a reader for the Nth input file entry. 1132 Incremental_input_entry_reader 1133 input_file(unsigned int n) const 1134 { return Incremental_input_entry_reader(this, this->input_file_offset(n)); } 1135 1136 // Return a reader for the input file entry at OFFSET. 1137 Incremental_input_entry_reader 1138 input_file_at_offset(unsigned int offset) const 1139 { 1140 gold_assert(offset < (this->header_size 1141 + this->input_file_count_ * this->input_entry_size)); 1142 return Incremental_input_entry_reader(this, offset); 1143 } 1144 1145 // Return a reader for the global symbol info at OFFSET. 1146 Incremental_global_symbol_reader<big_endian> 1147 global_symbol_reader_at_offset(unsigned int offset) const 1148 { 1149 const unsigned char* p = this->p_ + offset; 1150 return Incremental_global_symbol_reader<big_endian>(p); 1151 } 1152 1153 private: 1154 // Lookup a string in the ELF string table. 1155 const char* get_string(unsigned int offset) const 1156 { 1157 const char* s; 1158 if (this->strtab_.get_c_string(offset, &s)) 1159 return s; 1160 return NULL; 1161 } 1162 1163 // Base address of the .gnu_incremental_inputs section. 1164 const unsigned char* p_; 1165 // The associated ELF string table. 1166 elfcpp::Elf_strtab strtab_; 1167 // The number of input file entries in this section. 1168 unsigned int input_file_count_; 1169 }; 1170 1171 // Reader class for the .gnu_incremental_symtab section. 1172 1173 template<bool big_endian> 1174 class Incremental_symtab_reader 1175 { 1176 public: 1177 Incremental_symtab_reader() 1178 : p_(NULL), len_(0) 1179 { } 1180 1181 Incremental_symtab_reader(const unsigned char* p, off_t len) 1182 : p_(p), len_(len) 1183 { } 1184 1185 // Return the count of symbols in this section. 1186 unsigned int 1187 symbol_count() const 1188 { return static_cast<unsigned int>(this->len_ / 4); } 1189 1190 // Return the list head for symbol table entry N. 1191 unsigned int 1192 get_list_head(unsigned int n) const 1193 { return elfcpp::Swap<32, big_endian>::readval(this->p_ + 4 * n); } 1194 1195 private: 1196 // Base address of the .gnu_incremental_relocs section. 1197 const unsigned char* p_; 1198 // Size of the section. 1199 off_t len_; 1200 }; 1201 1202 // Reader class for the .gnu_incremental_relocs section. 1203 1204 template<int size, bool big_endian> 1205 class Incremental_relocs_reader 1206 { 1207 private: 1208 // Size of each field. 1209 static const unsigned int field_size = size / 8; 1210 1211 public: 1212 typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; 1213 typedef typename elfcpp::Elf_types<size>::Elf_Swxword Addend; 1214 1215 // Size of each entry. 1216 static const unsigned int reloc_size = 8 + 2 * field_size; 1217 1218 Incremental_relocs_reader() 1219 : p_(NULL), len_(0) 1220 { } 1221 1222 Incremental_relocs_reader(const unsigned char* p, off_t len) 1223 : p_(p), len_(len) 1224 { } 1225 1226 // Return the count of relocations in this section. 1227 unsigned int 1228 reloc_count() const 1229 { return static_cast<unsigned int>(this->len_ / reloc_size); } 1230 1231 // Return the relocation type for relocation entry at offset OFF. 1232 unsigned int 1233 get_r_type(unsigned int off) const 1234 { return elfcpp::Swap<32, big_endian>::readval(this->p_ + off); } 1235 1236 // Return the output section index for relocation entry at offset OFF. 1237 unsigned int 1238 get_r_shndx(unsigned int off) const 1239 { return elfcpp::Swap<32, big_endian>::readval(this->p_ + off + 4); } 1240 1241 // Return the output section offset for relocation entry at offset OFF. 1242 Address 1243 get_r_offset(unsigned int off) const 1244 { return elfcpp::Swap<size, big_endian>::readval(this->p_ + off + 8); } 1245 1246 // Return the addend for relocation entry at offset OFF. 1247 Addend 1248 get_r_addend(unsigned int off) const 1249 { 1250 return elfcpp::Swap<size, big_endian>::readval(this->p_ + off + 8 1251 + this->field_size); 1252 } 1253 1254 // Return a pointer to the relocation entry at offset OFF. 1255 const unsigned char* 1256 data(unsigned int off) const 1257 { return this->p_ + off; } 1258 1259 private: 1260 // Base address of the .gnu_incremental_relocs section. 1261 const unsigned char* p_; 1262 // Size of the section. 1263 off_t len_; 1264 }; 1265 1266 // Reader class for the .gnu_incremental_got_plt section. 1267 1268 template<bool big_endian> 1269 class Incremental_got_plt_reader 1270 { 1271 public: 1272 Incremental_got_plt_reader() 1273 : p_(NULL), got_count_(0), got_desc_p_(NULL), plt_desc_p_(NULL) 1274 { } 1275 1276 Incremental_got_plt_reader(const unsigned char* p) : p_(p) 1277 { 1278 this->got_count_ = elfcpp::Swap<32, big_endian>::readval(p); 1279 this->got_desc_p_ = p + 8 + ((this->got_count_ + 3) & ~3); 1280 this->plt_desc_p_ = this->got_desc_p_ + this->got_count_ * 8; 1281 } 1282 1283 // Return the GOT entry count. 1284 unsigned int 1285 get_got_entry_count() const 1286 { 1287 return this->got_count_; 1288 } 1289 1290 // Return the PLT entry count. 1291 unsigned int 1292 get_plt_entry_count() const 1293 { 1294 return elfcpp::Swap<32, big_endian>::readval(this->p_ + 4); 1295 } 1296 1297 // Return the GOT type for GOT entry N. 1298 unsigned int 1299 get_got_type(unsigned int n) 1300 { 1301 return this->p_[8 + n]; 1302 } 1303 1304 // Return the symbol index for GOT entry N. 1305 unsigned int 1306 get_got_symndx(unsigned int n) 1307 { 1308 return elfcpp::Swap<32, big_endian>::readval(this->got_desc_p_ + n * 8); 1309 } 1310 1311 // Return the input file index for GOT entry N. 1312 unsigned int 1313 get_got_input_index(unsigned int n) 1314 { 1315 return elfcpp::Swap<32, big_endian>::readval(this->got_desc_p_ + n * 8 + 4); 1316 } 1317 1318 // Return the PLT descriptor for PLT entry N. 1319 unsigned int 1320 get_plt_desc(unsigned int n) 1321 { 1322 return elfcpp::Swap<32, big_endian>::readval(this->plt_desc_p_ + n * 4); 1323 } 1324 1325 private: 1326 // Base address of the .gnu_incremental_got_plt section. 1327 const unsigned char* p_; 1328 // GOT entry count. 1329 unsigned int got_count_; 1330 // Base address of the GOT descriptor array. 1331 const unsigned char* got_desc_p_; 1332 // Base address of the PLT descriptor array. 1333 const unsigned char* plt_desc_p_; 1334 }; 1335 1336 // An object representing the ELF file we edit during an incremental build. 1337 // Similar to Object or Dynobj, but operates on Output_file and contains 1338 // methods to support incremental updating. This is the abstract parent class 1339 // implemented in Sized_incremental_binary<size, big_endian> for a specific 1340 // endianness and size. 1341 1342 class Incremental_binary 1343 { 1344 public: 1345 Incremental_binary(Output_file* output, Target* target) 1346 : input_args_map_(), library_map_(), script_map_(), 1347 output_(output), target_(target) 1348 { } 1349 1350 virtual 1351 ~Incremental_binary() 1352 { } 1353 1354 // Check the .gnu_incremental_inputs section to see whether an incremental 1355 // build is possible. 1356 bool 1357 check_inputs(const Command_line& cmdline, 1358 Incremental_inputs* incremental_inputs) 1359 { return this->do_check_inputs(cmdline, incremental_inputs); } 1360 1361 // Report an error. 1362 void 1363 error(const char* format, ...) const ATTRIBUTE_PRINTF_2; 1364 1365 // Proxy class for a sized Incremental_input_entry_reader. 1366 1367 class Input_reader 1368 { 1369 public: 1370 Input_reader() 1371 { } 1372 1373 virtual 1374 ~Input_reader() 1375 { } 1376 1377 const char* 1378 filename() const 1379 { return this->do_filename(); } 1380 1381 Timespec 1382 get_mtime() const 1383 { return this->do_get_mtime(); } 1384 1385 Incremental_input_type 1386 type() const 1387 { return this->do_type(); } 1388 1389 unsigned int 1390 arg_serial() const 1391 { return this->do_arg_serial(); } 1392 1393 unsigned int 1394 get_unused_symbol_count() const 1395 { return this->do_get_unused_symbol_count(); } 1396 1397 const char* 1398 get_unused_symbol(unsigned int n) const 1399 { return this->do_get_unused_symbol(n); } 1400 1401 protected: 1402 virtual const char* 1403 do_filename() const = 0; 1404 1405 virtual Timespec 1406 do_get_mtime() const = 0; 1407 1408 virtual Incremental_input_type 1409 do_type() const = 0; 1410 1411 virtual unsigned int 1412 do_arg_serial() const = 0; 1413 1414 virtual unsigned int 1415 do_get_unused_symbol_count() const = 0; 1416 1417 virtual const char* 1418 do_get_unused_symbol(unsigned int n) const = 0; 1419 }; 1420 1421 // Return the number of input files. 1422 unsigned int 1423 input_file_count() const 1424 { return this->do_input_file_count(); } 1425 1426 // Return an Input_reader for input file N. 1427 const Input_reader* 1428 get_input_reader(unsigned int n) const 1429 { return this->do_get_input_reader(n); } 1430 1431 // Return TRUE if the input file N has changed since the last link. 1432 bool 1433 file_has_changed(unsigned int n) const 1434 { return this->do_file_has_changed(n); } 1435 1436 // Return the Input_argument for input file N. Returns NULL if 1437 // the Input_argument is not available. 1438 const Input_argument* 1439 get_input_argument(unsigned int n) const 1440 { 1441 const Input_reader* input_file = this->do_get_input_reader(n); 1442 unsigned int arg_serial = input_file->arg_serial(); 1443 if (arg_serial == 0 || arg_serial > this->input_args_map_.size()) 1444 return NULL; 1445 return this->input_args_map_[arg_serial - 1]; 1446 } 1447 1448 // Return an Incremental_library for the given input file. 1449 Incremental_library* 1450 get_library(unsigned int n) const 1451 { return this->library_map_[n]; } 1452 1453 // Return a Script_info for the given input file. 1454 Script_info* 1455 get_script_info(unsigned int n) const 1456 { return this->script_map_[n]; } 1457 1458 // Initialize the layout of the output file based on the existing 1459 // output file. 1460 void 1461 init_layout(Layout* layout) 1462 { this->do_init_layout(layout); } 1463 1464 // Mark regions of the input file that must be kept unchanged. 1465 void 1466 reserve_layout(unsigned int input_file_index) 1467 { this->do_reserve_layout(input_file_index); } 1468 1469 // Process the GOT and PLT entries from the existing output file. 1470 void 1471 process_got_plt(Symbol_table* symtab, Layout* layout) 1472 { this->do_process_got_plt(symtab, layout); } 1473 1474 // Emit COPY relocations from the existing output file. 1475 void 1476 emit_copy_relocs(Symbol_table* symtab) 1477 { this->do_emit_copy_relocs(symtab); } 1478 1479 // Apply incremental relocations for symbols whose values have changed. 1480 void 1481 apply_incremental_relocs(const Symbol_table* symtab, Layout* layout, 1482 Output_file* of) 1483 { this->do_apply_incremental_relocs(symtab, layout, of); } 1484 1485 // Functions and types for the elfcpp::Elf_file interface. This 1486 // permit us to use Incremental_binary as the File template parameter for 1487 // elfcpp::Elf_file. 1488 1489 // The View class is returned by view. It must support a single 1490 // method, data(). This is trivial, because Output_file::get_output_view 1491 // does what we need. 1492 class View 1493 { 1494 public: 1495 View(const unsigned char* p) 1496 : p_(p) 1497 { } 1498 1499 const unsigned char* 1500 data() const 1501 { return this->p_; } 1502 1503 private: 1504 const unsigned char* p_; 1505 }; 1506 1507 // Return a View. 1508 View 1509 view(off_t file_offset, section_size_type data_size) 1510 { return View(this->output_->get_input_view(file_offset, data_size)); } 1511 1512 // A location in the file. 1513 struct Location 1514 { 1515 off_t file_offset; 1516 off_t data_size; 1517 1518 Location(off_t fo, section_size_type ds) 1519 : file_offset(fo), data_size(ds) 1520 { } 1521 1522 Location() 1523 : file_offset(0), data_size(0) 1524 { } 1525 }; 1526 1527 // Get a View given a Location. 1528 View 1529 view(Location loc) 1530 { return View(this->view(loc.file_offset, loc.data_size)); } 1531 1532 // Return the Output_file. 1533 Output_file* 1534 output_file() 1535 { return this->output_; } 1536 1537 protected: 1538 // Check the .gnu_incremental_inputs section to see whether an incremental 1539 // build is possible. 1540 virtual bool 1541 do_check_inputs(const Command_line& cmdline, 1542 Incremental_inputs* incremental_inputs) = 0; 1543 1544 // Return TRUE if input file N has changed since the last incremental link. 1545 virtual bool 1546 do_file_has_changed(unsigned int n) const = 0; 1547 1548 // Initialize the layout of the output file based on the existing 1549 // output file. 1550 virtual void 1551 do_init_layout(Layout* layout) = 0; 1552 1553 // Mark regions of the input file that must be kept unchanged. 1554 virtual void 1555 do_reserve_layout(unsigned int input_file_index) = 0; 1556 1557 // Process the GOT and PLT entries from the existing output file. 1558 virtual void 1559 do_process_got_plt(Symbol_table* symtab, Layout* layout) = 0; 1560 1561 // Emit COPY relocations from the existing output file. 1562 virtual void 1563 do_emit_copy_relocs(Symbol_table* symtab) = 0; 1564 1565 // Apply incremental relocations for symbols whose values have changed. 1566 virtual void 1567 do_apply_incremental_relocs(const Symbol_table*, Layout*, Output_file*) = 0; 1568 1569 virtual unsigned int 1570 do_input_file_count() const = 0; 1571 1572 virtual const Input_reader* 1573 do_get_input_reader(unsigned int) const = 0; 1574 1575 // Map from input file index to Input_argument. 1576 std::vector<const Input_argument*> input_args_map_; 1577 // Map from an input file index to an Incremental_library. 1578 std::vector<Incremental_library*> library_map_; 1579 // Map from an input file index to a Script_info. 1580 std::vector<Script_info*> script_map_; 1581 1582 private: 1583 // Edited output file object. 1584 Output_file* output_; 1585 // Target of the output file. 1586 Target* target_; 1587 }; 1588 1589 template<int size, bool big_endian> 1590 class Sized_relobj_incr; 1591 1592 template<int size, bool big_endian> 1593 class Sized_incremental_binary : public Incremental_binary 1594 { 1595 public: 1596 Sized_incremental_binary(Output_file* output, 1597 const elfcpp::Ehdr<size, big_endian>& ehdr, 1598 Target* target) 1599 : Incremental_binary(output, target), elf_file_(this, ehdr), 1600 input_objects_(), section_map_(), symbol_map_(), copy_relocs_(), 1601 main_symtab_loc_(), main_strtab_loc_(), has_incremental_info_(false), 1602 inputs_reader_(), symtab_reader_(), relocs_reader_(), got_plt_reader_(), 1603 input_entry_readers_() 1604 { this->setup_readers(); } 1605 1606 // Returns TRUE if the file contains incremental info. 1607 bool 1608 has_incremental_info() const 1609 { return this->has_incremental_info_; } 1610 1611 // Record a pointer to the object for input file N. 1612 void 1613 set_input_object(unsigned int n, 1614 Sized_relobj_incr<size, big_endian>* obj) 1615 { this->input_objects_[n] = obj; } 1616 1617 // Return a pointer to the object for input file N. 1618 Sized_relobj_incr<size, big_endian>* 1619 input_object(unsigned int n) const 1620 { 1621 gold_assert(n < this->input_objects_.size()); 1622 return this->input_objects_[n]; 1623 } 1624 1625 // Return the Output_section for section index SHNDX. 1626 Output_section* 1627 output_section(unsigned int shndx) 1628 { return this->section_map_[shndx]; } 1629 1630 // Map a symbol table entry from the base file to the output symbol table. 1631 // SYMNDX is relative to the first forced-local or global symbol in the 1632 // input file symbol table. 1633 void 1634 add_global_symbol(unsigned int symndx, Symbol* gsym) 1635 { this->symbol_map_[symndx] = gsym; } 1636 1637 // Map a symbol table entry from the base file to the output symbol table. 1638 // SYMNDX is relative to the first forced-local or global symbol in the 1639 // input file symbol table. 1640 Symbol* 1641 global_symbol(unsigned int symndx) const 1642 { return this->symbol_map_[symndx]; } 1643 1644 // Add a COPY relocation for a global symbol. 1645 void 1646 add_copy_reloc(Symbol* gsym, Output_section* os, off_t offset) 1647 { this->copy_relocs_.push_back(Copy_reloc(gsym, os, offset)); } 1648 1649 // Readers for the incremental info sections. 1650 1651 const Incremental_inputs_reader<size, big_endian>& 1652 inputs_reader() const 1653 { return this->inputs_reader_; } 1654 1655 const Incremental_symtab_reader<big_endian>& 1656 symtab_reader() const 1657 { return this->symtab_reader_; } 1658 1659 const Incremental_relocs_reader<size, big_endian>& 1660 relocs_reader() const 1661 { return this->relocs_reader_; } 1662 1663 const Incremental_got_plt_reader<big_endian>& 1664 got_plt_reader() const 1665 { return this->got_plt_reader_; } 1666 1667 void 1668 get_symtab_view(View* symtab_view, unsigned int* sym_count, 1669 elfcpp::Elf_strtab* strtab); 1670 1671 protected: 1672 typedef Incremental_inputs_reader<size, big_endian> Inputs_reader; 1673 typedef typename Inputs_reader::Incremental_input_entry_reader 1674 Input_entry_reader; 1675 1676 virtual bool 1677 do_check_inputs(const Command_line& cmdline, 1678 Incremental_inputs* incremental_inputs); 1679 1680 // Return TRUE if input file N has changed since the last incremental link. 1681 virtual bool 1682 do_file_has_changed(unsigned int n) const; 1683 1684 // Initialize the layout of the output file based on the existing 1685 // output file. 1686 virtual void 1687 do_init_layout(Layout* layout); 1688 1689 // Mark regions of the input file that must be kept unchanged. 1690 virtual void 1691 do_reserve_layout(unsigned int input_file_index); 1692 1693 // Process the GOT and PLT entries from the existing output file. 1694 virtual void 1695 do_process_got_plt(Symbol_table* symtab, Layout* layout); 1696 1697 // Emit COPY relocations from the existing output file. 1698 virtual void 1699 do_emit_copy_relocs(Symbol_table* symtab); 1700 1701 // Apply incremental relocations for symbols whose values have changed. 1702 virtual void 1703 do_apply_incremental_relocs(const Symbol_table* symtab, Layout* layout, 1704 Output_file* of); 1705 1706 // Proxy class for a sized Incremental_input_entry_reader. 1707 1708 class Sized_input_reader : public Input_reader 1709 { 1710 public: 1711 Sized_input_reader(Input_entry_reader r) 1712 : Input_reader(), reader_(r) 1713 { } 1714 1715 virtual 1716 ~Sized_input_reader() 1717 { } 1718 1719 private: 1720 const char* 1721 do_filename() const 1722 { return this->reader_.filename(); } 1723 1724 Timespec 1725 do_get_mtime() const 1726 { return this->reader_.get_mtime(); } 1727 1728 Incremental_input_type 1729 do_type() const 1730 { return this->reader_.type(); } 1731 1732 unsigned int 1733 do_arg_serial() const 1734 { return this->reader_.arg_serial(); } 1735 1736 unsigned int 1737 do_get_unused_symbol_count() const 1738 { return this->reader_.get_unused_symbol_count(); } 1739 1740 const char* 1741 do_get_unused_symbol(unsigned int n) const 1742 { return this->reader_.get_unused_symbol(n); } 1743 1744 Input_entry_reader reader_; 1745 }; 1746 1747 virtual unsigned int 1748 do_input_file_count() const 1749 { return this->inputs_reader_.input_file_count(); } 1750 1751 virtual const Input_reader* 1752 do_get_input_reader(unsigned int n) const 1753 { 1754 gold_assert(n < this->input_entry_readers_.size()); 1755 return &this->input_entry_readers_[n]; 1756 } 1757 1758 private: 1759 // List of symbols that need COPY relocations. 1760 struct Copy_reloc 1761 { 1762 Copy_reloc(Symbol* sym, Output_section* os, off_t off) 1763 : symbol(sym), output_section(os), offset(off) 1764 { } 1765 1766 // The global symbol to copy. 1767 Symbol* symbol; 1768 // The output section into which the symbol was copied. 1769 Output_section* output_section; 1770 // The offset within that output section. 1771 off_t offset; 1772 }; 1773 typedef std::vector<Copy_reloc> Copy_relocs; 1774 1775 bool 1776 find_incremental_inputs_sections(unsigned int* p_inputs_shndx, 1777 unsigned int* p_symtab_shndx, 1778 unsigned int* p_relocs_shndx, 1779 unsigned int* p_got_plt_shndx, 1780 unsigned int* p_strtab_shndx); 1781 1782 void 1783 setup_readers(); 1784 1785 // Output as an ELF file. 1786 elfcpp::Elf_file<size, big_endian, Incremental_binary> elf_file_; 1787 1788 // Vector of pointers to the input objects for the unchanged files. 1789 // For replaced files, the corresponding pointer is NULL. 1790 std::vector<Sized_relobj_incr<size, big_endian>*> input_objects_; 1791 1792 // Map section index to an Output_section in the updated layout. 1793 std::vector<Output_section*> section_map_; 1794 1795 // Map global symbols from the input file to the symbol table. 1796 std::vector<Symbol*> symbol_map_; 1797 1798 // List of symbols that need COPY relocations. 1799 Copy_relocs copy_relocs_; 1800 1801 // Locations of the main symbol table and symbol string table. 1802 Location main_symtab_loc_; 1803 Location main_strtab_loc_; 1804 1805 // Readers for the incremental info sections. 1806 bool has_incremental_info_; 1807 Incremental_inputs_reader<size, big_endian> inputs_reader_; 1808 Incremental_symtab_reader<big_endian> symtab_reader_; 1809 Incremental_relocs_reader<size, big_endian> relocs_reader_; 1810 Incremental_got_plt_reader<big_endian> got_plt_reader_; 1811 std::vector<Sized_input_reader> input_entry_readers_; 1812 }; 1813 1814 // An incremental Relobj. This class represents a relocatable object 1815 // that has not changed since the last incremental link, and whose contents 1816 // can be used directly from the base file. 1817 1818 template<int size, bool big_endian> 1819 class Sized_relobj_incr : public Sized_relobj<size, big_endian> 1820 { 1821 public: 1822 typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; 1823 typedef typename Sized_relobj<size, big_endian>::Symbols Symbols; 1824 1825 Sized_relobj_incr(const std::string& name, 1826 Sized_incremental_binary<size, big_endian>* ibase, 1827 unsigned int input_file_index); 1828 1829 private: 1830 // For convenience. 1831 typedef Sized_relobj_incr<size, big_endian> This; 1832 static const int sym_size = elfcpp::Elf_sizes<size>::sym_size; 1833 1834 typedef typename Sized_relobj<size, big_endian>::Output_sections 1835 Output_sections; 1836 typedef Incremental_inputs_reader<size, big_endian> Inputs_reader; 1837 typedef typename Inputs_reader::Incremental_input_entry_reader 1838 Input_entry_reader; 1839 1840 // A local symbol. 1841 struct Local_symbol 1842 { 1843 Local_symbol(const char* name_, Address value_, unsigned int size_, 1844 unsigned int shndx_, unsigned int type_, 1845 bool needs_dynsym_entry_) 1846 : st_value(value_), name(name_), st_size(size_), st_shndx(shndx_), 1847 st_type(type_), output_dynsym_index(0), 1848 needs_dynsym_entry(needs_dynsym_entry_) 1849 { } 1850 // The symbol value. 1851 Address st_value; 1852 // The symbol name. This points to the stringpool entry. 1853 const char* name; 1854 // The symbol size. 1855 unsigned int st_size; 1856 // The output section index. 1857 unsigned int st_shndx : 28; 1858 // The symbol type. 1859 unsigned int st_type : 4; 1860 // The index of the symbol in the output dynamic symbol table. 1861 unsigned int output_dynsym_index : 31; 1862 // TRUE if the symbol needs to appear in the dynamic symbol table. 1863 unsigned int needs_dynsym_entry : 1; 1864 }; 1865 1866 // Return TRUE if this is an incremental (unchanged) input file. 1867 bool 1868 do_is_incremental() const 1869 { return true; } 1870 1871 // Return the last modified time of the file. 1872 Timespec 1873 do_get_mtime() 1874 { return this->input_reader_.get_mtime(); } 1875 1876 // Read the symbols. 1877 void 1878 do_read_symbols(Read_symbols_data*); 1879 1880 // Lay out the input sections. 1881 void 1882 do_layout(Symbol_table*, Layout*, Read_symbols_data*); 1883 1884 // Layout sections whose layout was deferred while waiting for 1885 // input files from a plugin. 1886 void 1887 do_layout_deferred_sections(Layout*); 1888 1889 // Add the symbols to the symbol table. 1890 void 1891 do_add_symbols(Symbol_table*, Read_symbols_data*, Layout*); 1892 1893 Archive::Should_include 1894 do_should_include_member(Symbol_table* symtab, Layout*, Read_symbols_data*, 1895 std::string* why); 1896 1897 // Iterate over global symbols, calling a visitor class V for each. 1898 void 1899 do_for_all_global_symbols(Read_symbols_data* sd, 1900 Library_base::Symbol_visitor_base* v); 1901 1902 // Get the size of a section. 1903 uint64_t 1904 do_section_size(unsigned int shndx); 1905 1906 // Get the name of a section. 1907 std::string 1908 do_section_name(unsigned int shndx); 1909 1910 // Return a view of the contents of a section. 1911 const unsigned char* 1912 do_section_contents(unsigned int shndx, section_size_type* plen, 1913 bool cache); 1914 1915 // Return section flags. 1916 uint64_t 1917 do_section_flags(unsigned int shndx); 1918 1919 // Return section entsize. 1920 uint64_t 1921 do_section_entsize(unsigned int shndx); 1922 1923 // Return section address. 1924 uint64_t 1925 do_section_address(unsigned int shndx); 1926 1927 // Return section type. 1928 unsigned int 1929 do_section_type(unsigned int shndx); 1930 1931 // Return the section link field. 1932 unsigned int 1933 do_section_link(unsigned int shndx); 1934 1935 // Return the section link field. 1936 unsigned int 1937 do_section_info(unsigned int shndx); 1938 1939 // Return the section alignment. 1940 uint64_t 1941 do_section_addralign(unsigned int shndx); 1942 1943 // Return the Xindex structure to use. 1944 Xindex* 1945 do_initialize_xindex(); 1946 1947 // Get symbol counts. 1948 void 1949 do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const; 1950 1951 // Get global symbols. 1952 const Symbols* 1953 do_get_global_symbols() const 1954 { return &this->symbols_; } 1955 1956 // Return the value of a local symbol. 1957 uint64_t 1958 do_local_symbol_value(unsigned int, uint64_t) const 1959 { gold_unreachable(); } 1960 1961 unsigned int 1962 do_local_plt_offset(unsigned int) const 1963 { gold_unreachable(); } 1964 1965 // Return the number of local symbols. 1966 unsigned int 1967 do_local_symbol_count() const 1968 { return this->local_symbol_count_; } 1969 1970 // Return the number of local symbols in the output symbol table. 1971 unsigned int 1972 do_output_local_symbol_count() const 1973 { return this->local_symbol_count_; } 1974 1975 // Return the file offset for local symbols in the output symbol table. 1976 off_t 1977 do_local_symbol_offset() const 1978 { return this->local_symbol_offset_; } 1979 1980 // Read the relocs. 1981 void 1982 do_read_relocs(Read_relocs_data*); 1983 1984 // Process the relocs to find list of referenced sections. Used only 1985 // during garbage collection. 1986 void 1987 do_gc_process_relocs(Symbol_table*, Layout*, Read_relocs_data*); 1988 1989 // Scan the relocs and adjust the symbol table. 1990 void 1991 do_scan_relocs(Symbol_table*, Layout*, Read_relocs_data*); 1992 1993 // Count the local symbols. 1994 void 1995 do_count_local_symbols(Stringpool_template<char>*, 1996 Stringpool_template<char>*); 1997 1998 // Finalize the local symbols. 1999 unsigned int 2000 do_finalize_local_symbols(unsigned int, off_t, Symbol_table*); 2001 2002 // Set the offset where local dynamic symbol information will be stored. 2003 unsigned int 2004 do_set_local_dynsym_indexes(unsigned int); 2005 2006 // Set the offset where local dynamic symbol information will be stored. 2007 unsigned int 2008 do_set_local_dynsym_offset(off_t); 2009 2010 // Relocate the input sections and write out the local symbols. 2011 void 2012 do_relocate(const Symbol_table* symtab, const Layout*, Output_file* of); 2013 2014 // Set the offset of a section. 2015 void 2016 do_set_section_offset(unsigned int shndx, uint64_t off); 2017 2018 // The Incremental_binary base file. 2019 Sized_incremental_binary<size, big_endian>* ibase_; 2020 // The index of the object in the input file list. 2021 unsigned int input_file_index_; 2022 // The reader for the input file. 2023 Input_entry_reader input_reader_; 2024 // The number of local symbols. 2025 unsigned int local_symbol_count_; 2026 // The number of local symbols which go into the output file's dynamic 2027 // symbol table. 2028 unsigned int output_local_dynsym_count_; 2029 // This starting symbol index in the output symbol table. 2030 unsigned int local_symbol_index_; 2031 // The file offset for local symbols in the output symbol table. 2032 unsigned int local_symbol_offset_; 2033 // The file offset for local symbols in the output symbol table. 2034 unsigned int local_dynsym_offset_; 2035 // The entries in the symbol table for the external symbols. 2036 Symbols symbols_; 2037 // Number of symbols defined in object file itself. 2038 size_t defined_count_; 2039 // The offset of the first incremental relocation for this object. 2040 unsigned int incr_reloc_offset_; 2041 // The number of incremental relocations for this object. 2042 unsigned int incr_reloc_count_; 2043 // The index of the first incremental relocation for this object in the 2044 // updated output file. 2045 unsigned int incr_reloc_output_index_; 2046 // A copy of the incremental relocations from this object. 2047 unsigned char* incr_relocs_; 2048 // The local symbols. 2049 std::vector<Local_symbol> local_symbols_; 2050 }; 2051 2052 // An incremental Dynobj. This class represents a shared object that has 2053 // not changed since the last incremental link, and whose contents can be 2054 // used directly from the base file. 2055 2056 template<int size, bool big_endian> 2057 class Sized_incr_dynobj : public Dynobj 2058 { 2059 public: 2060 typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; 2061 2062 static const Address invalid_address = static_cast<Address>(0) - 1; 2063 2064 Sized_incr_dynobj(const std::string& name, 2065 Sized_incremental_binary<size, big_endian>* ibase, 2066 unsigned int input_file_index); 2067 2068 private: 2069 typedef Incremental_inputs_reader<size, big_endian> Inputs_reader; 2070 typedef typename Inputs_reader::Incremental_input_entry_reader 2071 Input_entry_reader; 2072 2073 // Return TRUE if this is an incremental (unchanged) input file. 2074 bool 2075 do_is_incremental() const 2076 { return true; } 2077 2078 // Return the last modified time of the file. 2079 Timespec 2080 do_get_mtime() 2081 { return this->input_reader_.get_mtime(); } 2082 2083 // Read the symbols. 2084 void 2085 do_read_symbols(Read_symbols_data*); 2086 2087 // Lay out the input sections. 2088 void 2089 do_layout(Symbol_table*, Layout*, Read_symbols_data*); 2090 2091 // Add the symbols to the symbol table. 2092 void 2093 do_add_symbols(Symbol_table*, Read_symbols_data*, Layout*); 2094 2095 Archive::Should_include 2096 do_should_include_member(Symbol_table* symtab, Layout*, Read_symbols_data*, 2097 std::string* why); 2098 2099 // Iterate over global symbols, calling a visitor class V for each. 2100 void 2101 do_for_all_global_symbols(Read_symbols_data* sd, 2102 Library_base::Symbol_visitor_base* v); 2103 2104 // Iterate over local symbols, calling a visitor class V for each GOT offset 2105 // associated with a local symbol. 2106 void 2107 do_for_all_local_got_entries(Got_offset_list::Visitor* v) const; 2108 2109 // Get the size of a section. 2110 uint64_t 2111 do_section_size(unsigned int shndx); 2112 2113 // Get the name of a section. 2114 std::string 2115 do_section_name(unsigned int shndx); 2116 2117 // Return a view of the contents of a section. 2118 const unsigned char* 2119 do_section_contents(unsigned int shndx, section_size_type* plen, 2120 bool cache); 2121 2122 // Return section flags. 2123 uint64_t 2124 do_section_flags(unsigned int shndx); 2125 2126 // Return section entsize. 2127 uint64_t 2128 do_section_entsize(unsigned int shndx); 2129 2130 // Return section address. 2131 uint64_t 2132 do_section_address(unsigned int shndx); 2133 2134 // Return section type. 2135 unsigned int 2136 do_section_type(unsigned int shndx); 2137 2138 // Return the section link field. 2139 unsigned int 2140 do_section_link(unsigned int shndx); 2141 2142 // Return the section link field. 2143 unsigned int 2144 do_section_info(unsigned int shndx); 2145 2146 // Return the section alignment. 2147 uint64_t 2148 do_section_addralign(unsigned int shndx); 2149 2150 // Return the Xindex structure to use. 2151 Xindex* 2152 do_initialize_xindex(); 2153 2154 // Get symbol counts. 2155 void 2156 do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const; 2157 2158 // Get global symbols. 2159 const Symbols* 2160 do_get_global_symbols() const 2161 { return &this->symbols_; } 2162 2163 // The Incremental_binary base file. 2164 Sized_incremental_binary<size, big_endian>* ibase_; 2165 // The index of the object in the input file list. 2166 unsigned int input_file_index_; 2167 // The reader for the input file. 2168 Input_entry_reader input_reader_; 2169 // The entries in the symbol table for the external symbols. 2170 Symbols symbols_; 2171 // Number of symbols defined in object file itself. 2172 size_t defined_count_; 2173 }; 2174 2175 // Allocate an incremental object of the appropriate size and endianness. 2176 extern Object* 2177 make_sized_incremental_object( 2178 Incremental_binary* base, 2179 unsigned int input_file_index, 2180 Incremental_input_type input_type, 2181 const Incremental_binary::Input_reader* input_reader); 2182 2183 // This class represents an Archive library (or --start-lib/--end-lib group) 2184 // that has not changed since the last incremental link. Its contents come 2185 // from the incremental inputs entry in the base file. 2186 2187 class Incremental_library : public Library_base 2188 { 2189 public: 2190 Incremental_library(const char* filename, unsigned int input_file_index, 2191 const Incremental_binary::Input_reader* input_reader) 2192 : Library_base(NULL), filename_(filename), 2193 input_file_index_(input_file_index), input_reader_(input_reader), 2194 unused_symbols_(), is_reported_(false) 2195 { } 2196 2197 // Return the input file index. 2198 unsigned int 2199 input_file_index() const 2200 { return this->input_file_index_; } 2201 2202 // Return the serial number of the input file. 2203 unsigned int 2204 arg_serial() const 2205 { return this->input_reader_->arg_serial(); } 2206 2207 // Copy the unused symbols from the incremental input info. 2208 // We need to do this because we may be overwriting the incremental 2209 // input info in the base file before we write the new incremental 2210 // info. 2211 void 2212 copy_unused_symbols(); 2213 2214 // Return FALSE on the first call to indicate that the library needs 2215 // to be recorded; return TRUE subsequently. 2216 bool 2217 is_reported() 2218 { 2219 bool was_reported = this->is_reported_; 2220 is_reported_ = true; 2221 return was_reported; 2222 } 2223 2224 private: 2225 typedef std::vector<std::string> Symbol_list; 2226 2227 // The file name. 2228 const std::string& 2229 do_filename() const 2230 { return this->filename_; } 2231 2232 // Return the modification time of the archive file. 2233 Timespec 2234 do_get_mtime() 2235 { return this->input_reader_->get_mtime(); } 2236 2237 // Iterator for unused global symbols in the library. 2238 void 2239 do_for_all_unused_symbols(Symbol_visitor_base* v) const; 2240 2241 // The name of the library. 2242 std::string filename_; 2243 // The input file index of this library. 2244 unsigned int input_file_index_; 2245 // A reader for the incremental input information. 2246 const Incremental_binary::Input_reader* input_reader_; 2247 // List of unused symbols defined in this library. 2248 Symbol_list unused_symbols_; 2249 // TRUE when this library has been reported to the new incremental info. 2250 bool is_reported_; 2251 }; 2252 2253 } // End namespace gold. 2254 2255 #endif // !defined(GOLD_INCREMENTAL_H) 2256