From 591be3e4a841ac56bb3ee094447b708d58a6d4b8 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 13 Dec 2016 13:01:13 -0800 Subject: 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. --- gold/script-sections.cc | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'gold/script-sections.cc') diff --git a/gold/script-sections.cc b/gold/script-sections.cc index 90ec8d4..ffd4666 100644 --- a/gold/script-sections.cc +++ b/gold/script-sections.cc @@ -3592,13 +3592,37 @@ Script_sections::output_section_name( } } - // If we couldn't find a mapping for the name, the output section - // gets the name of the input section. - + // We have an orphan section. *output_section_slot = NULL; *psection_type = Script_sections::ST_NONE; *keep = false; + General_options::Orphan_handling orphan_handling = + parameters->options().orphan_handling_enum(); + if (orphan_handling == General_options::ORPHAN_DISCARD) + return NULL; + if (orphan_handling == General_options::ORPHAN_ERROR) + { + if (file_name == NULL) + gold_error(_("unplaced orphan section '%s'"), section_name); + else + gold_error(_("unplaced orphan section '%s' from '%s'"), + section_name, file_name); + return NULL; + } + if (orphan_handling == General_options::ORPHAN_WARN) + { + if (file_name == NULL) + gold_warning(_("orphan section '%s' is being placed in section '%s'"), + section_name, section_name); + else + gold_warning(_("orphan section '%s' from '%s' is being placed " + "in section '%s'"), + section_name, file_name, section_name); + } + + // If we couldn't find a mapping for the name, the output section + // gets the name of the input section. return section_name; } -- cgit v1.1