// plugin.cc -- plugin manager for gold -*- C++ -*-
-// Copyright (C) 2008-2016 Free Software Foundation, Inc.
+// Copyright (C) 2008-2017 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of gold.
uint64_t align,
const struct ld_plugin_section *section_list,
unsigned int num_sections);
+
+static enum ld_plugin_status
+get_input_section_alignment(const struct ld_plugin_section section,
+ unsigned int* addralign);
+
+static enum ld_plugin_status
+get_input_section_size(const struct ld_plugin_section section,
+ uint64_t* secsize);
+
};
#endif // ENABLE_PLUGINS
sscanf(ver, "%d.%d", &major, &minor);
// Allocate and populate a transfer vector.
- const int tv_fixed_size = 27;
+ const int tv_fixed_size = 29;
int tv_size = this->args_.size() + tv_fixed_size;
ld_plugin_tv* tv = new ld_plugin_tv[tv_size];
tv[i].tv_tag = LDPT_UNIQUE_SEGMENT_FOR_SECTIONS;
tv[i].tv_u.tv_unique_segment_for_sections = unique_segment_for_sections;
+ ++i;
+ tv[i].tv_tag = LDPT_GET_INPUT_SECTION_ALIGNMENT;
+ tv[i].tv_u.tv_get_input_section_alignment = get_input_section_alignment;
+
+ ++i;
+ tv[i].tv_tag = LDPT_GET_INPUT_SECTION_SIZE;
+ tv[i].tv_u.tv_get_input_section_size = get_input_section_size;
+
++i;
tv[i].tv_tag = LDPT_NULL;
tv[i].tv_u.tv_val = 0;
for (int i = 0; i < this->nsyms_; ++i)
{
const struct ld_plugin_symbol& sym = this->syms_[i];
+ if (sym.def == LDPK_UNDEF || sym.def == LDPK_WEAKUNDEF)
+ continue;
const char* name = sym.name;
Symbol* symbol;
Archive::Should_include t = Archive::should_include_member(symtab,
return LDPS_OK;
}
+// Get the alignment of the specified section in the object corresponding
+// to the handle. This plugin interface can only be called in the
+// claim_file handler of the plugin.
+
+static enum ld_plugin_status
+get_input_section_alignment(const struct ld_plugin_section section,
+ unsigned int* addralign)
+{
+ gold_assert(parameters->options().has_plugins());
+
+ if (!parameters->options().plugins()->in_claim_file_handler())
+ return LDPS_ERR;
+
+ Object* obj
+ = parameters->options().plugins()->get_elf_object(section.handle);
+
+ if (obj == NULL)
+ return LDPS_BAD_HANDLE;
+
+ *addralign = obj->section_addralign(section.shndx);
+ return LDPS_OK;
+}
+
+// Get the size of the specified section in the object corresponding
+// to the handle. This plugin interface can only be called in the
+// claim_file handler of the plugin.
+
+static enum ld_plugin_status
+get_input_section_size(const struct ld_plugin_section section,
+ uint64_t* secsize)
+{
+ gold_assert(parameters->options().has_plugins());
+
+ if (!parameters->options().plugins()->in_claim_file_handler())
+ return LDPS_ERR;
+
+ Object* obj
+ = parameters->options().plugins()->get_elf_object(section.handle);
+
+ if (obj == NULL)
+ return LDPS_BAD_HANDLE;
+
+ *secsize = obj->section_size(section.shndx);
+ return LDPS_OK;
+}
+
+
// Specify the ordering of sections in the final layout. The sections are
// specified as (handle,shndx) pairs in the two arrays in the order in
// which they should appear in the final layout.