ld/
[binutils.git] / gold / target-select.h
blob0762d58f73417dde3509fcf945aed1ef4c16b60f
1 // target-select.h -- select a target for an object file -*- C++ -*-
3 #ifndef GOLD_TARGET_SELECT_H
4 #define GOLD_TARGET_SELECT_H
6 namespace gold
9 class Target;
11 // We want to avoid a master list of targets, which implies using a
12 // global constructor. And we also want the program to start up as
13 // quickly as possible, which implies avoiding global constructors.
14 // We compromise on a very simple global constructor. We use a target
15 // selector, which specifies an ELF machine number and a recognition
16 // function. We use global constructors to build a linked list of
17 // target selectors--a simple pointer list, not a std::list.
19 class Target_selector
21 public:
22 // Create a target selector for a specific machine number, size (32
23 // or 64), and endianness. The machine number can be EM_NONE to
24 // test for any machine number.
25 Target_selector(int machine, int size, bool big_endian);
27 virtual ~Target_selector()
28 { }
30 // If we can handle this target, return a pointer to a target
31 // structure. The size and endianness are known.
32 virtual Target* recognize(int machine, int osabi, int abiversion) const = 0;
34 // Return the next Target_selector in the linked list.
35 Target_selector*
36 next() const
37 { return this->next_; }
39 // Return the machine number this selector is looking for, which can
40 // be EM_NONE to match any machine number.
41 int
42 machine() const
43 { return this->machine_; }
45 // Return the size this is looking for (32 or 64).
46 int
47 size() const
48 { return this->size_; }
50 // Return the endianness this is looking for.
51 bool
52 big_endian() const
53 { return this->big_endian_; }
55 private:
56 int machine_;
57 int size_;
58 bool big_endian_;
59 Target_selector* next_;
62 // Select the target for an ELF file.
64 extern Target* select_target(int machine, int size, bool big_endian,
65 int osabi, int abiversion);
67 } // End namespace gold.
69 #endif // !defined(GOLD_TARGET_SELECT_H)