1 // object.h -- support for an object file for linking in gold -*- C++ -*-
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
30 #include "elfcpp_file.h"
37 class General_options;
43 template<typename Stringpool_char>
44 class Stringpool_template;
46 // Data to pass from read_symbols() to add_symbols().
48 struct Read_symbols_data
51 File_view* section_headers;
53 File_view* section_names;
54 // Size of section name data in bytes.
55 off_t section_names_size;
58 // Size of symbol data in bytes.
60 // Offset of external symbols within symbol data. This structure
61 // sometimes contains only external symbols, in which case this will
62 // be zero. Sometimes it contains all symbols.
63 off_t external_symbols_offset;
65 File_view* symbol_names;
66 // Size of symbol name data in bytes.
67 off_t symbol_names_size;
69 // Version information. This is only used on dynamic objects.
70 // Version symbol data (from SHT_GNU_versym section).
73 // Version definition data (from SHT_GNU_verdef section).
76 unsigned int verdef_info;
77 // Needed version data (from SHT_GNU_verneed section).
80 unsigned int verneed_info;
83 // Information used to print error messages.
85 struct Symbol_location_info
87 std::string source_file;
88 std::string enclosing_symbol_name;
92 // Data about a single relocation section. This is read in
93 // read_relocs and processed in scan_relocs.
97 // Index of reloc section.
98 unsigned int reloc_shndx;
99 // Index of section that relocs apply to.
100 unsigned int data_shndx;
101 // Contents of reloc section.
103 // Reloc section type.
104 unsigned int sh_type;
105 // Number of reloc entries.
108 Output_section* output_section;
109 // Whether this section has special handling for offsets.
110 bool needs_special_offset_handling;
113 // Relocations in an object file. This is read in read_relocs and
114 // processed in scan_relocs.
116 struct Read_relocs_data
118 typedef std::vector<Section_relocs> Relocs_list;
121 // The local symbols.
122 File_view* local_symbols;
125 // Object is an abstract base class which represents either a 32-bit
126 // or a 64-bit input object. This can be a regular object file
127 // (ET_REL) or a shared object (ET_DYN).
132 // NAME is the name of the object as we would report it to the user
133 // (e.g., libfoo.a(bar.o) if this is in an archive. INPUT_FILE is
134 // used to read the file. OFFSET is the offset within the input
135 // file--0 for a .o or .so file, something else for a .a file.
136 Object(const std::string& name, Input_file* input_file, bool is_dynamic,
138 : name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
139 is_dynamic_(is_dynamic), target_(NULL)
145 // Return the name of the object as we would report it to the tuser.
148 { return this->name_; }
150 // Get the offset into the file.
153 { return this->offset_; }
155 // Return whether this is a dynamic object.
158 { return this->is_dynamic_; }
160 // Return the target structure associated with this object.
163 { return this->target_; }
165 // Lock the underlying file.
168 { this->input_file_->file().lock(); }
170 // Unlock the underlying file.
173 { this->input_file_->file().unlock(); }
175 // Return whether the underlying file is locked.
178 { return this->input_file_->file().is_locked(); }
180 // Return the sized target structure associated with this object.
181 // This is like the target method but it returns a pointer of
182 // appropriate checked type.
183 template<int size, bool big_endian>
184 Sized_target<size, big_endian>*
185 sized_target(ACCEPT_SIZE_ENDIAN_ONLY);
187 // Get the number of sections.
190 { return this->shnum_; }
192 // Return a view of the contents of a section. Set *PLEN to the
193 // size. CACHE is a hint as in File_read::get_view.
195 section_contents(unsigned int shndx, off_t* plen, bool cache);
197 // Return the name of a section given a section index. This is only
198 // used for error messages.
200 section_name(unsigned int shndx)
201 { return this->do_section_name(shndx); }
203 // Return the section flags given a section index.
205 section_flags(unsigned int shndx)
206 { return this->do_section_flags(shndx); }
208 // Return the section type given a section index.
210 section_type(unsigned int shndx)
211 { return this->do_section_type(shndx); }
213 // Return the section link field given a section index.
215 section_link(unsigned int shndx)
216 { return this->do_section_link(shndx); }
218 // Return the section info field given a section index.
220 section_info(unsigned int shndx)
221 { return this->do_section_info(shndx); }
223 // Read the symbol information.
225 read_symbols(Read_symbols_data* sd)
226 { return this->do_read_symbols(sd); }
228 // Pass sections which should be included in the link to the Layout
229 // object, and record where the sections go in the output file.
231 layout(Symbol_table* symtab, Layout* layout, Read_symbols_data* sd)
232 { this->do_layout(symtab, layout, sd); }
234 // Add symbol information to the global symbol table.
236 add_symbols(Symbol_table* symtab, Read_symbols_data* sd)
237 { this->do_add_symbols(symtab, sd); }
239 // Functions and types for the elfcpp::Elf_file interface. This
240 // permit us to use Object as the File template parameter for
243 // The View class is returned by view. It must support a single
244 // method, data(). This is trivial, because get_view does what we
249 View(const unsigned char* p)
258 const unsigned char* p_;
263 view(off_t file_offset, off_t data_size)
264 { return View(this->get_view(file_offset, data_size, true)); }
268 error(const char* format, ...) const ATTRIBUTE_PRINTF_2;
270 // A location in the file.
276 Location(off_t fo, off_t ds)
277 : file_offset(fo), data_size(ds)
281 // Get a View given a Location.
282 View view(Location loc)
283 { return View(this->get_view(loc.file_offset, loc.data_size, true)); }
286 // Read the symbols--implemented by child class.
288 do_read_symbols(Read_symbols_data*) = 0;
290 // Lay out sections--implemented by child class.
292 do_layout(Symbol_table*, Layout*, Read_symbols_data*) = 0;
294 // Add symbol information to the global symbol table--implemented by
297 do_add_symbols(Symbol_table*, Read_symbols_data*) = 0;
299 // Return the location of the contents of a section. Implemented by
302 do_section_contents(unsigned int shndx) = 0;
304 // Get the name of a section--implemented by child class.
306 do_section_name(unsigned int shndx) = 0;
308 // Get section flags--implemented by child class.
310 do_section_flags(unsigned int shndx) = 0;
312 // Get section type--implemented by child class.
314 do_section_type(unsigned int shndx) = 0;
316 // Get section link field--implemented by child class.
318 do_section_link(unsigned int shndx) = 0;
320 // Get section info field--implemented by child class.
322 do_section_info(unsigned int shndx) = 0;
327 { return this->input_file_; }
329 // Get a view into the underlying file.
331 get_view(off_t start, off_t size, bool cache)
333 return this->input_file_->file().get_view(start + this->offset_, size,
337 // Get a lasting view into the underlying file.
339 get_lasting_view(off_t start, off_t size, bool cache)
341 return this->input_file_->file().get_lasting_view(start + this->offset_,
345 // Read data from the underlying file.
347 read(off_t start, off_t size, void* p)
348 { this->input_file_->file().read(start + this->offset_, size, p); }
352 set_target(int machine, int size, bool big_endian, int osabi,
355 // Set the number of sections.
358 { this->shnum_ = shnum; }
360 // Functions used by both Sized_relobj and Sized_dynobj.
362 // Read the section data into a Read_symbols_data object.
363 template<int size, bool big_endian>
365 read_section_data(elfcpp::Elf_file<size, big_endian, Object>*,
368 // If NAME is the name of a special .gnu.warning section, arrange
369 // for the warning to be issued. SHNDX is the section index.
370 // Return whether it is a warning section.
372 handle_gnu_warning_section(const char* name, unsigned int shndx,
376 // This class may not be copied.
377 Object(const Object&);
378 Object& operator=(const Object&);
380 // Name of object as printed to user.
382 // For reading the file.
383 Input_file* input_file_;
384 // Offset within the file--0 for an object file, non-0 for an
387 // Number of input sections.
389 // Whether this is a dynamic object.
391 // Target functions--may be NULL if the target is not known.
395 // Implement sized_target inline for efficiency. This approach breaks
396 // static type checking, but is made safe using asserts.
398 template<int size, bool big_endian>
399 inline Sized_target<size, big_endian>*
400 Object::sized_target(ACCEPT_SIZE_ENDIAN_ONLY)
402 gold_assert(this->target_->get_size() == size);
403 gold_assert(this->target_->is_big_endian() ? big_endian : !big_endian);
404 return static_cast<Sized_target<size, big_endian>*>(this->target_);
407 // A regular object (ET_REL). This is an abstract base class itself.
408 // The implementation is the template class Sized_relobj.
410 class Relobj : public Object
413 Relobj(const std::string& name, Input_file* input_file, off_t offset = 0)
414 : Object(name, input_file, false, offset)
419 read_relocs(Read_relocs_data* rd)
420 { return this->do_read_relocs(rd); }
422 // Scan the relocs and adjust the symbol table.
424 scan_relocs(const General_options& options, Symbol_table* symtab,
425 Layout* layout, Read_relocs_data* rd)
426 { return this->do_scan_relocs(options, symtab, layout, rd); }
428 // Initial local symbol processing: set the offset where local
429 // symbol information will be stored; add local symbol names to
430 // *POOL; return the new local symbol index.
432 finalize_local_symbols(unsigned int index, off_t off,
433 Stringpool_template<char>* pool)
434 { return this->do_finalize_local_symbols(index, off, pool); }
436 // Relocate the input sections and write out the local symbols.
438 relocate(const General_options& options, const Symbol_table* symtab,
439 const Layout* layout, Output_file* of)
440 { return this->do_relocate(options, symtab, layout, of); }
442 // Return whether an input section is being included in the link.
444 is_section_included(unsigned int shndx) const
446 gold_assert(shndx < this->map_to_output_.size());
447 return this->map_to_output_[shndx].output_section != NULL;
450 // Return whether an input section requires special
451 // handling--whether it is not simply mapped from the input file to
454 is_section_specially_mapped(unsigned int shndx) const
456 gold_assert(shndx < this->map_to_output_.size());
457 return (this->map_to_output_[shndx].output_section != NULL
458 && this->map_to_output_[shndx].offset == -1);
461 // Given a section index, return the corresponding Output_section
462 // (which will be NULL if the section is not included in the link)
463 // and set *POFF to the offset within that section. *POFF will be
464 // set to -1 if the section requires special handling.
465 inline Output_section*
466 output_section(unsigned int shndx, off_t* poff) const;
468 // Set the offset of an input section within its output section.
470 set_section_offset(unsigned int shndx, off_t off)
472 gold_assert(shndx < this->map_to_output_.size());
473 this->map_to_output_[shndx].offset = off;
476 // Return true if we need to wait for output sections to be written
477 // before we can apply relocations. This is true if the object has
478 // any relocations for sections which require special handling, such
479 // as the exception frame section.
481 relocs_must_follow_section_writes()
482 { return this->relocs_must_follow_section_writes_; }
485 // What we need to know to map an input section to an output
486 // section. We keep an array of these, one for each input section,
487 // indexed by the input section number.
490 // The output section. This is NULL if the input section is to be
492 Output_section* output_section;
493 // The offset within the output section. This is -1 if the
494 // section requires special handling.
498 // Read the relocs--implemented by child class.
500 do_read_relocs(Read_relocs_data*) = 0;
502 // Scan the relocs--implemented by child class.
504 do_scan_relocs(const General_options&, Symbol_table*, Layout*,
505 Read_relocs_data*) = 0;
507 // Finalize local symbols--implemented by child class.
509 do_finalize_local_symbols(unsigned int, off_t,
510 Stringpool_template<char>*) = 0;
512 // Relocate the input sections and write out the local
513 // symbols--implemented by child class.
515 do_relocate(const General_options& options, const Symbol_table* symtab,
516 const Layout*, Output_file* of) = 0;
518 // Return the vector mapping input sections to output sections.
519 std::vector<Map_to_output>&
521 { return this->map_to_output_; }
523 const std::vector<Map_to_output>&
524 map_to_output() const
525 { return this->map_to_output_; }
527 // Record that we must wait for the output sections to be written
528 // before applying relocations.
530 set_relocs_must_follow_section_writes()
531 { this->relocs_must_follow_section_writes_ = true; }
534 // Mapping from input sections to output section.
535 std::vector<Map_to_output> map_to_output_;
536 // Whether we need to wait for output sections to be written before
537 // we can apply relocations.
538 bool relocs_must_follow_section_writes_;
541 // Implement Object::output_section inline for efficiency.
542 inline Output_section*
543 Relobj::output_section(unsigned int shndx, off_t* poff) const
545 gold_assert(shndx < this->map_to_output_.size());
546 const Map_to_output& mo(this->map_to_output_[shndx]);
548 return mo.output_section;
551 // This POD class is holds the value of a symbol. This is used for
552 // local symbols, and for all symbols during relocation processing.
553 // For special sections, such as SHF_MERGE sections, this calls a
554 // function to get the final symbol value.
560 typedef typename elfcpp::Elf_types<size>::Elf_Addr Value;
563 : output_symtab_index_(0), input_shndx_(0), is_section_symbol_(false),
564 needs_output_address_(false), value_(0)
567 // Get the value of this symbol. OBJECT is the object in which this
568 // symbol is defined, and ADDEND is an addend to add to the value.
569 template<bool big_endian>
571 value(const Sized_relobj<size, big_endian>* object, Value addend) const
573 if (!this->needs_output_address_)
574 return this->value_ + addend;
575 return object->local_value(this->input_shndx_, this->value_,
576 this->is_section_symbol_, addend);
579 // Set the value of this symbol in the output symbol table.
581 set_output_value(Value value)
583 this->value_ = value;
584 this->needs_output_address_ = false;
587 // If this symbol is mapped to an output section which requires
588 // special handling to determine the output value, we store the
589 // value of the symbol in the input file. This is used for
590 // SHF_MERGE sections.
592 set_input_value(Value value)
594 this->value_ = value;
595 this->needs_output_address_ = true;
598 // Return whether this symbol should go into the output symbol
601 needs_output_symtab_entry() const
603 gold_assert(this->output_symtab_index_ != 0);
604 return this->output_symtab_index_ != -1U;
607 // Return the index in the output symbol table.
609 output_symtab_index() const
611 gold_assert(this->output_symtab_index_ != 0);
612 return this->output_symtab_index_;
615 // Set the index in the output symbol table.
617 set_output_symtab_index(unsigned int i)
619 gold_assert(this->output_symtab_index_ == 0);
620 this->output_symtab_index_ = i;
623 // Record that this symbol should not go into the output symbol
626 set_no_output_symtab_entry()
628 gold_assert(this->output_symtab_index_ == 0);
629 this->output_symtab_index_ = -1U;
632 // Set the index of the input section in the input file.
634 set_input_shndx(unsigned int i)
636 this->input_shndx_ = i;
637 gold_assert(this->input_shndx_ == i);
640 // Record that this is a section symbol.
642 set_is_section_symbol()
643 { this->is_section_symbol_ = true; }
646 // The index of this local symbol in the output symbol table. This
647 // will be -1 if the symbol should not go into the symbol table.
648 unsigned int output_symtab_index_;
649 // The section index in the input file in which this symbol is
651 unsigned int input_shndx_ : 30;
652 // Whether this is a STT_SECTION symbol.
653 bool is_section_symbol_ : 1;
654 // Whether getting the value of this symbol requires calling an
655 // Output_section method. For example, this will be true of a
656 // symbol in a SHF_MERGE section.
657 bool needs_output_address_ : 1;
658 // The value of the symbol. If !needs_output_address_, this is the
659 // value in the output file. If needs_output_address_, this is the
660 // value in the input file.
664 // A regular object file. This is size and endian specific.
666 template<int size, bool big_endian>
667 class Sized_relobj : public Relobj
670 typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
671 typedef std::vector<Symbol*> Symbols;
672 typedef std::vector<Symbol_value<size> > Local_values;
674 Sized_relobj(const std::string& name, Input_file* input_file, off_t offset,
675 const typename elfcpp::Ehdr<size, big_endian>&);
679 // Set up the object file based on the ELF header.
681 setup(const typename elfcpp::Ehdr<size, big_endian>&);
683 // Return the number of local symbols.
685 local_symbol_count() const
686 { return this->local_symbol_count_; }
688 // If SYM is the index of a global symbol in the object file's
689 // symbol table, return the Symbol object. Otherwise, return NULL.
691 global_symbol(unsigned int sym) const
693 if (sym >= this->local_symbol_count_)
695 gold_assert(sym - this->local_symbol_count_ < this->symbols_.size());
696 return this->symbols_[sym - this->local_symbol_count_];
701 // Return the section index of symbol SYM. Set *VALUE to its value
702 // in the object file. Note that for a symbol which is not defined
703 // in this object file, this will set *VALUE to 0 and return
704 // SHN_UNDEF; it will not return the final value of the symbol in
707 symbol_section_and_value(unsigned int sym, Address* value);
709 // Return a pointer to the Symbol_value structure which holds the
710 // value of a local symbol.
711 const Symbol_value<size>*
712 local_symbol(unsigned int sym) const
714 gold_assert(sym < this->local_values_.size());
715 return &this->local_values_[sym];
718 // Return the index of local symbol SYM in the ordinary symbol
719 // table. A value of -1U means that the symbol is not being output.
721 symtab_index(unsigned int sym) const
723 gold_assert(sym < this->local_values_.size());
724 return this->local_values_[sym].output_symtab_index();
727 // Return the appropriate Sized_target structure.
728 Sized_target<size, big_endian>*
731 return this->Object::sized_target
732 SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
733 SELECT_SIZE_ENDIAN_ONLY(size, big_endian));
736 // Return the value of the local symbol symndx.
738 local_symbol_value(unsigned int symndx) const;
740 // Return the value of a local symbol defined in input section
741 // SHNDX, with value VALUE, adding addend ADDEND. IS_SECTION_SYMBOL
742 // indicates whether the symbol is a section symbol. This handles
743 // SHF_MERGE sections.
745 local_value(unsigned int shndx, Address value, bool is_section_symbol,
746 Address addend) const;
748 // Return whether the local symbol SYMNDX has a GOT offset.
750 local_has_got_offset(unsigned int symndx) const
752 return (this->local_got_offsets_.find(symndx)
753 != this->local_got_offsets_.end());
756 // Return the GOT offset of the local symbol SYMNDX.
758 local_got_offset(unsigned int symndx) const
760 Local_got_offsets::const_iterator p =
761 this->local_got_offsets_.find(symndx);
762 gold_assert(p != this->local_got_offsets_.end());
766 // Set the GOT offset of the local symbol SYMNDX to GOT_OFFSET.
768 set_local_got_offset(unsigned int symndx, unsigned int got_offset)
770 std::pair<Local_got_offsets::iterator, bool> ins =
771 this->local_got_offsets_.insert(std::make_pair(symndx, got_offset));
772 gold_assert(ins.second);
775 // Return the name of the symbol that spans the given offset in the
776 // specified section in this object. This is used only for error
777 // messages and is not particularly efficient.
779 get_symbol_location_info(unsigned int shndx, off_t offset,
780 Symbol_location_info* info);
784 do_read_symbols(Read_symbols_data*);
786 // Lay out the input sections.
788 do_layout(Symbol_table*, Layout*, Read_symbols_data*);
790 // Add the symbols to the symbol table.
792 do_add_symbols(Symbol_table*, Read_symbols_data*);
796 do_read_relocs(Read_relocs_data*);
798 // Scan the relocs and adjust the symbol table.
800 do_scan_relocs(const General_options&, Symbol_table*, Layout*,
803 // Finalize the local symbols.
805 do_finalize_local_symbols(unsigned int, off_t,
806 Stringpool_template<char>*);
808 // Relocate the input sections and write out the local symbols.
810 do_relocate(const General_options& options, const Symbol_table* symtab,
811 const Layout*, Output_file* of);
813 // Get the name of a section.
815 do_section_name(unsigned int shndx)
816 { return this->elf_file_.section_name(shndx); }
818 // Return the location of the contents of a section.
820 do_section_contents(unsigned int shndx)
821 { return this->elf_file_.section_contents(shndx); }
823 // Return section flags.
825 do_section_flags(unsigned int shndx)
826 { return this->elf_file_.section_flags(shndx); }
828 // Return section type.
830 do_section_type(unsigned int shndx)
831 { return this->elf_file_.section_type(shndx); }
833 // Return the section link field.
835 do_section_link(unsigned int shndx)
836 { return this->elf_file_.section_link(shndx); }
838 // Return the section info field.
840 do_section_info(unsigned int shndx)
841 { return this->elf_file_.section_info(shndx); }
845 typedef Sized_relobj<size, big_endian> This;
846 static const int ehdr_size = elfcpp::Elf_sizes<size>::ehdr_size;
847 static const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
848 static const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
849 typedef elfcpp::Shdr<size, big_endian> Shdr;
851 // Find the SHT_SYMTAB section, given the section headers.
853 find_symtab(const unsigned char* pshdrs);
855 // Return whether SHDR has the right flags for a GNU style exception
858 check_eh_frame_flags(const elfcpp::Shdr<size, big_endian>* shdr) const;
860 // Return whether there is a section named .eh_frame which might be
861 // a GNU style exception frame section.
863 find_eh_frame(const unsigned char* pshdrs, const char* names,
864 off_t names_size) const;
866 // Whether to include a section group in the link.
868 include_section_group(Layout*, unsigned int,
869 const elfcpp::Shdr<size, big_endian>&,
872 // Whether to include a linkonce section in the link.
874 include_linkonce_section(Layout*, const char*,
875 const elfcpp::Shdr<size, big_endian>&);
877 // Views and sizes when relocating.
881 typename elfcpp::Elf_types<size>::Elf_Addr address;
884 bool is_input_output_view;
887 typedef std::vector<View_size> Views;
889 // Write section data to the output file. Record the views and
890 // sizes in VIEWS for use when relocating.
892 write_sections(const unsigned char* pshdrs, Output_file*, Views*);
894 // Relocate the sections in the output file.
896 relocate_sections(const General_options& options, const Symbol_table*,
897 const Layout*, const unsigned char* pshdrs, Views*);
899 // Write out the local symbols.
901 write_local_symbols(Output_file*,
902 const Stringpool_template<char>*);
904 // The GOT offsets of local symbols.
905 typedef Unordered_map<unsigned int, unsigned int> Local_got_offsets;
907 // General access to the ELF file.
908 elfcpp::Elf_file<size, big_endian, Object> elf_file_;
909 // Index of SHT_SYMTAB section.
910 unsigned int symtab_shndx_;
911 // The number of local symbols.
912 unsigned int local_symbol_count_;
913 // The number of local symbols which go into the output file.
914 unsigned int output_local_symbol_count_;
915 // The entries in the symbol table for the external symbols.
917 // File offset for local symbols.
918 off_t local_symbol_offset_;
919 // Values of local symbols.
920 Local_values local_values_;
921 // GOT offsets for local symbols, indexed by symbol number.
922 Local_got_offsets local_got_offsets_;
923 // Whether this object has a GNU style .eh_frame section.
927 // A class to manage the list of all objects.
933 : relobj_list_(), dynobj_list_(), target_(NULL), sonames_()
936 // The type of the list of input relocateable objects.
937 typedef std::vector<Relobj*> Relobj_list;
938 typedef Relobj_list::const_iterator Relobj_iterator;
940 // The type of the list of input dynamic objects.
941 typedef std::vector<Dynobj*> Dynobj_list;
942 typedef Dynobj_list::const_iterator Dynobj_iterator;
944 // Add an object to the list. Return true if all is well, or false
945 // if this object should be ignored.
949 // Get the target we should use for the output file.
952 { return this->target_; }
954 // For each dynamic object, check whether we've seen all of its
955 // explicit dependencies.
957 check_dynamic_dependencies() const;
959 // Iterate over all regular objects.
963 { return this->relobj_list_.begin(); }
967 { return this->relobj_list_.end(); }
969 // Iterate over all dynamic objects.
973 { return this->dynobj_list_.begin(); }
977 { return this->dynobj_list_.end(); }
979 // Return whether we have seen any dynamic objects.
982 { return !this->dynobj_list_.empty(); }
984 // Return the number of input objects.
986 number_of_input_objects() const
987 { return this->relobj_list_.size() + this->dynobj_list_.size(); }
990 Input_objects(const Input_objects&);
991 Input_objects& operator=(const Input_objects&);
993 // The list of ordinary objects included in the link.
994 Relobj_list relobj_list_;
995 // The list of dynamic objects included in the link.
996 Dynobj_list dynobj_list_;
999 // SONAMEs that we have seen.
1000 Unordered_set<std::string> sonames_;
1003 // Some of the information we pass to the relocation routines. We
1004 // group this together to avoid passing a dozen different arguments.
1006 template<int size, bool big_endian>
1007 struct Relocate_info
1009 // Command line options.
1010 const General_options* options;
1012 const Symbol_table* symtab;
1014 const Layout* layout;
1015 // Object being relocated.
1016 Sized_relobj<size, big_endian>* object;
1017 // Section index of relocation section.
1018 unsigned int reloc_shndx;
1019 // Section index of section being relocated.
1020 unsigned int data_shndx;
1022 // Return a string showing the location of a relocation. This is
1023 // only used for error messages.
1025 location(size_t relnum, off_t reloffset) const;
1028 // Return an Object appropriate for the input file. P is BYTES long,
1029 // and holds the ELF header.
1032 make_elf_object(const std::string& name, Input_file*,
1033 off_t offset, const unsigned char* p,
1036 } // end namespace gold
1038 #endif // !defined(GOLD_OBJECT_H)