Update copyright years. Update language files.
[deliverable/binutils-gdb.git] / gold / target-select.h
1 // target-select.h -- select a target for an object file -*- C++ -*-
2
3 // Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
12
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
22
23 #ifndef GOLD_TARGET_SELECT_H
24 #define GOLD_TARGET_SELECT_H
25
26 namespace gold
27 {
28
29 class Target;
30
31 // We want to avoid a master list of targets, which implies using a
32 // global constructor. And we also want the program to start up as
33 // quickly as possible, which implies avoiding global constructors.
34 // We compromise on a very simple global constructor. We use a target
35 // selector, which specifies an ELF machine number and a recognition
36 // function. We use global constructors to build a linked list of
37 // target selectors--a simple pointer list, not a std::list.
38
39 class Target_selector
40 {
41 public:
42 // Create a target selector for a specific machine number, size (32
43 // or 64), and endianness. The machine number can be EM_NONE to
44 // test for any machine number.
45 Target_selector(int machine, int size, bool is_big_endian);
46
47 virtual ~Target_selector()
48 { }
49
50 // If we can handle this target, return a pointer to a target
51 // structure. The size and endianness are known.
52 virtual Target*
53 recognize(int machine, int osabi, int abiversion) = 0;
54
55 // If NAME matches the target, return a pointer to a target
56 // structure.
57 virtual Target*
58 recognize_by_name(const char* name) = 0;
59
60 // Return the next Target_selector in the linked list.
61 Target_selector*
62 next() const
63 { return this->next_; }
64
65 // Return the machine number this selector is looking for, which can
66 // be EM_NONE to match any machine number.
67 int
68 machine() const
69 { return this->machine_; }
70
71 // Return the size this is looking for (32 or 64).
72 int
73 get_size() const
74 { return this->size_; }
75
76 // Return the endianness this is looking for.
77 bool
78 is_big_endian() const
79 { return this->is_big_endian_; }
80
81 private:
82 int machine_;
83 int size_;
84 bool is_big_endian_;
85 Target_selector* next_;
86 };
87
88 // Select the target for an ELF file.
89
90 extern Target* select_target(int machine, int size, bool big_endian,
91 int osabi, int abiversion);
92
93 // Select a target using a BFD name.
94
95 extern Target* select_target_by_name(const char* name);
96
97 } // End namespace gold.
98
99 #endif // !defined(GOLD_TARGET_SELECT_H)
This page took 0.036148 seconds and 5 git commands to generate.