1 // inremental.cc -- incremental linking support for gold
3 // Copyright 2009 Free Software Foundation, Inc.
4 // Written by Mikolaj Zalewski <mikolajz@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.
26 using elfcpp::Convert
;
30 // Version information. Will change frequently during the development, later
31 // we could think about backward (and forward?) compatibility.
32 const int INCREMENTAL_LINK_VERSION
= 1;
36 // Header of the .gnu_incremental_input section.
37 struct Incremental_input_header_data
39 // Incremental linker version.
40 elfcpp::Elf_Word version
;
42 // Numer of input files in the link.
43 elfcpp::Elf_Word input_file_count
;
45 // Offset of command line options in .gnu_incremental_strtab.
46 elfcpp::Elf_Word command_line_offset
;
49 elfcpp::Elf_Word reserved
;
52 // Data stored in .gnu_incremental_input after the header for each of the
53 // Incremental_input_header_data::input_file_count input entries.
54 struct Incremental_input_entry_data
56 // Offset of file name in .gnu_incremental_strtab section.
57 elfcpp::Elf_Word filename_offset
;
59 // Offset of data in .gnu_incremental_input.
60 elfcpp::Elf_Word data_offset
;
62 // Timestamp (in seconds).
63 elfcpp::Elf_Xword timestamp_sec
;
65 // Nano-second part of timestamp (if supported).
66 elfcpp::Elf_Word timestamp_usec
;
68 // Type of the input entry.
69 elfcpp::Elf_Half input_type
;
72 elfcpp::Elf_Half reserved
;
79 // See internal::Incremental_input_header for fields descriptions.
80 template<int size
, bool big_endian
>
81 class Incremental_input_header_write
84 Incremental_input_header_write(unsigned char *p
)
85 : p_(reinterpret_cast<internal::Incremental_input_header_data
>(p
))
89 put_version(elfcpp::Elf_Word v
)
90 { this->p_
->version
= Convert
<32, big_endian
>::convert_host(v
); }
93 input_file_count(elfcpp::Elf_Word v
)
94 { this->p_
->input_file_count
= Convert
<32, big_endian
>::convert_host(v
); }
97 command_line_offset(elfcpp::Elf_Word v
)
98 { this->p_
->command_line_offset
= Convert
<32, big_endian
>::convert_host(v
); }
101 reserved(elfcpp::Elf_Word v
)
102 { this->p_
->reserved
= Convert
<32, big_endian
>::convert_host(v
); }
105 internal::Incremental_input_header_data
* p_
;
108 // See internal::Incremental_input_entry for fields descriptions.
109 template<int size
, bool big_endian
>
110 class Incremental_input_entry_write
113 Incremental_input_entry_write(unsigned char *p
)
114 : p_(reinterpret_cast<internal::Incremental_input_entry_data
>(p
))
118 put_filename_offset(elfcpp::Elf_Word v
)
119 { this->p_
->filename_offset
= Convert
<32, big_endian
>::convert_host(v
); }
122 put_data_offset(elfcpp::Elf_Word v
)
123 { this->p_
->data_offset
= Convert
<32, big_endian
>::convert_host(v
); }
126 put_timestamp_sec(elfcpp::Elf_Word v
)
127 { this->p_
->timestamp_sec
= Convert
<32, big_endian
>::convert_host(v
); }
130 put_timestamp_usec(elfcpp::Elf_Word v
)
131 { this->p_
->timestamp_usec
= Convert
<32, big_endian
>::convert_host(v
); }
134 put_input_type(elfcpp::Elf_Word v
)
135 { this->p_
->input_type
= Convert
<32, big_endian
>::convert_host(v
); }
138 put_reserved(elfcpp::Elf_Word v
)
139 { this->p_
->reserved
= Convert
<32, big_endian
>::convert_host(v
); }
142 internal::Incremental_input_entry_data
* p_
;
145 } // End namespace gold.