// plugin.cc -- plugin manager for gold -*- C++ -*-
-// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of gold.
#include "target.h"
#include "readsyms.h"
#include "symtab.h"
+#include "descriptors.h"
#include "elfcpp.h"
namespace gold
++obj)
delete *obj;
this->objects_.clear();
+ delete this->lock_;
}
// Load all plugin libraries.
Plugin_manager::claim_file(Input_file* input_file, off_t offset,
off_t filesize, Object* elf_object)
{
+ bool lock_initialized = this->initialize_lock_.initialize();
+
+ gold_assert(lock_initialized);
+ Hold_lock hl(*this->lock_);
if (this->in_replacement_phase_)
return NULL;
void
Plugin_manager::cleanup()
{
+ if (this->any_added_)
+ {
+ // If any input files were added, close all the input files.
+ // This is because the plugin may want to remove them, and on
+ // Windows you are not allowed to remove an open file.
+ close_all_descriptors();
+ }
+
for (this->current_ = this->plugins_.begin();
this->current_ != this->plugins_.end();
++this->current_)
// Get symbol resolution info.
ld_plugin_status
-Pluginobj::get_symbol_resolution_info(int nsyms,
+Pluginobj::get_symbol_resolution_info(Symbol_table* symtab,
+ int nsyms,
ld_plugin_symbol* syms,
int version) const
{
{
ld_plugin_symbol* isym = &syms[i];
Symbol* lsym = this->symbols_[i];
+ if (lsym->is_forwarder())
+ lsym = symtab->resolve_forwards(lsym);
ld_plugin_symbol_resolution res = LDPR_UNKNOWN;
if (lsym->is_undefined())
elfcpp::Sym<size, big_endian> sym(symbuf);
elfcpp::Sym_write<size, big_endian> osym(symbuf);
- typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type;
-
this->symbols_.resize(this->nsyms_);
for (int i = 0; i < this->nsyms_; ++i)
osym.put_st_name(0);
osym.put_st_value(0);
- osym.put_st_size(static_cast<Elf_size_type>(isym->size));
+ osym.put_st_size(0);
osym.put_st_info(bind, elfcpp::STT_NOTYPE);
osym.put_st_other(vis, 0);
osym.put_st_shndx(shndx);
template<int size, bool big_endian>
std::string
-Sized_pluginobj<size, big_endian>::do_section_name(unsigned int)
+Sized_pluginobj<size, big_endian>::do_section_name(unsigned int) const
{
gold_unreachable();
return std::string();
get_symbols(const void* handle, int nsyms, ld_plugin_symbol* syms)
{
gold_assert(parameters->options().has_plugins());
- Object* obj = parameters->options().plugins()->object(
+ Plugin_manager* plugins = parameters->options().plugins();
+ Object* obj = plugins->object(
static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
if (obj == NULL)
return LDPS_ERR;
Pluginobj* plugin_obj = obj->pluginobj();
if (plugin_obj == NULL)
return LDPS_ERR;
- return plugin_obj->get_symbol_resolution_info(nsyms, syms, 1);
+ Symbol_table* symtab = plugins->symtab();
+ return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 1);
}
// Version 2 of the above. The only difference is that this version
get_symbols_v2(const void* handle, int nsyms, ld_plugin_symbol* syms)
{
gold_assert(parameters->options().has_plugins());
- Object* obj = parameters->options().plugins()->object(
+ Plugin_manager* plugins = parameters->options().plugins();
+ Object* obj = plugins->object(
static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
if (obj == NULL)
return LDPS_ERR;
Pluginobj* plugin_obj = obj->pluginobj();
if (plugin_obj == NULL)
return LDPS_ERR;
- return plugin_obj->get_symbol_resolution_info(nsyms, syms, 2);
+ Symbol_table* symtab = plugins->symtab();
+ return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 2);
}
// Add a new (real) input file generated by a plugin.
{
Object* obj = parameters->options().plugins()->get_elf_object(
section_list[i].handle);
- if (obj == NULL)
+ if (obj == NULL || obj->is_dynamic())
return LDPS_BAD_HANDLE;
unsigned int shndx = section_list[i].shndx;
- Section_id secn_id(obj, shndx);
+ Section_id secn_id(static_cast<Relobj*>(obj), shndx);
(*order_map)[secn_id] = i + 1;
}
{
Object* obj = parameters->options().plugins()->get_elf_object(
section_list[i].handle);
- if (obj == NULL)
+ if (obj == NULL || obj->is_dynamic())
return LDPS_BAD_HANDLE;
unsigned int shndx = section_list[i].shndx;
- Const_section_id secn_id(obj, shndx);
+ Const_section_id secn_id(static_cast<Relobj*>(obj), shndx);
layout->insert_section_segment_map(secn_id, s);
}