]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/TextAPI/ELF/ELFStub.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / TextAPI / ELF / ELFStub.h
1 //===- ELFStub.h ------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===-----------------------------------------------------------------------===/
9 ///
10 /// \file
11 /// This file defines an internal representation of an ELF stub.
12 ///
13 //===-----------------------------------------------------------------------===/
14
15 #ifndef LLVM_TEXTAPI_ELF_ELFSTUB_H
16 #define LLVM_TEXTAPI_ELF_ELFSTUB_H
17
18 #include "llvm/BinaryFormat/ELF.h"
19 #include "llvm/Support/VersionTuple.h"
20 #include <vector>
21 #include <set>
22
23 namespace llvm {
24 namespace elfabi {
25
26 typedef uint16_t ELFArch;
27
28 enum class ELFSymbolType {
29   NoType = ELF::STT_NOTYPE,
30   Object = ELF::STT_OBJECT,
31   Func = ELF::STT_FUNC,
32   TLS = ELF::STT_TLS,
33
34   // Type information is 4 bits, so 16 is safely out of range.
35   Unknown = 16,
36 };
37
38 struct ELFSymbol {
39   ELFSymbol(std::string SymbolName) : Name(SymbolName) {}
40   std::string Name;
41   uint64_t Size;
42   ELFSymbolType Type;
43   bool Undefined;
44   bool Weak;
45   Optional<std::string> Warning;
46   bool operator<(const ELFSymbol &RHS) const {
47     return Name < RHS.Name;
48   }
49 };
50
51 // A cumulative representation of ELF stubs.
52 // Both textual and binary stubs will read into and write from this object.
53 class ELFStub {
54 // TODO: Add support for symbol versioning.
55 public:
56   VersionTuple TbeVersion;
57   Optional<std::string> SoName;
58   ELFArch Arch;
59   std::vector<std::string> NeededLibs;
60   std::set<ELFSymbol> Symbols;
61
62   ELFStub() {}
63   ELFStub(const ELFStub &Stub);
64   ELFStub(ELFStub &&Stub);
65 };
66 } // end namespace elfabi
67 } // end namespace llvm
68
69 #endif // LLVM_TEXTAPI_ELF_ELFSTUB_H