Change default to discard temporary local symbols in merge sections.

Add --discard-none to keep all local symbols.

gold/
	PR gold/17498
	* object.cc (Sized_relobj_file::do_count_local_symbols): Discard
	temporary locals in merge sections.
	* options.cc (General_options::parse_discard_all): New method.
	(General_options::parse_discard_locals): New method.
	(General_options::parse_discard_none): New method.
	(General_options::General_options): Initialize discard_locals_.
	* options.h (--discard-all): Convert to special option.
	(--discard-locals): Likewise.
	(--discard-none): New option.
	(General_options::discard_all): New method.
	(General_options::discard_locals): New method.
	(General_options::discard_sec_merge): New method.
	(General_options::Discard_locals): New enum.
	(General_options::discard_locals_): New data member.
This commit is contained in:
Cary Coutant
2015-06-04 20:58:08 -07:00
parent dc302c0061
commit cd3c333f43
4 changed files with 81 additions and 6 deletions

View File

@@ -739,10 +739,12 @@ class General_options
N_("Look for violations of the C++ One Definition Rule"),
N_("Do not look for violations of the C++ One Definition Rule"));
DEFINE_bool(discard_all, options::TWO_DASHES, 'x', false,
N_("Delete all local symbols"), NULL);
DEFINE_bool(discard_locals, options::TWO_DASHES, 'X', false,
N_("Delete all temporary local symbols"), NULL);
DEFINE_special(discard_all, options::TWO_DASHES, 'x',
N_("Delete all local symbols"), NULL);
DEFINE_special(discard_locals, options::TWO_DASHES, 'X',
N_("Delete all temporary local symbols"), NULL);
DEFINE_special(discard_none, options::TWO_DASHES, '\0',
N_("Keep all local symbols"), NULL);
DEFINE_bool(dynamic_list_data, options::TWO_DASHES, '\0', false,
N_("Add data symbols to dynamic symbols"), NULL);
@@ -1526,11 +1528,36 @@ class General_options
endianness() const
{ return this->endianness_; }
bool
discard_all() const
{ return this->discard_locals_ == DISCARD_ALL; }
bool
discard_locals() const
{ return this->discard_locals_ == DISCARD_LOCALS; }
bool
discard_sec_merge() const
{ return this->discard_locals_ == DISCARD_SEC_MERGE; }
private:
// Don't copy this structure.
General_options(const General_options&);
General_options& operator=(const General_options&);
// What local symbols to discard.
enum Discard_locals
{
// Locals in merge sections (default).
DISCARD_SEC_MERGE,
// None (--discard-none).
DISCARD_NONE,
// Temporary locals (--discard-locals/-X).
DISCARD_LOCALS,
// All locals (--discard-all/-x).
DISCARD_ALL
};
// Whether to mark the stack as executable.
enum Execstack
{
@@ -1626,6 +1653,8 @@ class General_options
Fix_v4bx fix_v4bx_;
// Endianness.
Endianness endianness_;
// What local symbols to discard.
Discard_locals discard_locals_;
};
// The position-dependent options. We use this to store the state of