summaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog10
-rw-r--r--gold/layout.cc5
-rw-r--r--gold/options.cc20
-rw-r--r--gold/options.h10
4 files changed, 42 insertions, 3 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index f3d37159362..5fa3b630801 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,13 @@
+2020-06-12 Roland McGrath <mcgrathr@google.com>
+
+ Implement -z start-stop-visibility=... option.
+ * options.h (class General_options): Handle -z start-stop-visibility=.
+ (General_options::start_stop_visibility): New public method.
+ (General_options::start_stop_visibility_): New private member.
+ * options.cc (General_options::General_options): Add initializer.
+ (General_options::parse_start_stop_visibility): New function.
+ * layout.cc (Layout::define_section_symbols): Use option setting.
+
2020-06-06 Alan Modra <amodra@gmail.com>
* powerpc.cc: Update throughout for reloc renaming.
diff --git a/gold/layout.cc b/gold/layout.cc
index be437f3900e..bb7fd497b42 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -2474,6 +2474,7 @@ Layout::create_initial_dynamic_sections(Symbol_table* symtab)
void
Layout::define_section_symbols(Symbol_table* symtab)
{
+ const elfcpp::STV visibility = parameters->options().start_stop_visibility();
for (Section_list::const_iterator p = this->section_list_.begin();
p != this->section_list_.end();
++p)
@@ -2495,7 +2496,7 @@ Layout::define_section_symbols(Symbol_table* symtab)
0, // symsize
elfcpp::STT_NOTYPE,
elfcpp::STB_GLOBAL,
- elfcpp::STV_PROTECTED,
+ visibility,
0, // nonvis
false, // offset_is_from_end
true); // only_if_ref
@@ -2508,7 +2509,7 @@ Layout::define_section_symbols(Symbol_table* symtab)
0, // symsize
elfcpp::STT_NOTYPE,
elfcpp::STB_GLOBAL,
- elfcpp::STV_PROTECTED,
+ visibility,
0, // nonvis
true, // offset_is_from_end
true); // only_if_ref
diff --git a/gold/options.cc b/gold/options.cc
index 94867b361a2..9936619685f 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -760,6 +760,23 @@ General_options::parse_pop_state(const char*, const char*, Command_line*)
delete posdep;
}
+void
+General_options::parse_start_stop_visibility(char const*, char const* arg,
+ Command_line*)
+{
+ if (strcmp(arg, "default") == 0)
+ this->start_stop_visibility_ = elfcpp::STV_DEFAULT;
+ else if (strcmp(arg, "internal") == 0)
+ this->start_stop_visibility_ = elfcpp::STV_INTERNAL;
+ else if (strcmp(arg, "hidden") == 0)
+ this->start_stop_visibility_ = elfcpp::STV_HIDDEN;
+ else if (strcmp(arg, "protected") == 0)
+ this->start_stop_visibility_ = elfcpp::STV_PROTECTED;
+ else
+ gold_fatal(_("-z start-stop-visibility: must take one of the following "
+ "arguments: default, internal, hidden, protected"));
+}
+
} // End namespace gold.
namespace
@@ -997,7 +1014,8 @@ General_options::General_options()
fix_v4bx_(FIX_V4BX_NONE),
endianness_(ENDIANNESS_NOT_SET),
discard_locals_(DISCARD_SEC_MERGE),
- orphan_handling_enum_(ORPHAN_PLACE)
+ orphan_handling_enum_(ORPHAN_PLACE),
+ start_stop_visibility_(elfcpp::STV_PROTECTED)
{
// Turn off option registration once construction is complete.
gold::options::ready_to_register = false;
diff --git a/gold/options.h b/gold/options.h
index b2059d984cd..ed050c3b026 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1500,6 +1500,10 @@ class General_options
N_("Don't mark variables read-only after relocation"));
DEFINE_uint64(stack_size, options::DASH_Z, '\0', 0,
N_("Set PT_GNU_STACK segment p_memsz to SIZE"), N_("SIZE"));
+ DEFINE_special(start_stop_visibility, options::DASH_Z, '\0',
+ N_("ELF symbol visibility for synthesized "
+ "__start_* and __stop_* symbols"),
+ N_("[default,internal,hidden,protected]"));
DEFINE_bool(text, options::DASH_Z, '\0', false,
N_("Do not permit relocations in read-only segments"),
N_("Permit relocations in read-only segments"));
@@ -1750,6 +1754,10 @@ class General_options
orphan_handling_enum() const
{ return this->orphan_handling_enum_; }
+ elfcpp::STV
+ start_stop_visibility() const
+ { return this->start_stop_visibility_; }
+
private:
// Don't copy this structure.
General_options(const General_options&);
@@ -1876,6 +1884,8 @@ class General_options
std::vector<Position_dependent_options*> options_stack_;
// Orphan handling option, decoded to an enum value.
Orphan_handling orphan_handling_enum_;
+ // Symbol visibility for __start_* / __stop_* magic symbols.
+ elfcpp::STV start_stop_visibility_;
};
// The position-dependent options. We use this to store the state of