Commit | Line | Data |
---|---|---|
af6359d5 ILT |
1 | // tls.h -- Thread-Local Storage utility routines for gold -*- C++ -*- |
2 | ||
3 | // Copyright 2006, 2007 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_TLS_H | |
24 | #define GOLD_TLS_H | |
25 | ||
26 | #include "elfcpp.h" | |
27 | #include "reloc.h" | |
28 | ||
29 | namespace gold | |
30 | { | |
31 | ||
32 | namespace tls | |
33 | { | |
34 | ||
35 | // This is used for relocations that can be converted to a different, | |
36 | // more efficient type of relocation. | |
37 | ||
38 | enum Tls_optimization | |
39 | { | |
40 | TLSOPT_NONE, // Can not convert this relocation to a more efficient one. | |
41 | TLSOPT_TO_LD, // Can convert General Dynamic to Local Dynamic. | |
42 | TLSOPT_TO_LE, // Can convert GD or LD to Local-Exec. | |
43 | TLSOPT_TO_IE, // Can convert GD or LD or LE to Initial-Exec. | |
44 | }; | |
45 | ||
46 | // Check the range for a TLS relocation. This is inlined for efficiency. | |
47 | ||
48 | template<int size, bool big_endian> | |
49 | inline void | |
50 | check_range(const Relocate_info<size, big_endian>* relinfo, | |
51 | size_t relnum, | |
52 | typename elfcpp::Elf_types<size>::Elf_Addr rel_offset, | |
53 | off_t view_size, off_t off) | |
54 | { | |
55 | off_t offset = rel_offset + off; | |
56 | if (offset < 0 || offset > view_size) | |
75f2446e ILT |
57 | gold_error_at_location(relinfo, relnum, rel_offset, |
58 | _("TLS relocation out of range")); | |
af6359d5 ILT |
59 | } |
60 | ||
61 | // Check the validity of a TLS relocation. This is like assert. | |
62 | ||
63 | template<int size, bool big_endian> | |
64 | inline void | |
65 | check_tls(const Relocate_info<size, big_endian>* relinfo, | |
66 | size_t relnum, | |
67 | typename elfcpp::Elf_types<size>::Elf_Addr rel_offset, | |
68 | bool valid) | |
69 | { | |
70 | if (!valid) | |
75f2446e ILT |
71 | gold_error_at_location(relinfo, relnum, rel_offset, |
72 | _("TLS relocation against invalid instruction")); | |
af6359d5 ILT |
73 | } |
74 | ||
75 | ||
76 | } // End namespace tls. | |
77 | ||
78 | } // End namespace gold. | |
79 | ||
80 | #endif // !defined(GOLD_TLS_H) |