2011-09-29 Sriraman Tallam <tmsriram@google.com>

* layout.h (section_order_map_): New member.
	(get_section_order_map): New member function.
	* output.cc (Output_section::add_input_section): Check for patterns
	only when --section-ordering-file is specified.
	* gold.cc (queue_middle_tasks): Delay updating order of sections till
	output_sections have been formed.
	* layout.cc (Layout_Layout): Initialize section_order_map_.
	* plugin.cc (update_section_order): Store order in order_map. Do not
	update the order.
	* testsuite/Makefile.am: Add test case for plugin_final_layout.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_section_order.c: New file.
	* testsuite/plugin_final_layout.cc: New file.
	* testsuite/plugin_final_layout.sh: New file.
This commit is contained in:
Sriraman Tallam
2011-09-29 23:45:57 +00:00
parent a7dac15368
commit f0558624db
12 changed files with 355 additions and 18 deletions

View File

@@ -1630,7 +1630,7 @@ get_input_section_contents(const struct ld_plugin_section section,
// which they should appear in the final layout.
static enum ld_plugin_status
update_section_order(const struct ld_plugin_section *section_list,
update_section_order(const struct ld_plugin_section* section_list,
unsigned int num_sections)
{
gold_assert(parameters->options().has_plugins());
@@ -1641,8 +1641,14 @@ update_section_order(const struct ld_plugin_section *section_list,
if (section_list == NULL)
return LDPS_ERR;
std::map<Section_id, unsigned int> order_map;
Layout* layout = parameters->options().plugins()->layout();
gold_assert (layout != NULL);
std::map<Section_id, unsigned int>* order_map
= layout->get_section_order_map();
/* Store the mapping from Section_id to section position in layout's
order_map to consult after output sections are added. */
for (unsigned int i = 0; i < num_sections; ++i)
{
Object* obj = parameters->options().plugins()->get_elf_object(
@@ -1651,17 +1657,9 @@ update_section_order(const struct ld_plugin_section *section_list,
return LDPS_BAD_HANDLE;
unsigned int shndx = section_list[i].shndx;
Section_id secn_id(obj, shndx);
order_map[secn_id] = i + 1;
(*order_map)[secn_id] = i + 1;
}
Layout* layout = parameters->options().plugins()->layout();
gold_assert (layout != NULL);
for (Layout::Section_list::const_iterator p = layout->section_list().begin();
p != layout->section_list().end();
++p)
(*p)->update_section_layout(order_map);
return LDPS_OK;
}