summaryrefslogtreecommitdiff
path: root/gold/plugin.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2009-01-15 01:29:25 +0000
committerCary Coutant <ccoutant@google.com>2009-01-15 01:29:25 +0000
commit0f7c0701ba26bd4c94e968f6be5c954819c97f81 (patch)
tree3ffcaaf955c71edad7e9d7b1965894a3e5e3d722 /gold/plugin.h
parentfa7f3e72292434483fbce576f8613a1af727df6c (diff)
downloadbinutils-gdb-0f7c0701ba26bd4c94e968f6be5c954819c97f81.tar.gz
* archive.cc (Archive::get_elf_object_for_member): Remove call
to File_read::claim_for_plugin. * descriptors.cc (Descriptors::open): Remove reference to is_claimed. (Descriptors::claim_for_plugin): Remove. * descriptors.h (Descriptors::claim_for_plugin): Remove. (Descriptors::is_claimed): Remove. (claim_descriptor_for_plugin): Remove. * fileread.cc (File_read::claim_for_plugin): Remove. * fileread.h (File_read::claim_for_plugin): Remove. (File_read::descriptor): Reopen descriptor if necessary. * plugin.cc (Plugin::load): Add two new APIs to transfer vector. (Plugin_manager::all_symbols_read): Add task parameter. Change all callers. (Plugin_manager::get_input_file): New function. (Plugin_manager::release_input_file): New function. (Pluginobj::Pluginobj): Add filesize parameter and initialize corresponding data member. (Sized_pluginobj::Sized_pluginobj): Add filesize parameter and pass to base constructor. Change all callers. (get_input_file, release_input_file): New functions. (make_sized_plugin_object): Add filesize parameter. Change all callers. * plugin.h (Plugin_manager::Plugin_manager): Initialize task_ member. (Plugin_manager::all_symbols_read): Add task parameter. (Plugin_manager::get_input_file): New function. (Plugin_manager::release_input_file): New function. (Plugin_manager::task_): New data member. (Pluginobj::Pluginobj): Add filesize parameter. (Pluginobj::filename): New function. (Pluginobj::descriptor): New function. (Pluginobj::filesize): New function. (Pluginobj::filesize_): New data member. (Sized_pluginobj::Sized_pluginobj): Add filesize parameter. * readsyms.cc (Read_symbols::do_read_symbols): Remove call to File_read::claim_for_plugin; use Object::unlock to unlock the file. * testsuite/Makefile.am (plugin_test_4): New test case for plugins with archive libraries. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c (struct sym_info): New type. (get_input_file, release_input_file): New static variables. (onload): Capture new transfer vector entries. (claim_file_hook): Stop reading at end of file according to filesize. Factor out parsing of readelf output into separate function. (all_symbols_read_hook): Exercise get_input_file and release_input_file APIs and get the source file name from the symbol table. Convert source file name to corresponding object file name. Print info message when adding new input files. (parse_readelf_line): New function. * testsuite/plugin_test_1.sh: Add checks for new info messages. * testsuite/plugin_test_2.sh: Likewise. * testsuite/plugin_test_3.sh: Likewise. * testsuite/plugin_test_4.sh: New test case.
Diffstat (limited to 'gold/plugin.h')
-rw-r--r--gold/plugin.h46
1 files changed, 38 insertions, 8 deletions
diff --git a/gold/plugin.h b/gold/plugin.h
index 2ea0370878c..a8d3dc4db15 100644
--- a/gold/plugin.h
+++ b/gold/plugin.h
@@ -1,6 +1,6 @@
// plugin.h -- plugin manager for gold -*- C++ -*-
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008, 2009 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of gold.
@@ -122,8 +122,9 @@ class Plugin_manager
Plugin_manager(const General_options& options)
: plugins_(), objects_(), deferred_layout_objects_(), input_file_(NULL),
plugin_input_file_(), in_replacement_phase_(false), cleanup_done_(false),
- options_(options), workqueue_(NULL), input_objects_(NULL), symtab_(NULL),
- layout_(NULL), dirpath_(NULL), mapfile_(NULL), this_blocker_(NULL)
+ options_(options), workqueue_(NULL), task_(NULL), input_objects_(NULL),
+ symtab_(NULL), layout_(NULL), dirpath_(NULL), mapfile_(NULL),
+ this_blocker_(NULL)
{ this->current_ = plugins_.end(); }
~Plugin_manager();
@@ -151,9 +152,10 @@ class Plugin_manager
// Call the all-symbols-read handlers.
void
- all_symbols_read(Workqueue* workqueue, Input_objects* input_objects,
- Symbol_table* symtab, Layout* layout, Dirsearch* dirpath,
- Mapfile* mapfile, Task_token** last_blocker);
+ all_symbols_read(Workqueue* workqueue, Task* task,
+ Input_objects* input_objects, Symbol_table* symtab,
+ Layout* layout, Dirsearch* dirpath, Mapfile* mapfile,
+ Task_token** last_blocker);
// Run deferred layout.
void
@@ -214,6 +216,15 @@ class Plugin_manager
add_deferred_layout_object(Relobj* obj)
{ this->deferred_layout_objects_.push_back(obj); }
+ // Get input file information with an open (possibly re-opened)
+ // file descriptor.
+ ld_plugin_status
+ get_input_file(unsigned int handle, struct ld_plugin_input_file *file);
+
+ // Release an input file.
+ ld_plugin_status
+ release_input_file(unsigned int handle);
+
// Add a new input file.
ld_plugin_status
add_input_file(char *pathname);
@@ -257,6 +268,7 @@ class Plugin_manager
const General_options& options_;
Workqueue* workqueue_;
+ Task* task_;
Input_objects* input_objects_;
Symbol_table* symtab_;
Layout* layout_;
@@ -275,7 +287,8 @@ class Pluginobj : public Object
typedef std::vector<Symbol*> Symbols;
- Pluginobj(const std::string& name, Input_file* input_file, off_t offset);
+ Pluginobj(const std::string& name, Input_file* input_file, off_t offset,
+ off_t filesize);
// Fill in the symbol resolution status for the given plugin symbols.
ld_plugin_status
@@ -299,6 +312,21 @@ class Pluginobj : public Object
bool
include_comdat_group(std::string comdat_key, Layout* layout);
+ // Return the filename.
+ const std::string&
+ filename() const
+ { return this->input_file()->filename(); }
+
+ // Return the file descriptor.
+ int
+ descriptor()
+ { return this->input_file()->file().descriptor(); }
+
+ // Return the size of the file or archive member.
+ off_t
+ filesize()
+ { return this->filesize_; }
+
protected:
// Return TRUE if this is an object claimed by a plugin.
virtual Pluginobj*
@@ -320,6 +348,8 @@ class Pluginobj : public Object
Symbols symbols_;
private:
+ // Size of the file (or archive member).
+ off_t filesize_;
// Map a comdat key symbol to a boolean indicating whether the comdat
// group in this object with that key should be kept.
typedef Unordered_map<std::string, bool> Comdat_map;
@@ -333,7 +363,7 @@ class Sized_pluginobj : public Pluginobj
{
public:
Sized_pluginobj(const std::string& name, Input_file* input_file,
- off_t offset);
+ off_t offset, off_t filesize);
// Read the symbols.
void