* target.h (class Target): Add osabi_ field.
[deliverable/binutils-gdb.git] / gold / freebsd.h
CommitLineData
36959681
ILT
1// freebsd.h -- FreeBSD support for gold -*- C++ -*-
2
200b2bb9 3// Copyright 2009, 2011 Free Software Foundation, Inc.
36959681
ILT
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#include "target.h"
24#include "target-select.h"
25
26#ifndef GOLD_FREEBSD_H
27#define GOLD_FREEBSD_H
28
29namespace gold
30{
31
32// FreeBSD 4.1 and later wants the EI_OSABI field in the ELF header to
200b2bb9
ILT
33// be set to ELFOSABI_FREEBSD. This is a target selector for targets
34// which permit combining both FreeBSD and non-FreeBSD object files.
36959681
ILT
35
36class Target_selector_freebsd : public Target_selector
37{
38 public:
2ea97941
ILT
39 Target_selector_freebsd(int machine, int size, bool is_big_endian,
40 const char* bfd_name,
36959681 41 const char* freebsd_bfd_name)
2ea97941
ILT
42 : Target_selector(machine, size, is_big_endian, NULL),
43 bfd_name_(bfd_name), freebsd_bfd_name_(freebsd_bfd_name)
36959681
ILT
44 { }
45
46 protected:
47 // If we see a FreeBSD input file, mark the output file as using
48 // FreeBSD.
49 virtual Target*
50 do_recognize(int, int osabi, int)
51 {
52 Target* ret = this->instantiate_target();
53 if (osabi == elfcpp::ELFOSABI_FREEBSD)
200b2bb9 54 ret->set_osabi(static_cast<elfcpp::ELFOSABI>(osabi));
36959681
ILT
55 return ret;
56 }
57
58 // Recognize two names.
59 virtual Target*
60 do_recognize_by_name(const char* name)
61 {
62 if (strcmp(name, this->bfd_name_) == 0)
63 return this->instantiate_target();
64 else if (strcmp(name, this->freebsd_bfd_name_) == 0)
65 {
66 Target* ret = this->instantiate_target();
200b2bb9 67 ret->set_osabi(elfcpp::ELFOSABI_FREEBSD);
36959681
ILT
68 return ret;
69 }
70 else
71 return NULL;
72 }
73
74 // Print both names in --help output.
75 virtual void
76 do_supported_names(std::vector<const char*>* names)
77 {
78 names->push_back(this->bfd_name_);
79 names->push_back(this->freebsd_bfd_name_);
80 }
81
82 private:
36959681
ILT
83 // The BFD name for the non-Freebsd target.
84 const char* bfd_name_;
85 // The BFD name for the Freebsd target.
86 const char* freebsd_bfd_name_;
87};
88
89} // end namespace gold
90
91#endif // !defined(GOLD_FREEBSD_H)
This page took 0.134584 seconds and 4 git commands to generate.