add this momentarily, will move them to the attic soon
[binutils.git] / gold / target-select.cc
blobd15d0e346d1d15d307c248f1038f26b0d2a92ef2
1 // target-select.cc -- select a target for an object file
3 #include "gold.h"
5 #include "elfcpp.h"
6 #include "target-select.h"
8 namespace
11 // The start of the list of target selectors.
13 gold::Target_selector* target_selectors;
15 } // End anonymous namespace.
17 namespace gold
20 // Construct a Target_selector, which means adding it to the linked
21 // list. This runs at global constructor time, so we want it to be
22 // fast.
24 Target_selector::Target_selector(int machine, int size, bool big_endian)
25 : machine_(machine), size_(size), big_endian_(big_endian)
27 this->next_ = target_selectors;
28 target_selectors = this;
31 // Find the target for an ELF file.
33 extern Target*
34 select_target(int machine, int size, bool big_endian, int osabi,
35 int abiversion)
37 for (Target_selector* p = target_selectors; p != NULL; p = p->next())
39 int pmach = p->machine();
40 if ((pmach == machine || pmach == elfcpp::EM_NONE)
41 && p->size() == size
42 && p->big_endian() ? big_endian : !big_endian)
44 Target* ret = p->recognize(machine, osabi, abiversion);
45 if (ret != NULL)
46 return ret;
49 return NULL;
52 } // End namespace gold.