* fileread.h (Timespec): New structure.
(File_read::get_mtime): New method.
* incremental.cc (Incremental_inputs_entry_data::timestamp_usec):
Renamed from timestamp_nsec.
(Incremental_inputs_entry_write::timestamp_sec): Fix argument to
Elf_Xword.
(Incremental_inputs_entry_write::timestamp_usec): Renamed from
timestamp_nsec.
(Incremental_inputs::report_archive): Save mtime; style fix.
(Incremental_inputs::report_obejct): Save mtime; style fix.
(Incremental_inputs::report_script): Save mtime; style fix.
(Incremental_inputs::finalize_inputs): Style fix.
(Incremental_inputs::finalize): Style fix.
(Incremental_inputs::create_input_section_data): Store inputs
mtime.
* incremental.h (Incremental_inputs::report_script): Add mtime
argument.
(Incremental_inputs::Input_info::Input_info): Intialize only one
union member.
(Incremental_inputs::Input_info::archive): Move to nameless
union.
(Incremental_inputs::Input_info::obejct): Move to nameless union.
(Incremental_inputs::Input_info::script): Move to nameless union.
(Incremental_inputs::mtime): New field.
* script.cc (read_input_script): Pass file mtime to
Incremental_input.
* script.h (Script_info::inputs): Style fix.
+2009-07-06 Mikolaj Zalewski <mikolajz@google.com>
+
+ * fileread.cc (File_read::get_mtime): New method.
+ * fileread.h (Timespec): New structure.
+ (File_read::get_mtime): New method.
+ * incremental.cc (Incremental_inputs_entry_data::timestamp_usec):
+ Renamed from timestamp_nsec.
+ (Incremental_inputs_entry_write::timestamp_sec): Fix argument to
+ Elf_Xword.
+ (Incremental_inputs_entry_write::timestamp_usec): Renamed from
+ timestamp_nsec.
+ (Incremental_inputs::report_archive): Save mtime; style fix.
+ (Incremental_inputs::report_obejct): Save mtime; style fix.
+ (Incremental_inputs::report_script): Save mtime; style fix.
+ (Incremental_inputs::finalize_inputs): Style fix.
+ (Incremental_inputs::finalize): Style fix.
+ (Incremental_inputs::create_input_section_data): Store inputs
+ mtime.
+ * incremental.h (Incremental_inputs::report_script): Add mtime
+ argument.
+ (Incremental_inputs::Input_info::Input_info): Intialize only one
+ union member.
+ (Incremental_inputs::Input_info::archive): Move to nameless
+ union.
+ (Incremental_inputs::Input_info::obejct): Move to nameless union.
+ (Incremental_inputs::Input_info::script): Move to nameless union.
+ (Incremental_inputs::mtime): New field.
+ * script.cc (read_input_script): Pass file mtime to
+ Incremental_input.
+ * script.h (Script_info::inputs): Style fix.
+
2009-07-01 Ian Lance Taylor <ian@airs.com>
* freebsd.h (Target_freebsd::do_adjust_elf_header): Use size
|| this->input_argument_->extra_search_path() != NULL));
}
+// Return the file last modification time. Calls gold_fatal if the stat
+// system call failed.
+
+Timespec
+File_read::get_mtime()
+{
+ struct stat file_stat;
+ this->reopen_descriptor();
+
+ if (fstat(this->descriptor_, &file_stat) < 0)
+ gold_fatal(_("%s: stat failed: %s"), this->name_.c_str(),
+ strerror(errno));
+ // TODO: do a configure check if st_mtim is present and get the
+ // nanoseconds part if it is.
+ return Timespec(file_stat.st_mtime, 0);
+}
+
// Open the file.
// If the filename is not absolute, we assume it is in the current
namespace gold
{
+// Since not all system supports stat.st_mtim and struct timespec,
+// we define our own structure and fill the nanoseconds if we can.
+
+struct Timespec
+{
+ Timespec()
+ : seconds(0), nanoseconds(0)
+ { }
+
+ Timespec(time_t a_seconds, int a_nanoseconds)
+ : seconds(a_seconds), nanoseconds(a_nanoseconds)
+ { }
+
+ time_t seconds;
+ int nanoseconds;
+};
+
class Position_dependent_options;
class Input_file_argument;
class Dirsearch;
this->reopen_descriptor();
return this->descriptor_;
}
+
+ // Return the file last modification time. Calls gold_fatal if the stat
+ // system call failed.
+ Timespec
+ get_mtime();
private:
// This class may not be copied.
#include "elfcpp.h"
#include "output.h"
#include "incremental.h"
+#include "archive.h"
using elfcpp::Convert;
elfcpp::Elf_Xword timestamp_sec;
// Nano-second part of timestamp (if supported).
- elfcpp::Elf_Word timestamp_usec;
+ elfcpp::Elf_Word timestamp_nsec;
// Type of the input entry.
elfcpp::Elf_Half input_type;
{ this->p_->data_offset = Convert<32, big_endian>::convert_host(v); }
void
- put_timestamp_sec(elfcpp::Elf_Word v)
- { this->p_->timestamp_sec = Convert<32, big_endian>::convert_host(v); }
+ put_timestamp_sec(elfcpp::Elf_Xword v)
+ { this->p_->timestamp_sec = Convert<64, big_endian>::convert_host(v); }
void
- put_timestamp_usec(elfcpp::Elf_Word v)
- { this->p_->timestamp_usec = Convert<32, big_endian>::convert_host(v); }
+ put_timestamp_nsec(elfcpp::Elf_Word v)
+ { this->p_->timestamp_nsec = Convert<32, big_endian>::convert_host(v); }
void
put_input_type(elfcpp::Elf_Word v)
Input_info info;
info.type = INCREMENTAL_INPUT_ARCHIVE;
info.archive = archive;
- inputs_map_.insert(std::make_pair(input, info));
+ info.mtime = archive->file().get_mtime();
+ this->inputs_map_.insert(std::make_pair(input, info));
}
// Record that the input argument INPUT is an object OBJ. This is
? INCREMENTAL_INPUT_SHARED_LIBRARY
: INCREMENTAL_INPUT_OBJECT);
info.object = obj;
- inputs_map_.insert(std::make_pair(input, info));
+ info.mtime = obj->input_file()->file().get_mtime();
+ this->inputs_map_.insert(std::make_pair(input, info));
}
// Record that the input argument INPUT is an script SCRIPT. This is
void
Incremental_inputs::report_script(const Input_argument* input,
+ Timespec mtime,
Script_info* script)
{
Hold_lock hl(*this->lock_);
Input_info info;
info.type = INCREMENTAL_INPUT_SCRIPT;
info.script = script;
- inputs_map_.insert(std::make_pair(input, info));
+ info.mtime = mtime;
+ this->inputs_map_.insert(std::make_pair(input, info));
}
// Compute indexes in the order in which the inputs should appear in
continue;
}
- Inputs_info_map::iterator it = inputs_map_.find(&(*p));
+ Inputs_info_map::iterator it = this->inputs_map_.find(&(*p));
// TODO: turn it into an assert when the code will be more stable.
- if (it == inputs_map_.end())
+ if (it == this->inputs_map_.end())
{
gold_error("internal error: %s: incremental build info not provided",
(p->is_file() ? p->file().name() : "[group]"));
finalize_inputs(this->inputs_->begin(), this->inputs_->end(), &index);
// Sanity check.
- for (Inputs_info_map::const_iterator p = inputs_map_.begin();
- p != inputs_map_.end();
+ for (Inputs_info_map::const_iterator p = this->inputs_map_.begin();
+ p != this->inputs_map_.end();
++p)
{
gold_assert(p->second.filename_key != 0);
// an out-of-bounds offset for future version of gold to reject
// such an incremental_inputs section.
entry.put_data_offset(0xffffffff);
- entry.put_timestamp_sec(0);
- entry.put_timestamp_usec(0);
+ entry.put_timestamp_sec(it->second.mtime.seconds);
+ entry.put_timestamp_nsec(it->second.mtime.nanoseconds);
entry.put_input_type(it->second.type);
entry.put_reserved(0);
}
#include "stringpool.h"
#include "workqueue.h"
+#include "fileread.h"
namespace gold
{
// Record that the input argument INPUT is to an script SCRIPT.
void
- report_script(const Input_argument* input, Script_info* script);
+ report_script(const Input_argument* input, Timespec mtime,
+ Script_info* script);
// Prepare for layout. Called from Layout::finalize.
void
struct Input_info
{
Input_info()
- : type(INCREMENTAL_INPUT_INVALID), archive(NULL), object(NULL),
- script(NULL), filename_key(0), index(0)
+ : type(INCREMENTAL_INPUT_INVALID), archive(NULL), filename_key(0),
+ index(0)
{ }
// Type of the file pointed by this argument.
Incremental_input_type type;
- // Present if type == INCREMENTAL_INPUT_ARCHIVE.
- Archive* archive;
-
- // Present if type == INCREMENTAL_INPUT_OBJECT or
- // INCREMENTAL_INPUT_SHARED_LIBRARY.
- Object* object;
-
- // Present if type == INCREMENTAL_INPUT_SCRIPT.
- Script_info* script;
+ union
+ {
+ // Present if type == INCREMENTAL_INPUT_ARCHIVE.
+ Archive* archive;
+
+ // Present if type == INCREMENTAL_INPUT_OBJECT or
+ // INCREMENTAL_INPUT_SHARED_LIBRARY.
+ Object* object;
+
+ // Present if type == INCREMENTAL_INPUT_SCRIPT.
+ Script_info* script;
+ };
// Key of the filename string in the section stringtable.
Stringpool::Key filename_key;
// Position of the entry information in the output section.
unsigned int index;
+
+ // Last modification time of the file.
+ Timespec mtime;
};
typedef std::map<const Input_argument*, Input_info> Inputs_info_map;
// Like new Read_symbols(...) above, we rely on close.inputs()
// getting leaked by closure.
Script_info* info = new Script_info(closure.inputs());
- layout->incremental_inputs()->report_script(input_argument, info);
+ layout->incremental_inputs()->report_script(
+ input_argument,
+ input_file->file().get_mtime(),
+ info);
}
*used_next_blocker = true;
// Returns the input files included because of this script.
Input_arguments*
inputs()
- { return inputs_; }
+ { return this->inputs_; }
private:
Input_arguments* inputs_;