aboutsummaryrefslogtreecommitdiff
path: root/gold/script-sections.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2016-12-13 13:01:13 -0800
committerCary Coutant <ccoutant@gmail.com>2016-12-13 13:01:26 -0800
commit591be3e4a841ac56bb3ee094447b708d58a6d4b8 (patch)
tree9ef4c58b0530d20a799cb095554656a2cad35c6a /gold/script-sections.cc
parent03fb64f837bd8466ba6e7b7cb8880f5c6c87daab (diff)
downloadgdb-591be3e4a841ac56bb3ee094447b708d58a6d4b8.zip
gdb-591be3e4a841ac56bb3ee094447b708d58a6d4b8.tar.gz
gdb-591be3e4a841ac56bb3ee094447b708d58a6d4b8.tar.bz2
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.
Diffstat (limited to 'gold/script-sections.cc')
-rw-r--r--gold/script-sections.cc30
1 files changed, 27 insertions, 3 deletions
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;
}