summaryrefslogtreecommitdiff
path: root/gold/script-sections.cc
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2012-08-14 08:31:57 +0000
committerNick Clifton <nickc@redhat.com>2012-08-14 08:31:57 +0000
commitb9b2ae8bbf911b7762fe41ecbb5dbc64a8e2b5a7 (patch)
tree53b5d6d4c8f3c498a9c9ebfb42d572a2553bfd4f /gold/script-sections.cc
parent921b53228fa18e00beca6b19b3aa43c23903b900 (diff)
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.
Diffstat (limited to 'gold/script-sections.cc')
-rw-r--r--gold/script-sections.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/gold/script-sections.cc b/gold/script-sections.cc
index f90c0b3752..e5d3a93b2a 100644
--- a/gold/script-sections.cc
+++ b/gold/script-sections.cc
@@ -582,7 +582,7 @@ class Sections_element
// Output_section_definition.
virtual const char*
output_section_name(const char*, const char*, Output_section***,
- Script_sections::Section_type*)
+ Script_sections::Section_type*, bool*)
{ return NULL; }
// Initialize OSP with an output section.
@@ -800,7 +800,7 @@ class Output_section_element
// Return whether this element matches FILE_NAME and SECTION_NAME.
// The only real implementation is in Output_section_element_input.
virtual bool
- match_name(const char*, const char*) const
+ match_name(const char*, const char*, bool *) const
{ return false; }
// Set section addresses. This includes applying assignments if the
@@ -1238,10 +1238,10 @@ class Output_section_element_input : public Output_section_element
*dot_section = this->final_dot_section_;
}
- // See whether we match FILE_NAME and SECTION_NAME as an input
- // section.
+ // See whether we match FILE_NAME and SECTION_NAME as an input section.
+ // If we do then also indicate whether the section should be KEPT.
bool
- match_name(const char* file_name, const char* section_name) const;
+ match_name(const char* file_name, const char* section_name, bool* keep) const;
// Set the section address.
void
@@ -1393,15 +1393,19 @@ Output_section_element_input::match_file_name(const char* file_name) const
return true;
}
-// See whether we match FILE_NAME and SECTION_NAME.
+// See whether we match FILE_NAME and SECTION_NAME. If we do then
+// KEEP indicates whether the section should survive garbage collection.
bool
Output_section_element_input::match_name(const char* file_name,
- const char* section_name) const
+ const char* section_name,
+ bool *keep) const
{
if (!this->match_file_name(file_name))
return false;
+ *keep = this->keep_;
+
// If there are no section name patterns, then we match.
if (this->input_section_patterns_.empty())
return true;
@@ -1861,7 +1865,8 @@ class Output_section_definition : public Sections_element
// section name.
const char*
output_section_name(const char* file_name, const char* section_name,
- Output_section***, Script_sections::Section_type*);
+ Output_section***, Script_sections::Section_type*,
+ bool*);
// Initialize OSP with an output section.
void
@@ -2146,14 +2151,15 @@ Output_section_definition::output_section_name(
const char* file_name,
const char* section_name,
Output_section*** slot,
- Script_sections::Section_type* psection_type)
+ Script_sections::Section_type* psection_type,
+ bool* keep)
{
// Ask each element whether it matches NAME.
for (Output_section_elements::const_iterator p = this->elements_.begin();
p != this->elements_.end();
++p)
{
- if ((*p)->match_name(file_name, section_name))
+ if ((*p)->match_name(file_name, section_name, keep))
{
// We found a match for NAME, which means that it should go
// into this output section.
@@ -3365,7 +3371,8 @@ Script_sections::output_section_name(
const char* file_name,
const char* section_name,
Output_section*** output_section_slot,
- Script_sections::Section_type* psection_type)
+ Script_sections::Section_type* psection_type,
+ bool* keep)
{
for (Sections_elements::const_iterator p = this->sections_elements_->begin();
p != this->sections_elements_->end();
@@ -3373,7 +3380,7 @@ Script_sections::output_section_name(
{
const char* ret = (*p)->output_section_name(file_name, section_name,
output_section_slot,
- psection_type);
+ psection_type, keep);
if (ret != NULL)
{