From e96caa791095788fe6b3cbbdc54547278ca70db7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 25 Mar 2008 21:39:01 +0000 Subject: * options.cc (options::help): Print list of supported targets. * target-select.h: Include . (class Target_selector): Make machine_, size_, and is_big_endian_ fields const. Add bfd_name_ and instantiated_target_ fields. (Target_selector::Target_selector): Add bfd_name parameter. (Target_selector::recognize): Make non-virtual, call do_recognize. (Target_selector::recognize_by_name): Make non-virtual, call do_recognize_by_name. (Target_selector::supported_names): New function. (Target_selector::bfd_name): New function. (Target_selector::do_instantiate_target): New pure virtual function. (Target_selector::do_recognize): New virtual function. (Target_selector::do_recognize_by_name): New virtual function. (Target_selector::instantiate_target): New private function. (supported_target_names): Declare. * target-select.cc (Target_selector::Target_selector): Update for new parameter and fields. (select_target_by_name): Check that the name matches before calling recognize_by_name. (supported_target_names): New function. * i386.cc (class Target_selector_i386): Update Target_selector constructor call. Remove recognize and recognize_by_name. Add do_instantiate_target. * x86_64.cc (class Target_selector_x86_64): Likewise. * testsuite/testfile.cc (class Target_selector_test): Update for changes to Target_selector. --- gold/target-select.cc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'gold/target-select.cc') diff --git a/gold/target-select.cc b/gold/target-select.cc index 8a75708..092a1df 100644 --- a/gold/target-select.cc +++ b/gold/target-select.cc @@ -41,8 +41,11 @@ namespace gold // list. This runs at global constructor time, so we want it to be // fast. -Target_selector::Target_selector(int machine, int size, bool is_big_endian) - : machine_(machine), size_(size), is_big_endian_(is_big_endian) +Target_selector::Target_selector(int machine, int size, bool is_big_endian, + const char* bfd_name) + : machine_(machine), size_(size), is_big_endian_(is_big_endian), + bfd_name_(bfd_name), instantiated_target_(NULL) + { this->next_ = target_selectors; target_selectors = this; @@ -77,11 +80,24 @@ select_target_by_name(const char* name) { for (Target_selector* p = target_selectors; p != NULL; p = p->next()) { - Target* ret = p->recognize_by_name(name); - if (ret != NULL) - return ret; + const char* pname = p->bfd_name(); + if (pname == NULL || strcmp(pname, name) == 0) + { + Target* ret = p->recognize_by_name(name); + if (ret != NULL) + return ret; + } } return NULL; } +// Push all the supported BFD names onto a vector. + +void +supported_target_names(std::vector* names) +{ + for (Target_selector* p = target_selectors; p != NULL; p = p->next()) + p->supported_names(names); +} + } // End namespace gold. -- cgit v1.1