diff options
author | Cary Coutant <ccoutant@gmail.com> | 2016-12-01 16:32:38 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2016-12-01 16:33:08 -0800 |
commit | 376c3ecd17d0636bcf4e527c2e2ca2f94822fe64 (patch) | |
tree | 972697333f871a499fd72fa29308d36aa3ca31b1 /gold/options.cc | |
parent | Automatic date update in version.in (diff) | |
download | binutils-gdb-376c3ecd17d0636bcf4e527c2e2ca2f94822fe64.tar.gz binutils-gdb-376c3ecd17d0636bcf4e527c2e2ca2f94822fe64.tar.bz2 binutils-gdb-376c3ecd17d0636bcf4e527c2e2ca2f94822fe64.zip |
Implement --push-state/--pop-state.
gold/
PR gold/18989
* options.cc (General_options::object_format_to_string): New function.
(General_options::copy_from_posdep_options): New function.
(General_options::parse_push_state): New function.
(General_options::parse_pop_state): New function.
* options.h (--push-state, --pop-state): New options.
(General_options::object_format_to_string): New method.
(General_options::set_incremental_disposition): New method.
(General_options::copy_from_posdep_options): New method.
(General_options::options_stack_): New data member.
Diffstat (limited to 'gold/options.cc')
-rw-r--r-- | gold/options.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gold/options.cc b/gold/options.cc index 73a3f67990c..276be39e470 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -689,6 +689,20 @@ General_options::string_to_object_format(const char* arg) } } +const char* +General_options::object_format_to_string(General_options::Object_format fmt) +{ + switch (fmt) + { + case General_options::OBJECT_FORMAT_ELF: + return "elf"; + case General_options::OBJECT_FORMAT_BINARY: + return "binary"; + default: + gold_unreachable(); + } +} + void General_options::parse_fix_v4bx(const char*, const char*, Command_line*) @@ -715,6 +729,39 @@ General_options::parse_EL(const char*, const char*, Command_line*) this->endianness_ = ENDIANNESS_LITTLE; } +void +General_options::copy_from_posdep_options( + const Position_dependent_options& posdep) +{ + this->set_as_needed(posdep.as_needed()); + this->set_Bdynamic(posdep.Bdynamic()); + this->set_format( + General_options::object_format_to_string(posdep.format_enum())); + this->set_whole_archive(posdep.whole_archive()); + this->set_incremental_disposition(posdep.incremental_disposition()); +} + +void +General_options::parse_push_state(const char*, const char*, Command_line*) +{ + Position_dependent_options* posdep = new Position_dependent_options(*this); + this->options_stack_.push_back(posdep); +} + +void +General_options::parse_pop_state(const char*, const char*, Command_line*) +{ + if (this->options_stack_.empty()) + { + gold::gold_error(_("unbalanced --push-state/--pop-state")); + return; + } + Position_dependent_options* posdep = this->options_stack_.back(); + this->options_stack_.pop_back(); + this->copy_from_posdep_options(*posdep); + delete posdep; +} + } // End namespace gold. namespace |