Add --orphan-handling option.

gold/
	PR gold/20749
	* options.h (--orphan-handling): New option.
	(General_options::Orphan_handling): New enum.
	(General_options::orphan_handling_enum): New method.
	(General_options::set_orphan_handling_enum): New method.
	(General_options::orphan_handling_enum_): New data member.
	* options.cc (General_options::General_options): Initialize new member.
	(General_options::finalize): Convert --orphan-handling argument to enum.
	* script-sections.cc (Script_sections::output_section_name): Check it.
This commit is contained in:
Cary Coutant
2016-12-13 13:01:13 -08:00
parent 03fb64f837
commit 591be3e4a8
4 changed files with 80 additions and 4 deletions

View File

@@ -998,7 +998,8 @@ General_options::General_options()
section_starts_(),
fix_v4bx_(FIX_V4BX_NONE),
endianness_(ENDIANNESS_NOT_SET),
discard_locals_(DISCARD_SEC_MERGE)
discard_locals_(DISCARD_SEC_MERGE),
orphan_handling_enum_(ORPHAN_PLACE)
{
// Turn off option registration once construction is complete.
gold::options::ready_to_register = false;
@@ -1157,6 +1158,19 @@ General_options::finalize()
this->set_do_demangle(getenv("COLLECT_NO_DEMANGLE") == NULL);
}
// Parse the --orphan-handling argument.
if (this->user_set_orphan_handling())
{
if (strcmp(this->orphan_handling(), "place") == 0)
this->set_orphan_handling_enum(ORPHAN_PLACE);
else if (strcmp(this->orphan_handling(), "discard") == 0)
this->set_orphan_handling_enum(ORPHAN_DISCARD);
else if (strcmp(this->orphan_handling(), "warn") == 0)
this->set_orphan_handling_enum(ORPHAN_WARN);
else if (strcmp(this->orphan_handling(), "error") == 0)
this->set_orphan_handling_enum(ORPHAN_ERROR);
}
// -M is equivalent to "-Map -".
if (this->print_map() && !this->user_set_Map())
{