forked from Imagelibrary/binutils-gdb
PR ld/14265
* script-sections.cc (Sections_element::output_section_name): Add keep return parameter. (Output_section_element::match_name): Add keep return parameter. Return the value of the keep_ member. * script-sections.h (class Output_section): Update output_section_name prototype. * layout.cc (Layout::keep_input_section): New public member function. (Layout::choose_output_section): Pass keep parameter to output_section_name. * layout.h (class Layout): Add keep_input_section. * object.cc (Sized_relobj_file::do_layout): Check for kept input sections. * testsuite/Makefile.am: Add a test. * testsuite/Makefile.in: Regenerate. * testsuite/pr14265.c: Source file for the test. * testsuite/pr14265.t: Linker script for the test. * testsuite/pr14265.sh: Shell script for the test. * ld-gc/gc.exp: Add a new test. * ld-gc/pr14265.c: Source file for the new test. * ld-gc/pr14265.t: Linker script for the new test. * ld-gc/pr14265.d: Expected symbol dump.
This commit is contained in:
@@ -805,6 +805,26 @@ Layout::get_output_section(const char* name, Stringpool::Key name_key,
|
||||
}
|
||||
}
|
||||
|
||||
// Returns TRUE iff NAME (an input section from RELOBJ) will
|
||||
// be mapped to an output section that should be KEPT.
|
||||
|
||||
bool
|
||||
Layout::keep_input_section(const Relobj* relobj, const char* name)
|
||||
{
|
||||
if (! this->script_options_->saw_sections_clause())
|
||||
return false;
|
||||
|
||||
Script_sections* ss = this->script_options_->script_sections();
|
||||
const char* file_name = relobj == NULL ? NULL : relobj->name().c_str();
|
||||
Output_section** output_section_slot;
|
||||
Script_sections::Section_type script_section_type;
|
||||
bool keep;
|
||||
|
||||
name = ss->output_section_name(file_name, name, &output_section_slot,
|
||||
&script_section_type, &keep);
|
||||
return name != NULL && keep;
|
||||
}
|
||||
|
||||
// Pick the output section to use for section NAME, in input file
|
||||
// RELOBJ, with type TYPE and flags FLAGS. RELOBJ may be NULL for a
|
||||
// linker created section. IS_INPUT_SECTION is true if we are
|
||||
@@ -845,8 +865,10 @@ Layout::choose_output_section(const Relobj* relobj, const char* name,
|
||||
Output_section** output_section_slot;
|
||||
Script_sections::Section_type script_section_type;
|
||||
const char* orig_name = name;
|
||||
bool keep;
|
||||
name = ss->output_section_name(file_name, name, &output_section_slot,
|
||||
&script_section_type);
|
||||
&script_section_type, &keep);
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
gold_debug(DEBUG_SCRIPT, _("Unable to create output section '%s' "
|
||||
|
||||
Reference in New Issue
Block a user