New option -z,keep-text-section prefix.

This option does not merge certain text sections with prefixes
.text.hot, .text.unlikely, .text.startup and .text.exit.

	* layout.cc (Layout::default_section_order): Check for text section
	prefixes.
	(Layout::text_section_name_mapping): New static member.
	(Layout::text_section_name_mapping_count): New static member.
	(Layout::match_section_name): New static function.
	(Layout::output_section_name): Check for text section prefixes.
	* layout.h (Output_section_order::ORDER_TEXT_HOT): New enum value.
	(Output_section_order::ORDER_TEXT_STARTUP): New enum value.
	(Output_section_order::ORDER_TEXT_EXIT): New enum value.
	(Output_section_order::ORDER_TEXT_UNLIKELY): New enum value.
	(Layout::text_section_name_mapping): New static member.
	(Layout::text_section_name_mapping_count): New static member.
	(Layout::match_section_name): New static function.
	* options.h (keep_text_section_prefix): New -z option.
	* testsuite/Makefile.am (keep_text_section_prefix): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/keep_text_section_prefix.cc: New test source.
	* testsuite/keep_text_section_prefix.sh: New test script.
This commit is contained in:
Sriraman Tallam
2018-03-07 12:15:49 -08:00
parent ea005f31ca
commit 779bdadbea
8 changed files with 272 additions and 18 deletions

View File

@@ -422,9 +422,21 @@ enum Output_section_order
// The PLT.
ORDER_PLT,
// The hot text sections, prefixed by .text.hot.
ORDER_TEXT_HOT,
// The regular text sections.
ORDER_TEXT,
// The startup text sections, prefixed by .text.startup.
ORDER_TEXT_STARTUP,
// The startup text sections, prefixed by .text.startup.
ORDER_TEXT_EXIT,
// The unlikely text sections, prefixed by .text.unlikely.
ORDER_TEXT_UNLIKELY,
// The .fini section.
ORDER_FINI,
@@ -1015,6 +1027,14 @@ class Layout
};
static const Section_name_mapping section_name_mapping[];
static const int section_name_mapping_count;
static const Section_name_mapping text_section_name_mapping[];
static const int text_section_name_mapping_count;
// Find section name NAME in map and return the mapped name if found
// with the length set in PLEN.
static const char* match_section_name(const Section_name_mapping* map,
const int count, const char* name,
size_t* plen);
// During a relocatable link, a list of group sections and
// signatures.