diff options
author | Cary Coutant <ccoutant@gmail.com> | 2016-03-03 12:09:06 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2016-03-03 12:09:06 -0800 |
commit | 82838bd626b10f1a82b0de29728c26f4458ec514 (patch) | |
tree | 696a1f1565a3a667826b6b1c62bbf7e9449e67cb /gold/plugin.cc | |
parent | 95ecdfbfcbf508919652a0254ee2b8c6572a949e (diff) | |
download | gdb-82838bd626b10f1a82b0de29728c26f4458ec514.zip gdb-82838bd626b10f1a82b0de29728c26f4458ec514.tar.gz gdb-82838bd626b10f1a82b0de29728c26f4458ec514.tar.bz2 |
Add new plugin hooks to support querying section alignment and size.
include/
2016-03-03 Than McIntosh <thanm@google.com>
* plugin-api.h: Add new hooks to the plugin transfer vector to
to support querying section alignment and section size.
(ld_plugin_get_input_section_alignment): New hook.
(ld_plugin_get_input_section_size): New hook.
(ld_plugin_tag): Add LDPT_GET_INPUT_SECTION_ALIGNMENT
and LDPT_GET_INPUT_SECTION_SIZE.
(ld_plugin_tv): Add tv_get_input_section_alignment and
tv_get_input_section_size.
gold/
2016-03-03 Than McIntosh <thanm@google.com>
* plugin.cc (Plugin::load): Include hooks for get_input_section_size
and get_input_section_alignment in transfer vector.
(get_input_section_alignment): New function.
(get_input_section_size): New function.
* testsuite/Makefile.am: Add plugin_layout_with_alignment.sh test.
* testsuite/Makefile.in: [Regenerate.]
* testsuite/plugin_section_alignment.cc: New test file.
* testsuite/plugin_layout_with_alignment.cc: New test file.
* testsuite/plugin_layout_with_alignment.sh: New test file.
Diffstat (limited to 'gold/plugin.cc')
-rw-r--r-- | gold/plugin.cc | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/gold/plugin.cc b/gold/plugin.cc index 4aeb3ea..bb7d6b2 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -158,6 +158,15 @@ unique_segment_for_sections(const char* segment_name, 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 @@ -202,7 +211,7 @@ Plugin::load() 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]; @@ -329,6 +338,14 @@ Plugin::load() 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; @@ -1730,6 +1747,53 @@ get_input_section_contents(const struct ld_plugin_section section, 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. |