1 // target-select.h -- select a target for an object file -*- C++ -*-
3 #ifndef GOLD_TARGET_SELECT_H
4 #define GOLD_TARGET_SELECT_H
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.
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()
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.
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.
43 { return this->machine_
; }
45 // Return the size this is looking for (32 or 64).
48 { return this->size_
; }
50 // Return the endianness this is looking for.
53 { return this->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)