]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gold/incremental.cc
include/elf:
[thirdparty/binutils-gdb.git] / gold / incremental.cc
1 // inremental.cc -- incremental linking support for gold
2
3 // Copyright 2009 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 #include "gold.h"
24 #include "elfcpp.h"
25
26 using elfcpp::Convert;
27
28 namespace gold {
29
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;
33
34 namespace internal {
35
36 // Header of the .gnu_incremental_input section.
37 struct Incremental_input_header_data
38 {
39 // Incremental linker version.
40 elfcpp::Elf_Word version;
41
42 // Numer of input files in the link.
43 elfcpp::Elf_Word input_file_count;
44
45 // Offset of command line options in .gnu_incremental_strtab.
46 elfcpp::Elf_Word command_line_offset;
47
48 // Padding.
49 elfcpp::Elf_Word reserved;
50 };
51
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
55 {
56 // Offset of file name in .gnu_incremental_strtab section.
57 elfcpp::Elf_Word filename_offset;
58
59 // Offset of data in .gnu_incremental_input.
60 elfcpp::Elf_Word data_offset;
61
62 // Timestamp (in seconds).
63 elfcpp::Elf_Xword timestamp_sec;
64
65 // Nano-second part of timestamp (if supported).
66 elfcpp::Elf_Word timestamp_usec;
67
68 // Type of the input entry.
69 elfcpp::Elf_Half input_type;
70
71 // Padding.
72 elfcpp::Elf_Half reserved;
73 };
74
75 }
76
77 // Accessors.
78
79 // See internal::Incremental_input_header for fields descriptions.
80 template<int size, bool big_endian>
81 class Incremental_input_header_write
82 {
83 public:
84 Incremental_input_header_write(unsigned char *p)
85 : p_(reinterpret_cast<internal::Incremental_input_header_data>(p))
86 { }
87
88 void
89 put_version(elfcpp::Elf_Word v)
90 { this->p_->version = Convert<32, big_endian>::convert_host(v); }
91
92 void
93 input_file_count(elfcpp::Elf_Word v)
94 { this->p_->input_file_count = Convert<32, big_endian>::convert_host(v); }
95
96 void
97 command_line_offset(elfcpp::Elf_Word v)
98 { this->p_->command_line_offset = Convert<32, big_endian>::convert_host(v); }
99
100 void
101 reserved(elfcpp::Elf_Word v)
102 { this->p_->reserved = Convert<32, big_endian>::convert_host(v); }
103
104 private:
105 internal::Incremental_input_header_data* p_;
106 };
107
108 // See internal::Incremental_input_entry for fields descriptions.
109 template<int size, bool big_endian>
110 class Incremental_input_entry_write
111 {
112 public:
113 Incremental_input_entry_write(unsigned char *p)
114 : p_(reinterpret_cast<internal::Incremental_input_entry_data>(p))
115 { }
116
117 void
118 put_filename_offset(elfcpp::Elf_Word v)
119 { this->p_->filename_offset = Convert<32, big_endian>::convert_host(v); }
120
121 void
122 put_data_offset(elfcpp::Elf_Word v)
123 { this->p_->data_offset = Convert<32, big_endian>::convert_host(v); }
124
125 void
126 put_timestamp_sec(elfcpp::Elf_Word v)
127 { this->p_->timestamp_sec = Convert<32, big_endian>::convert_host(v); }
128
129 void
130 put_timestamp_usec(elfcpp::Elf_Word v)
131 { this->p_->timestamp_usec = Convert<32, big_endian>::convert_host(v); }
132
133 void
134 put_input_type(elfcpp::Elf_Word v)
135 { this->p_->input_type = Convert<32, big_endian>::convert_host(v); }
136
137 void
138 put_reserved(elfcpp::Elf_Word v)
139 { this->p_->reserved = Convert<32, big_endian>::convert_host(v); }
140
141 private:
142 internal::Incremental_input_entry_data* p_;
143 };
144
145 } // End namespace gold.