1 // output.h -- manage the output file for 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.
31 #include "reloc-types.h"
36 class General_options
;
42 template<int size
, bool big_endian
>
44 template<int size
, bool big_endian
>
47 // An abtract class for data which has to go into the output file.
52 explicit Output_data(off_t data_size
= 0)
53 : address_(0), data_size_(data_size
), offset_(-1)
59 // Return the address. This is only valid after Layout::finalize is
63 { return this->address_
; }
65 // Return the size of the data. This must be valid after
66 // Layout::finalize calls set_address, but need not be valid before
70 { return this->data_size_
; }
72 // Return the file offset. This is only valid after
73 // Layout::finalize is finished.
76 { return this->offset_
; }
78 // Return the required alignment.
81 { return this->do_addralign(); }
83 // Return whether this is an Output_section.
86 { return this->do_is_section(); }
88 // Return whether this is an Output_section of the specified type.
90 is_section_type(elfcpp::Elf_Word stt
) const
91 { return this->do_is_section_type(stt
); }
93 // Return whether this is an Output_section with the specified flag
96 is_section_flag_set(elfcpp::Elf_Xword shf
) const
97 { return this->do_is_section_flag_set(shf
); }
99 // Return the output section index, if there is an output section.
102 { return this->do_out_shndx(); }
104 // Set the output section index, if this is an output section.
106 set_out_shndx(unsigned int shndx
)
107 { this->do_set_out_shndx(shndx
); }
109 // Set the address and file offset of this data. This is called
110 // during Layout::finalize.
112 set_address(uint64_t addr
, off_t off
);
114 // Write the data to the output file. This is called after
115 // Layout::finalize is complete.
117 write(Output_file
* file
)
118 { this->do_write(file
); }
120 // This is called by Layout::finalize to note that all sizes must
124 { Output_data::sizes_are_fixed
= true; }
127 // Functions that child classes may or in some cases must implement.
129 // Write the data to the output file.
131 do_write(Output_file
*) = 0;
133 // Return the required alignment.
135 do_addralign() const = 0;
137 // Return whether this is an Output_section.
139 do_is_section() const
142 // Return whether this is an Output_section of the specified type.
143 // This only needs to be implement by Output_section.
145 do_is_section_type(elfcpp::Elf_Word
) const
148 // Return whether this is an Output_section with the specific flag
149 // set. This only needs to be implemented by Output_section.
151 do_is_section_flag_set(elfcpp::Elf_Xword
) const
154 // Return the output section index, if there is an output section.
157 { gold_unreachable(); }
159 // Set the output section index, if this is an output section.
161 do_set_out_shndx(unsigned int)
162 { gold_unreachable(); }
164 // Set the address and file offset of the data. This only needs to
165 // be implemented if the child needs to know. The child class can
166 // set its size in this call.
168 do_set_address(uint64_t, off_t
)
171 // Functions that child classes may call.
173 // Set the size of the data.
175 set_data_size(off_t data_size
)
177 gold_assert(!Output_data::sizes_are_fixed
);
178 this->data_size_
= data_size
;
181 // Return default alignment for a size--32 or 64.
183 default_alignment(int size
);
186 Output_data(const Output_data
&);
187 Output_data
& operator=(const Output_data
&);
189 // This is used for verification, to make sure that we don't try to
190 // change any sizes after we set the section addresses.
191 static bool sizes_are_fixed
;
193 // Memory address in file (not always meaningful).
195 // Size of data in file.
197 // Offset within file.
201 // Output the section headers.
203 class Output_section_headers
: public Output_data
206 Output_section_headers(int size
,
209 const Layout::Segment_list
*,
210 const Layout::Section_list
*,
213 // Write the data to the file.
215 do_write(Output_file
*);
217 // Return the required alignment.
220 { return Output_data::default_alignment(this->size_
); }
223 // Write the data to the file with the right size and endianness.
224 template<int size
, bool big_endian
>
226 do_sized_write(Output_file
*);
230 const Layout
* layout_
;
231 const Layout::Segment_list
* segment_list_
;
232 const Layout::Section_list
* unattached_section_list_
;
233 const Stringpool
* secnamepool_
;
236 // Output the segment headers.
238 class Output_segment_headers
: public Output_data
241 Output_segment_headers(int size
, bool big_endian
,
242 const Layout::Segment_list
& segment_list
);
244 // Write the data to the file.
246 do_write(Output_file
*);
248 // Return the required alignment.
251 { return Output_data::default_alignment(this->size_
); }
254 // Write the data to the file with the right size and endianness.
255 template<int size
, bool big_endian
>
257 do_sized_write(Output_file
*);
261 const Layout::Segment_list
& segment_list_
;
264 // Output the ELF file header.
266 class Output_file_header
: public Output_data
269 Output_file_header(int size
,
273 const Output_segment_headers
*);
275 // Add information about the section headers. We lay out the ELF
276 // file header before we create the section headers.
277 void set_section_info(const Output_section_headers
*,
278 const Output_section
* shstrtab
);
280 // Write the data to the file.
282 do_write(Output_file
*);
284 // Return the required alignment.
287 { return Output_data::default_alignment(this->size_
); }
289 // Set the address and offset--we only implement this for error
292 do_set_address(uint64_t, off_t off
) const
293 { gold_assert(off
== 0); }
296 // Write the data to the file with the right size and endianness.
297 template<int size
, bool big_endian
>
299 do_sized_write(Output_file
*);
303 const Target
* target_
;
304 const Symbol_table
* symtab_
;
305 const Output_segment_headers
* segment_header_
;
306 const Output_section_headers
* section_header_
;
307 const Output_section
* shstrtab_
;
310 // Output sections are mainly comprised of input sections. However,
311 // there are cases where we have data to write out which is not in an
312 // input section. Output_section_data is used in such cases. This is
313 // an abstract base class.
315 class Output_section_data
: public Output_data
318 Output_section_data(off_t data_size
, uint64_t addralign
)
319 : Output_data(data_size
), output_section_(NULL
), addralign_(addralign
)
322 Output_section_data(uint64_t addralign
)
323 : Output_data(0), output_section_(NULL
), addralign_(addralign
)
326 // Return the output section.
327 const Output_section
*
328 output_section() const
329 { return this->output_section_
; }
331 // Record the output section.
333 set_output_section(Output_section
* os
);
335 // Add an input section, for SHF_MERGE sections. This returns true
336 // if the section was handled.
338 add_input_section(Relobj
* object
, unsigned int shndx
)
339 { return this->do_add_input_section(object
, shndx
); }
341 // Given an input OBJECT, an input section index SHNDX within that
342 // object, and an OFFSET relative to the start of that input
343 // section, return whether or not the output address is known.
344 // OUTPUT_SECTION_ADDRESS is the address of the output section which
345 // this is a part of. If this function returns true, it sets
346 // *POUTPUT to the output address.
348 output_address(const Relobj
* object
, unsigned int shndx
, off_t offset
,
349 uint64_t output_section_address
, uint64_t *poutput
) const
351 return this->do_output_address(object
, shndx
, offset
,
352 output_section_address
, poutput
);
356 // The child class must implement do_write.
358 // The child class may implement specific adjustments to the output
361 do_adjust_output_section(Output_section
*)
364 // May be implemented by child class. Return true if the section
367 do_add_input_section(Relobj
*, unsigned int)
368 { gold_unreachable(); }
370 // The child class may implement output_address.
372 do_output_address(const Relobj
*, unsigned int, off_t
, uint64_t,
376 // Return the required alignment.
379 { return this->addralign_
; }
381 // Return the section index of the output section.
383 do_out_shndx() const;
385 // Set the alignment.
387 set_addralign(uint64_t addralign
)
388 { this->addralign_
= addralign
; }
391 // The output section for this section.
392 const Output_section
* output_section_
;
393 // The required alignment.
397 // A simple case of Output_data in which we have constant data to
400 class Output_data_const
: public Output_section_data
403 Output_data_const(const std::string
& data
, uint64_t addralign
)
404 : Output_section_data(data
.size(), addralign
), data_(data
)
407 Output_data_const(const char* p
, off_t len
, uint64_t addralign
)
408 : Output_section_data(len
, addralign
), data_(p
, len
)
411 Output_data_const(const unsigned char* p
, off_t len
, uint64_t addralign
)
412 : Output_section_data(len
, addralign
),
413 data_(reinterpret_cast<const char*>(p
), len
)
418 add_data(const std::string
& add
)
420 this->data_
.append(add
);
421 this->set_data_size(this->data_
.size());
424 // Write the data to the output file.
426 do_write(Output_file
*);
432 // Another version of Output_data with constant data, in which the
433 // buffer is allocated by the caller.
435 class Output_data_const_buffer
: public Output_section_data
438 Output_data_const_buffer(const unsigned char* p
, off_t len
,
440 : Output_section_data(len
, addralign
), p_(p
)
443 // Write the data the output file.
445 do_write(Output_file
*);
448 const unsigned char* p_
;
451 // A place holder for data written out via some other mechanism.
453 class Output_data_space
: public Output_section_data
456 Output_data_space(off_t data_size
, uint64_t addralign
)
457 : Output_section_data(data_size
, addralign
)
460 explicit Output_data_space(uint64_t addralign
)
461 : Output_section_data(addralign
)
466 set_space_size(off_t space_size
)
467 { this->set_data_size(space_size
); }
469 // Set the alignment.
471 set_space_alignment(uint64_t align
)
472 { this->set_addralign(align
); }
474 // Write out the data--this must be handled elsewhere.
476 do_write(Output_file
*)
480 // A string table which goes into an output section.
482 class Output_data_strtab
: public Output_section_data
485 Output_data_strtab(Stringpool
* strtab
)
486 : Output_section_data(1), strtab_(strtab
)
489 // This is called to set the address and file offset. Here we make
490 // sure that the Stringpool is finalized.
492 do_set_address(uint64_t, off_t
);
494 // Write out the data.
496 do_write(Output_file
*);
502 // This POD class is used to represent a single reloc in the output
503 // file. This could be a private class within Output_data_reloc, but
504 // the templatization is complex enough that I broke it out into a
505 // separate class. The class is templatized on either elfcpp::SHT_REL
506 // or elfcpp::SHT_RELA, and also on whether this is a dynamic
507 // relocation or an ordinary relocation.
509 // A relocation can be against a global symbol, a local symbol, an
510 // output section, or the undefined symbol at index 0. We represent
511 // the latter by using a NULL global symbol.
513 template<int sh_type
, bool dynamic
, int size
, bool big_endian
>
516 template<bool dynamic
, int size
, bool big_endian
>
517 class Output_reloc
<elfcpp::SHT_REL
, dynamic
, size
, big_endian
>
520 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Address
;
522 // An uninitialized entry. We need this because we want to put
523 // instances of this class into an STL container.
525 : local_sym_index_(INVALID_CODE
)
528 // A reloc against a global symbol.
530 Output_reloc(Symbol
* gsym
, unsigned int type
, Output_data
* od
,
532 : address_(address
), local_sym_index_(GSYM_CODE
), type_(type
),
535 this->u1_
.gsym
= gsym
;
539 Output_reloc(Symbol
* gsym
, unsigned int type
, Relobj
* relobj
,
540 unsigned int shndx
, Address address
)
541 : address_(address
), local_sym_index_(GSYM_CODE
), type_(type
),
544 gold_assert(shndx
!= INVALID_CODE
);
545 this->u1_
.gsym
= gsym
;
546 this->u2_
.relobj
= relobj
;
549 // A reloc against a local symbol.
551 Output_reloc(Sized_relobj
<size
, big_endian
>* relobj
,
552 unsigned int local_sym_index
,
556 : address_(address
), local_sym_index_(local_sym_index
), type_(type
),
559 gold_assert(local_sym_index
!= GSYM_CODE
560 && local_sym_index
!= INVALID_CODE
);
561 this->u1_
.relobj
= relobj
;
565 Output_reloc(Sized_relobj
<size
, big_endian
>* relobj
,
566 unsigned int local_sym_index
,
570 : address_(address
), local_sym_index_(local_sym_index
), type_(type
),
573 gold_assert(local_sym_index
!= GSYM_CODE
574 && local_sym_index
!= INVALID_CODE
);
575 gold_assert(shndx
!= INVALID_CODE
);
576 this->u1_
.relobj
= relobj
;
577 this->u2_
.relobj
= relobj
;
580 // A reloc against the STT_SECTION symbol of an output section.
582 Output_reloc(Output_section
* os
, unsigned int type
, Output_data
* od
,
584 : address_(address
), local_sym_index_(SECTION_CODE
), type_(type
),
591 Output_reloc(Output_section
* os
, unsigned int type
, Relobj
* relobj
,
592 unsigned int shndx
, Address address
)
593 : address_(address
), local_sym_index_(SECTION_CODE
), type_(type
),
596 gold_assert(shndx
!= INVALID_CODE
);
598 this->u2_
.relobj
= relobj
;
601 // Write the reloc entry to an output view.
603 write(unsigned char* pov
) const;
605 // Write the offset and info fields to Write_rel.
606 template<typename Write_rel
>
607 void write_rel(Write_rel
*) const;
610 // Return the symbol index. We can't do a double template
611 // specialization, so we do a secondary template here.
613 get_symbol_index() const;
615 // Codes for local_sym_index_.
622 // Invalid uninitialized entry.
628 // For a local symbol, the object. We will never generate a
629 // relocation against a local symbol in a dynamic object; that
630 // doesn't make sense. And our callers will always be
631 // templatized, so we use Sized_relobj here.
632 Sized_relobj
<size
, big_endian
>* relobj
;
633 // For a global symbol, the symbol. If this is NULL, it indicates
634 // a relocation against the undefined 0 symbol.
636 // For a relocation against an output section, the output section.
641 // If shndx_ is not INVALID CODE, the object which holds the input
642 // section being used to specify the reloc address.
644 // If shndx_ is INVALID_CODE, the output data being used to
645 // specify the reloc address. This may be NULL if the reloc
646 // address is absolute.
649 // The address offset within the input section or the Output_data.
651 // For a local symbol, the local symbol index. This is GSYM_CODE
652 // for a global symbol, or INVALID_CODE for an uninitialized value.
653 unsigned int local_sym_index_
;
654 // The reloc type--a processor specific code.
656 // If the reloc address is an input section in an object, the
657 // section index. This is INVALID_CODE if the reloc address is
658 // specified in some other way.
662 // The SHT_RELA version of Output_reloc<>. This is just derived from
663 // the SHT_REL version of Output_reloc, but it adds an addend.
665 template<bool dynamic
, int size
, bool big_endian
>
666 class Output_reloc
<elfcpp::SHT_RELA
, dynamic
, size
, big_endian
>
669 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Address
;
670 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Addend
;
672 // An uninitialized entry.
677 // A reloc against a global symbol.
679 Output_reloc(Symbol
* gsym
, unsigned int type
, Output_data
* od
,
680 Address address
, Addend addend
)
681 : rel_(gsym
, type
, od
, address
), addend_(addend
)
684 Output_reloc(Symbol
* gsym
, unsigned int type
, Relobj
* relobj
,
685 unsigned int shndx
, Address address
, Addend addend
)
686 : rel_(gsym
, type
, relobj
, shndx
, address
), addend_(addend
)
689 // A reloc against a local symbol.
691 Output_reloc(Sized_relobj
<size
, big_endian
>* relobj
,
692 unsigned int local_sym_index
,
693 unsigned int type
, Output_data
* od
, Address address
,
695 : rel_(relobj
, local_sym_index
, type
, od
, address
), addend_(addend
)
698 Output_reloc(Sized_relobj
<size
, big_endian
>* relobj
,
699 unsigned int local_sym_index
,
704 : rel_(relobj
, local_sym_index
, type
, shndx
, address
),
708 // A reloc against the STT_SECTION symbol of an output section.
710 Output_reloc(Output_section
* os
, unsigned int type
, Output_data
* od
,
711 Address address
, Addend addend
)
712 : rel_(os
, type
, od
, address
), addend_(addend
)
715 Output_reloc(Output_section
* os
, unsigned int type
, Relobj
* relobj
,
716 unsigned int shndx
, Address address
, Addend addend
)
717 : rel_(os
, type
, relobj
, shndx
, address
), addend_(addend
)
720 // Write the reloc entry to an output view.
722 write(unsigned char* pov
) const;
726 Output_reloc
<elfcpp::SHT_REL
, dynamic
, size
, big_endian
> rel_
;
731 // Output_data_reloc is used to manage a section containing relocs.
732 // SH_TYPE is either elfcpp::SHT_REL or elfcpp::SHT_RELA. DYNAMIC
733 // indicates whether this is a dynamic relocation or a normal
734 // relocation. Output_data_reloc_base is a base class.
735 // Output_data_reloc is the real class, which we specialize based on
738 template<int sh_type
, bool dynamic
, int size
, bool big_endian
>
739 class Output_data_reloc_base
: public Output_section_data
742 typedef Output_reloc
<sh_type
, dynamic
, size
, big_endian
> Output_reloc_type
;
743 typedef typename
Output_reloc_type::Address Address
;
744 static const int reloc_size
=
745 Reloc_types
<sh_type
, size
, big_endian
>::reloc_size
;
747 // Construct the section.
748 Output_data_reloc_base()
749 : Output_section_data(Output_data::default_alignment(size
))
752 // Write out the data.
754 do_write(Output_file
*);
757 // Set the entry size and the link.
759 do_adjust_output_section(Output_section
*os
);
761 // Add a relocation entry.
763 add(const Output_reloc_type
& reloc
)
765 this->relocs_
.push_back(reloc
);
766 this->set_data_size(this->relocs_
.size() * reloc_size
);
770 typedef std::vector
<Output_reloc_type
> Relocs
;
775 // The class which callers actually create.
777 template<int sh_type
, bool dynamic
, int size
, bool big_endian
>
778 class Output_data_reloc
;
780 // The SHT_REL version of Output_data_reloc.
782 template<bool dynamic
, int size
, bool big_endian
>
783 class Output_data_reloc
<elfcpp::SHT_REL
, dynamic
, size
, big_endian
>
784 : public Output_data_reloc_base
<elfcpp::SHT_REL
, dynamic
, size
, big_endian
>
787 typedef Output_data_reloc_base
<elfcpp::SHT_REL
, dynamic
, size
,
791 typedef typename
Base::Output_reloc_type Output_reloc_type
;
792 typedef typename
Output_reloc_type::Address Address
;
795 : Output_data_reloc_base
<elfcpp::SHT_REL
, dynamic
, size
, big_endian
>()
798 // Add a reloc against a global symbol.
801 add_global(Symbol
* gsym
, unsigned int type
, Output_data
* od
, Address address
)
802 { this->add(Output_reloc_type(gsym
, type
, od
, address
)); }
805 add_global(Symbol
* gsym
, unsigned int type
, Relobj
* relobj
,
806 unsigned int shndx
, Address address
)
807 { this->add(Output_reloc_type(gsym
, type
, relobj
, shndx
, address
)); }
809 // Add a reloc against a local symbol.
812 add_local(Sized_relobj
<size
, big_endian
>* relobj
,
813 unsigned int local_sym_index
, unsigned int type
,
814 Output_data
* od
, Address address
)
815 { this->add(Output_reloc_type(relobj
, local_sym_index
, type
, od
, address
)); }
818 add_local(Sized_relobj
<size
, big_endian
>* relobj
,
819 unsigned int local_sym_index
, unsigned int type
,
820 unsigned int shndx
, Address address
)
821 { this->add(Output_reloc_type(relobj
, local_sym_index
, type
, shndx
,
825 // A reloc against the STT_SECTION symbol of an output section.
828 add_output_section(Output_section
* os
, unsigned int type
,
829 Output_data
* od
, Address address
)
830 { this->add(Output_reloc_type(os
, type
, od
, address
)); }
833 add_output_section(Output_section
* os
, unsigned int type
,
834 Relobj
* relobj
, unsigned int shndx
, Address address
)
835 { this->add(Output_reloc_type(os
, type
, relobj
, shndx
, address
)); }
838 // The SHT_RELA version of Output_data_reloc.
840 template<bool dynamic
, int size
, bool big_endian
>
841 class Output_data_reloc
<elfcpp::SHT_RELA
, dynamic
, size
, big_endian
>
842 : public Output_data_reloc_base
<elfcpp::SHT_RELA
, dynamic
, size
, big_endian
>
845 typedef Output_data_reloc_base
<elfcpp::SHT_RELA
, dynamic
, size
,
849 typedef typename
Base::Output_reloc_type Output_reloc_type
;
850 typedef typename
Output_reloc_type::Address Address
;
851 typedef typename
Output_reloc_type::Addend Addend
;
854 : Output_data_reloc_base
<elfcpp::SHT_RELA
, dynamic
, size
, big_endian
>()
857 // Add a reloc against a global symbol.
860 add_global(Symbol
* gsym
, unsigned int type
, Output_data
* od
,
861 Address address
, Addend addend
)
862 { this->add(Output_reloc_type(gsym
, type
, od
, address
, addend
)); }
865 add_global(Symbol
* gsym
, unsigned int type
, Relobj
* relobj
,
866 unsigned int shndx
, Address address
, Addend addend
)
867 { this->add(Output_reloc_type(gsym
, type
, relobj
, shndx
, address
, addend
)); }
869 // Add a reloc against a local symbol.
872 add_local(Sized_relobj
<size
, big_endian
>* relobj
,
873 unsigned int local_sym_index
, unsigned int type
,
874 Output_data
* od
, Address address
, Addend addend
)
876 this->add(Output_reloc_type(relobj
, local_sym_index
, type
, od
, address
,
881 add_local(Sized_relobj
<size
, big_endian
>* relobj
,
882 unsigned int local_sym_index
, unsigned int type
,
883 unsigned int shndx
, Address address
, Addend addend
)
885 this->add(Output_reloc_type(relobj
, local_sym_index
, type
, shndx
, address
,
889 // A reloc against the STT_SECTION symbol of an output section.
892 add_output_section(Output_section
* os
, unsigned int type
, Output_data
* od
,
893 Address address
, Addend addend
)
894 { this->add(Output_reloc_type(os
, type
, od
, address
, addend
)); }
897 add_output_section(Output_section
* os
, unsigned int type
, Relobj
* relobj
,
898 unsigned int shndx
, Address address
, Addend addend
)
899 { this->add(Output_reloc_type(os
, type
, relobj
, shndx
, address
, addend
)); }
902 // Output_data_got is used to manage a GOT. Each entry in the GOT is
903 // for one symbol--either a global symbol or a local symbol in an
904 // object. The target specific code adds entries to the GOT as
907 template<int size
, bool big_endian
>
908 class Output_data_got
: public Output_section_data
911 typedef typename
elfcpp::Elf_types
<size
>::Elf_Addr Valtype
;
914 : Output_section_data(Output_data::default_alignment(size
)), entries_()
917 // Add an entry for a global symbol to the GOT. Return true if this
918 // is a new GOT entry, false if the symbol was already in the GOT.
920 add_global(Symbol
* gsym
);
922 // Add an entry for a local symbol to the GOT. This returns the
923 // offset of the new entry from the start of the GOT.
925 add_local(Object
* object
, unsigned int sym_index
)
927 this->entries_
.push_back(Got_entry(object
, sym_index
));
928 this->set_got_size();
929 return this->last_got_offset();
932 // Add a constant to the GOT. This returns the offset of the new
933 // entry from the start of the GOT.
935 add_constant(Valtype constant
)
937 this->entries_
.push_back(Got_entry(constant
));
938 this->set_got_size();
939 return this->last_got_offset();
942 // Write out the GOT table.
944 do_write(Output_file
*);
947 // This POD class holds a single GOT entry.
951 // Create a zero entry.
953 : local_sym_index_(CONSTANT_CODE
)
954 { this->u_
.constant
= 0; }
956 // Create a global symbol entry.
957 explicit Got_entry(Symbol
* gsym
)
958 : local_sym_index_(GSYM_CODE
)
959 { this->u_
.gsym
= gsym
; }
961 // Create a local symbol entry.
962 Got_entry(Object
* object
, unsigned int local_sym_index
)
963 : local_sym_index_(local_sym_index
)
965 gold_assert(local_sym_index
!= GSYM_CODE
966 && local_sym_index
!= CONSTANT_CODE
);
967 this->u_
.object
= object
;
970 // Create a constant entry. The constant is a host value--it will
971 // be swapped, if necessary, when it is written out.
972 explicit Got_entry(Valtype constant
)
973 : local_sym_index_(CONSTANT_CODE
)
974 { this->u_
.constant
= constant
; }
976 // Write the GOT entry to an output view.
978 write(unsigned char* pov
) const;
989 // For a local symbol, the object.
991 // For a global symbol, the symbol.
993 // For a constant, the constant.
996 // For a local symbol, the local symbol index. This is GSYM_CODE
997 // for a global symbol, or CONSTANT_CODE for a constant.
998 unsigned int local_sym_index_
;
1001 typedef std::vector
<Got_entry
> Got_entries
;
1003 // Return the offset into the GOT of GOT entry I.
1005 got_offset(unsigned int i
) const
1006 { return i
* (size
/ 8); }
1008 // Return the offset into the GOT of the last entry added.
1010 last_got_offset() const
1011 { return this->got_offset(this->entries_
.size() - 1); }
1013 // Set the size of the section.
1016 { this->set_data_size(this->got_offset(this->entries_
.size())); }
1018 // The list of GOT entries.
1019 Got_entries entries_
;
1022 // Output_data_dynamic is used to hold the data in SHT_DYNAMIC
1025 class Output_data_dynamic
: public Output_section_data
1028 Output_data_dynamic(const Target
* target
, Stringpool
* pool
)
1029 : Output_section_data(Output_data::default_alignment(target
->get_size())),
1030 target_(target
), entries_(), pool_(pool
)
1033 // Add a new dynamic entry with a fixed numeric value.
1035 add_constant(elfcpp::DT tag
, unsigned int val
)
1036 { this->add_entry(Dynamic_entry(tag
, val
)); }
1038 // Add a new dynamic entry with the address of output data.
1040 add_section_address(elfcpp::DT tag
, const Output_data
* od
)
1041 { this->add_entry(Dynamic_entry(tag
, od
, false)); }
1043 // Add a new dynamic entry with the size of output data.
1045 add_section_size(elfcpp::DT tag
, const Output_data
* od
)
1046 { this->add_entry(Dynamic_entry(tag
, od
, true)); }
1048 // Add a new dynamic entry with the address of a symbol.
1050 add_symbol(elfcpp::DT tag
, const Symbol
* sym
)
1051 { this->add_entry(Dynamic_entry(tag
, sym
)); }
1053 // Add a new dynamic entry with a string.
1055 add_string(elfcpp::DT tag
, const char* str
)
1056 { this->add_entry(Dynamic_entry(tag
, this->pool_
->add(str
, NULL
))); }
1059 add_string(elfcpp::DT tag
, const std::string
& str
)
1060 { this->add_string(tag
, str
.c_str()); }
1062 // Set the final data size.
1064 do_set_address(uint64_t, off_t
);
1066 // Write out the dynamic entries.
1068 do_write(Output_file
*);
1071 // Adjust the output section to set the entry size.
1073 do_adjust_output_section(Output_section
*);
1076 // This POD class holds a single dynamic entry.
1080 // Create an entry with a fixed numeric value.
1081 Dynamic_entry(elfcpp::DT tag
, unsigned int val
)
1082 : tag_(tag
), classification_(DYNAMIC_NUMBER
)
1083 { this->u_
.val
= val
; }
1085 // Create an entry with the size or address of a section.
1086 Dynamic_entry(elfcpp::DT tag
, const Output_data
* od
, bool section_size
)
1088 classification_(section_size
1089 ? DYNAMIC_SECTION_SIZE
1090 : DYNAMIC_SECTION_ADDRESS
)
1091 { this->u_
.od
= od
; }
1093 // Create an entry with the address of a symbol.
1094 Dynamic_entry(elfcpp::DT tag
, const Symbol
* sym
)
1095 : tag_(tag
), classification_(DYNAMIC_SYMBOL
)
1096 { this->u_
.sym
= sym
; }
1098 // Create an entry with a string.
1099 Dynamic_entry(elfcpp::DT tag
, const char* str
)
1100 : tag_(tag
), classification_(DYNAMIC_STRING
)
1101 { this->u_
.str
= str
; }
1103 // Write the dynamic entry to an output view.
1104 template<int size
, bool big_endian
>
1106 write(unsigned char* pov
, const Stringpool
* ACCEPT_SIZE_ENDIAN
) const;
1114 DYNAMIC_SECTION_ADDRESS
,
1116 DYNAMIC_SECTION_SIZE
,
1125 // For DYNAMIC_NUMBER.
1127 // For DYNAMIC_SECTION_ADDRESS and DYNAMIC_SECTION_SIZE.
1128 const Output_data
* od
;
1129 // For DYNAMIC_SYMBOL.
1131 // For DYNAMIC_STRING.
1136 // The type of entry.
1137 Classification classification_
;
1140 // Add an entry to the list.
1142 add_entry(const Dynamic_entry
& entry
)
1143 { this->entries_
.push_back(entry
); }
1145 // Sized version of write function.
1146 template<int size
, bool big_endian
>
1148 sized_write(Output_file
* of
);
1150 // The type of the list of entries.
1151 typedef std::vector
<Dynamic_entry
> Dynamic_entries
;
1154 const Target
* target_
;
1156 Dynamic_entries entries_
;
1157 // The pool used for strings.
1161 // An output section. We don't expect to have too many output
1162 // sections, so we don't bother to do a template on the size.
1164 class Output_section
: public Output_data
1167 // Create an output section, giving the name, type, and flags.
1168 Output_section(const char* name
, elfcpp::Elf_Word
, elfcpp::Elf_Xword
);
1169 virtual ~Output_section();
1171 // Add a new input section SHNDX, named NAME, with header SHDR, from
1172 // object OBJECT. Return the offset within the output section.
1173 template<int size
, bool big_endian
>
1175 add_input_section(Relobj
* object
, unsigned int shndx
, const char *name
,
1176 const elfcpp::Shdr
<size
, big_endian
>& shdr
);
1178 // Add generated data POSD to this output section.
1180 add_output_section_data(Output_section_data
* posd
);
1182 // Return the section name.
1185 { return this->name_
; }
1187 // Return the section type.
1190 { return this->type_
; }
1192 // Return the section flags.
1195 { return this->flags_
; }
1197 // Return the section index in the output file.
1199 do_out_shndx() const
1200 { return this->out_shndx_
; }
1202 // Set the output section index.
1204 do_set_out_shndx(unsigned int shndx
)
1205 { this->out_shndx_
= shndx
; }
1207 // Return the entsize field.
1210 { return this->entsize_
; }
1212 // Set the entsize field.
1214 set_entsize(uint64_t v
);
1216 // Set the link field to the output section index of a section.
1218 set_link_section(const Output_data
* od
)
1220 gold_assert(this->link_
== 0
1221 && !this->should_link_to_symtab_
1222 && !this->should_link_to_dynsym_
);
1223 this->link_section_
= od
;
1226 // Set the link field to a constant.
1228 set_link(unsigned int v
)
1230 gold_assert(this->link_section_
== NULL
1231 && !this->should_link_to_symtab_
1232 && !this->should_link_to_dynsym_
);
1236 // Record that this section should link to the normal symbol table.
1238 set_should_link_to_symtab()
1240 gold_assert(this->link_section_
== NULL
1242 && !this->should_link_to_dynsym_
);
1243 this->should_link_to_symtab_
= true;
1246 // Record that this section should link to the dynamic symbol table.
1248 set_should_link_to_dynsym()
1250 gold_assert(this->link_section_
== NULL
1252 && !this->should_link_to_symtab_
);
1253 this->should_link_to_dynsym_
= true;
1256 // Return the info field.
1260 gold_assert(this->info_section_
== NULL
);
1264 // Set the info field to the output section index of a section.
1266 set_info_section(const Output_data
* od
)
1268 gold_assert(this->info_
== 0);
1269 this->info_section_
= od
;
1272 // Set the info field to a constant.
1274 set_info(unsigned int v
)
1276 gold_assert(this->info_section_
== NULL
);
1280 // Set the addralign field.
1282 set_addralign(uint64_t v
)
1283 { this->addralign_
= v
; }
1285 // Indicate that we need a symtab index.
1287 set_needs_symtab_index()
1288 { this->needs_symtab_index_
= true; }
1290 // Return whether we need a symtab index.
1292 needs_symtab_index() const
1293 { return this->needs_symtab_index_
; }
1295 // Get the symtab index.
1297 symtab_index() const
1299 gold_assert(this->symtab_index_
!= 0);
1300 return this->symtab_index_
;
1303 // Set the symtab index.
1305 set_symtab_index(unsigned int index
)
1307 gold_assert(index
!= 0);
1308 this->symtab_index_
= index
;
1311 // Indicate that we need a dynsym index.
1313 set_needs_dynsym_index()
1314 { this->needs_dynsym_index_
= true; }
1316 // Return whether we need a dynsym index.
1318 needs_dynsym_index() const
1319 { return this->needs_dynsym_index_
; }
1321 // Get the dynsym index.
1323 dynsym_index() const
1325 gold_assert(this->dynsym_index_
!= 0);
1326 return this->dynsym_index_
;
1329 // Set the dynsym index.
1331 set_dynsym_index(unsigned int index
)
1333 gold_assert(index
!= 0);
1334 this->dynsym_index_
= index
;
1337 // Return the output virtual address of OFFSET relative to the start
1338 // of input section SHNDX in object OBJECT.
1340 output_address(const Relobj
* object
, unsigned int shndx
,
1341 off_t offset
) const;
1343 // Set the address of the Output_section. For a typical
1344 // Output_section, there is nothing to do, but if there are any
1345 // Output_section_data objects we need to set the final addresses
1348 do_set_address(uint64_t, off_t
);
1350 // Write the data to the file. For a typical Output_section, this
1351 // does nothing: the data is written out by calling Object::Relocate
1352 // on each input object. But if there are any Output_section_data
1353 // objects we do need to write them out here.
1355 do_write(Output_file
*);
1357 // Return the address alignment--function required by parent class.
1359 do_addralign() const
1360 { return this->addralign_
; }
1362 // Return whether this is an Output_section.
1364 do_is_section() const
1367 // Return whether this is a section of the specified type.
1369 do_is_section_type(elfcpp::Elf_Word type
) const
1370 { return this->type_
== type
; }
1372 // Return whether the specified section flag is set.
1374 do_is_section_flag_set(elfcpp::Elf_Xword flag
) const
1375 { return (this->flags_
& flag
) != 0; }
1377 // Write the section header into *OPHDR.
1378 template<int size
, bool big_endian
>
1380 write_header(const Layout
*, const Stringpool
*,
1381 elfcpp::Shdr_write
<size
, big_endian
>*) const;
1384 // In some cases we need to keep a list of the input sections
1385 // associated with this output section. We only need the list if we
1386 // might have to change the offsets of the input section within the
1387 // output section after we add the input section. The ordinary
1388 // input sections will be written out when we process the object
1389 // file, and as such we don't need to track them here. We do need
1390 // to track Output_section_data objects here. We store instances of
1391 // this structure in a std::vector, so it must be a POD. There can
1392 // be many instances of this structure, so we use a union to save
1398 : shndx_(0), p2align_(0)
1400 this->u1_
.data_size
= 0;
1401 this->u2_
.object
= NULL
;
1404 // For an ordinary input section.
1405 Input_section(Relobj
* object
, unsigned int shndx
, off_t data_size
,
1408 p2align_(ffsll(static_cast<long long>(addralign
)))
1410 gold_assert(shndx
!= OUTPUT_SECTION_CODE
1411 && shndx
!= MERGE_DATA_SECTION_CODE
1412 && shndx
!= MERGE_STRING_SECTION_CODE
);
1413 this->u1_
.data_size
= data_size
;
1414 this->u2_
.object
= object
;
1417 // For a non-merge output section.
1418 Input_section(Output_section_data
* posd
)
1419 : shndx_(OUTPUT_SECTION_CODE
),
1420 p2align_(ffsll(static_cast<long long>(posd
->addralign())))
1422 this->u1_
.data_size
= 0;
1423 this->u2_
.posd
= posd
;
1426 // For a merge section.
1427 Input_section(Output_section_data
* posd
, bool is_string
, uint64_t entsize
)
1429 ? MERGE_STRING_SECTION_CODE
1430 : MERGE_DATA_SECTION_CODE
),
1431 p2align_(ffsll(static_cast<long long>(posd
->addralign())))
1433 this->u1_
.entsize
= entsize
;
1434 this->u2_
.posd
= posd
;
1437 // The required alignment.
1441 return (this->p2align_
== 0
1443 : static_cast<uint64_t>(1) << (this->p2align_
- 1));
1446 // Return the required size.
1450 // Return whether this is a merge section which matches the
1453 is_merge_section(bool is_string
, uint64_t entsize
) const
1455 return (this->shndx_
== (is_string
1456 ? MERGE_STRING_SECTION_CODE
1457 : MERGE_DATA_SECTION_CODE
)
1458 && this->u1_
.entsize
== entsize
);
1461 // Set the output section.
1463 set_output_section(Output_section
* os
)
1465 gold_assert(!this->is_input_section());
1466 this->u2_
.posd
->set_output_section(os
);
1469 // Set the address and file offset. This is called during
1470 // Layout::finalize. SECOFF is the file offset of the enclosing
1473 set_address(uint64_t addr
, off_t off
, off_t secoff
);
1475 // Add an input section, for SHF_MERGE sections.
1477 add_input_section(Relobj
* object
, unsigned int shndx
)
1479 gold_assert(this->shndx_
== MERGE_DATA_SECTION_CODE
1480 || this->shndx_
== MERGE_STRING_SECTION_CODE
);
1481 return this->u2_
.posd
->add_input_section(object
, shndx
);
1484 // Given an input OBJECT, an input section index SHNDX within that
1485 // object, and an OFFSET relative to the start of that input
1486 // section, return whether or not the output address is known.
1487 // OUTPUT_SECTION_ADDRESS is the address of the output section
1488 // which this is a part of. If this function returns true, it
1489 // sets *POUTPUT to the output address.
1491 output_address(const Relobj
* object
, unsigned int shndx
, off_t offset
,
1492 uint64_t output_section_address
, uint64_t *poutput
) const;
1494 // Write out the data. This does nothing for an input section.
1496 write(Output_file
*);
1499 // Code values which appear in shndx_. If the value is not one of
1500 // these codes, it is the input section index in the object file.
1503 // An Output_section_data.
1504 OUTPUT_SECTION_CODE
= -1U,
1505 // An Output_section_data for an SHF_MERGE section with
1506 // SHF_STRINGS not set.
1507 MERGE_DATA_SECTION_CODE
= -2U,
1508 // An Output_section_data for an SHF_MERGE section with
1510 MERGE_STRING_SECTION_CODE
= -3U
1513 // Whether this is an input section.
1515 is_input_section() const
1517 return (this->shndx_
!= OUTPUT_SECTION_CODE
1518 && this->shndx_
!= MERGE_DATA_SECTION_CODE
1519 && this->shndx_
!= MERGE_STRING_SECTION_CODE
);
1522 // For an ordinary input section, this is the section index in the
1523 // input file. For an Output_section_data, this is
1524 // OUTPUT_SECTION_CODE or MERGE_DATA_SECTION_CODE or
1525 // MERGE_STRING_SECTION_CODE.
1526 unsigned int shndx_
;
1527 // The required alignment, stored as a power of 2.
1528 unsigned int p2align_
;
1531 // For an ordinary input section, the section size.
1533 // For OUTPUT_SECTION_CODE, this is not used. For
1534 // MERGE_DATA_SECTION_CODE or MERGE_STRING_SECTION_CODE, the
1540 // For an ordinary input section, the object which holds the
1543 // For OUTPUT_SECTION_CODE or MERGE_DATA_SECTION_CODE or
1544 // MERGE_STRING_SECTION_CODE, the data.
1545 Output_section_data
* posd
;
1549 typedef std::vector
<Input_section
> Input_section_list
;
1551 // Fill data. This is used to fill in data between input sections.
1552 // When we have to keep track of the input sections, we can use an
1553 // Output_data_const, but we don't want to have to keep track of
1554 // input sections just to implement fills. For a fill we record the
1555 // offset, and the actual data to be written out.
1559 Fill(off_t section_offset
, off_t length
)
1560 : section_offset_(section_offset
), length_(length
)
1563 // Return section offset.
1565 section_offset() const
1566 { return this->section_offset_
; }
1568 // Return fill length.
1571 { return this->length_
; }
1574 // The offset within the output section.
1575 off_t section_offset_
;
1576 // The length of the space to fill.
1580 typedef std::vector
<Fill
> Fill_list
;
1582 // Add a new output section by Input_section.
1584 add_output_section_data(Input_section
*);
1586 // Add an SHF_MERGE input section. Returns true if the section was
1589 add_merge_input_section(Relobj
* object
, unsigned int shndx
, uint64_t flags
,
1590 uint64_t entsize
, uint64_t addralign
);
1592 // Add an output SHF_MERGE section POSD to this output section.
1593 // IS_STRING indicates whether it is a SHF_STRINGS section, and
1594 // ENTSIZE is the entity size. This returns the entry added to
1597 add_output_merge_section(Output_section_data
* posd
, bool is_string
,
1600 // Most of these fields are only valid after layout.
1602 // The name of the section. This will point into a Stringpool.
1604 // The section address is in the parent class.
1605 // The section alignment.
1606 uint64_t addralign_
;
1607 // The section entry size.
1609 // The file offset is in the parent class.
1610 // Set the section link field to the index of this section.
1611 const Output_data
* link_section_
;
1612 // If link_section_ is NULL, this is the link field.
1614 // Set the section info field to the index of this section.
1615 const Output_data
* info_section_
;
1616 // If info_section_ is NULL, this is the section info field.
1618 // The section type.
1619 elfcpp::Elf_Word type_
;
1620 // The section flags.
1621 elfcpp::Elf_Xword flags_
;
1622 // The section index.
1623 unsigned int out_shndx_
;
1624 // If there is a STT_SECTION for this output section in the normal
1625 // symbol table, this is the symbol index. This starts out as zero.
1626 // It is initialized in Layout::finalize() to be the index, or -1U
1627 // if there isn't one.
1628 unsigned int symtab_index_
;
1629 // If there is a STT_SECTION for this output section in the dynamic
1630 // symbol table, this is the symbol index. This starts out as zero.
1631 // It is initialized in Layout::finalize() to be the index, or -1U
1632 // if there isn't one.
1633 unsigned int dynsym_index_
;
1634 // The input sections. This will be empty in cases where we don't
1635 // need to keep track of them.
1636 Input_section_list input_sections_
;
1637 // The offset of the first entry in input_sections_.
1638 off_t first_input_offset_
;
1639 // The fill data. This is separate from input_sections_ because we
1640 // often will need fill sections without needing to keep track of
1643 // Whether this output section needs a STT_SECTION symbol in the
1644 // normal symbol table. This will be true if there is a relocation
1646 bool needs_symtab_index_
: 1;
1647 // Whether this output section needs a STT_SECTION symbol in the
1648 // dynamic symbol table. This will be true if there is a dynamic
1649 // relocation which needs it.
1650 bool needs_dynsym_index_
: 1;
1651 // Whether the link field of this output section should point to the
1652 // normal symbol table.
1653 bool should_link_to_symtab_
: 1;
1654 // Whether the link field of this output section should point to the
1655 // dynamic symbol table.
1656 bool should_link_to_dynsym_
: 1;
1659 // An output segment. PT_LOAD segments are built from collections of
1660 // output sections. Other segments typically point within PT_LOAD
1661 // segments, and are built directly as needed.
1663 class Output_segment
1666 // Create an output segment, specifying the type and flags.
1667 Output_segment(elfcpp::Elf_Word
, elfcpp::Elf_Word
);
1669 // Return the virtual address.
1672 { return this->vaddr_
; }
1674 // Return the physical address.
1677 { return this->paddr_
; }
1679 // Return the segment type.
1682 { return this->type_
; }
1684 // Return the segment flags.
1687 { return this->flags_
; }
1689 // Return the memory size.
1692 { return this->memsz_
; }
1694 // Return the file size.
1697 { return this->filesz_
; }
1699 // Return the maximum alignment of the Output_data.
1703 // Add an Output_section to this segment.
1705 add_output_section(Output_section
* os
, elfcpp::Elf_Word seg_flags
)
1706 { this->add_output_section(os
, seg_flags
, false); }
1708 // Add an Output_section to the start of this segment.
1710 add_initial_output_section(Output_section
* os
, elfcpp::Elf_Word seg_flags
)
1711 { this->add_output_section(os
, seg_flags
, true); }
1713 // Add an Output_data (which is not an Output_section) to the start
1716 add_initial_output_data(Output_data
*);
1718 // Set the address of the segment to ADDR and the offset to *POFF
1719 // (aligned if necessary), and set the addresses and offsets of all
1720 // contained output sections accordingly. Set the section indexes
1721 // of all contained output sections starting with *PSHNDX. Return
1722 // the address of the immediately following segment. Update *POFF
1723 // and *PSHNDX. This should only be called for a PT_LOAD segment.
1725 set_section_addresses(uint64_t addr
, off_t
* poff
, unsigned int* pshndx
);
1727 // Set the minimum alignment of this segment. This may be adjusted
1728 // upward based on the section alignments.
1730 set_minimum_addralign(uint64_t align
)
1732 gold_assert(!this->is_align_known_
);
1733 this->align_
= align
;
1736 // Set the offset of this segment based on the section. This should
1737 // only be called for a non-PT_LOAD segment.
1741 // Return the number of output sections.
1743 output_section_count() const;
1745 // Write the segment header into *OPHDR.
1746 template<int size
, bool big_endian
>
1748 write_header(elfcpp::Phdr_write
<size
, big_endian
>*);
1750 // Write the section headers of associated sections into V.
1751 template<int size
, bool big_endian
>
1753 write_section_headers(const Layout
*, const Stringpool
*, unsigned char* v
,
1754 unsigned int* pshndx ACCEPT_SIZE_ENDIAN
) const;
1757 Output_segment(const Output_segment
&);
1758 Output_segment
& operator=(const Output_segment
&);
1760 typedef std::list
<Output_data
*> Output_data_list
;
1762 // Add an Output_section to this segment, specifying front or back.
1764 add_output_section(Output_section
*, elfcpp::Elf_Word seg_flags
,
1767 // Find the maximum alignment in an Output_data_list.
1769 maximum_alignment(const Output_data_list
*);
1771 // Set the section addresses in an Output_data_list.
1773 set_section_list_addresses(Output_data_list
*, uint64_t addr
, off_t
* poff
,
1774 unsigned int* pshndx
);
1776 // Return the number of Output_sections in an Output_data_list.
1778 output_section_count_list(const Output_data_list
*) const;
1780 // Write the section headers in the list into V.
1781 template<int size
, bool big_endian
>
1783 write_section_headers_list(const Layout
*, const Stringpool
*,
1784 const Output_data_list
*, unsigned char* v
,
1785 unsigned int* pshdx ACCEPT_SIZE_ENDIAN
) const;
1787 // The list of output data with contents attached to this segment.
1788 Output_data_list output_data_
;
1789 // The list of output data without contents attached to this segment.
1790 Output_data_list output_bss_
;
1791 // The segment virtual address.
1793 // The segment physical address.
1795 // The size of the segment in memory.
1797 // The segment alignment. The is_align_known_ field indicates
1798 // whether this has been finalized. It can be set to a minimum
1799 // value before it is finalized.
1801 // The offset of the segment data within the file.
1803 // The size of the segment data in the file.
1805 // The segment type;
1806 elfcpp::Elf_Word type_
;
1807 // The segment flags.
1808 elfcpp::Elf_Word flags_
;
1809 // Whether we have finalized align_.
1810 bool is_align_known_
;
1813 // This class represents the output file.
1818 Output_file(const General_options
& options
, Target
*);
1820 // Get a pointer to the target.
1823 { return this->target_
; }
1825 // Open the output file. FILE_SIZE is the final size of the file.
1827 open(off_t file_size
);
1829 // Close the output file and make sure there are no error.
1833 // We currently always use mmap which makes the view handling quite
1834 // simple. In the future we may support other approaches.
1836 // Write data to the output file.
1838 write(off_t offset
, const void* data
, off_t len
)
1839 { memcpy(this->base_
+ offset
, data
, len
); }
1841 // Get a buffer to use to write to the file, given the offset into
1842 // the file and the size.
1844 get_output_view(off_t start
, off_t size
)
1846 gold_assert(start
>= 0 && size
>= 0 && start
+ size
<= this->file_size_
);
1847 return this->base_
+ start
;
1850 // VIEW must have been returned by get_output_view. Write the
1851 // buffer to the file, passing in the offset and the size.
1853 write_output_view(off_t
, off_t
, unsigned char*)
1858 const General_options
& options_
;
1867 // Base of file mapped into memory.
1868 unsigned char* base_
;
1871 } // End namespace gold.
1873 #endif // !defined(GOLD_OUTPUT_H)