LLVM  14.0.0git
IFSStub.cpp
Go to the documentation of this file.
1 //===- IFSStub.cpp --------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===-----------------------------------------------------------------------===/
8 
10 #include "llvm/BinaryFormat/ELF.h"
11 #include "llvm/Support/Error.h"
12 
13 using namespace llvm;
14 using namespace llvm::ifs;
15 
16 IFSStub::IFSStub(IFSStub const &Stub) {
17  IfsVersion = Stub.IfsVersion;
18  Target = Stub.Target;
19  SoName = Stub.SoName;
20  NeededLibs = Stub.NeededLibs;
21  Symbols = Stub.Symbols;
22 }
23 
25  IfsVersion = std::move(Stub.IfsVersion);
26  Target = std::move(Stub.Target);
27  SoName = std::move(Stub.SoName);
28  NeededLibs = std::move(Stub.NeededLibs);
29  Symbols = std::move(Stub.Symbols);
30 }
31 
33  IfsVersion = Stub.IfsVersion;
34  Target = Stub.Target;
35  SoName = Stub.SoName;
36  NeededLibs = Stub.NeededLibs;
37  Symbols = Stub.Symbols;
38 }
39 
41  IfsVersion = Stub.IfsVersion;
42  Target = Stub.Target;
43  SoName = Stub.SoName;
44  NeededLibs = Stub.NeededLibs;
45  Symbols = Stub.Symbols;
46 }
47 
49  IfsVersion = std::move(Stub.IfsVersion);
50  Target = std::move(Stub.Target);
51  SoName = std::move(Stub.SoName);
52  NeededLibs = std::move(Stub.NeededLibs);
53  Symbols = std::move(Stub.Symbols);
54 }
55 
57  return !Triple && !ObjectFormat && !Arch && !ArchString && !Endianness &&
58  !BitWidth;
59 }
60 
62  switch (BitWidth) {
64  return ELF::ELFCLASS32;
66  return ELF::ELFCLASS64;
67  default:
68  llvm_unreachable("unknown bitwidth");
69  }
70 }
71 
73  switch (Endianness) {
75  return ELF::ELFDATA2LSB;
77  return ELF::ELFDATA2MSB;
78  default:
79  llvm_unreachable("unknown endianness");
80  }
81 }
82 
84  switch (SymbolType) {
86  return ELF::STT_OBJECT;
88  return ELF::STT_FUNC;
89  case IFSSymbolType::TLS:
90  return ELF::STT_TLS;
92  default:
93  return ELF::STT_NOTYPE;
94  }
95 }
96 
98  switch (BitWidth) {
99  case ELF::ELFCLASS32:
100  return IFSBitWidthType::IFS32;
101  case ELF::ELFCLASS64:
102  return IFSBitWidthType::IFS64;
103  default:
105  }
106 }
107 
109  switch (Endianness) {
110  case ELF::ELFDATA2LSB:
112  case ELF::ELFDATA2MSB:
113  return IFSEndiannessType::Big;
114  default:
116  }
117 }
118 
120  SymbolType = SymbolType & 0xf;
121  switch (SymbolType) {
122  case ELF::STT_OBJECT:
123  return IFSSymbolType::Object;
124  case ELF::STT_FUNC:
125  return IFSSymbolType::Func;
126  case ELF::STT_TLS:
127  return IFSSymbolType::TLS;
128  case ELF::STT_NOTYPE:
129  return IFSSymbolType::NoType;
130  default:
131  return IFSSymbolType::Unknown;
132  }
133 }
llvm::ifs::IFSSymbolType::Unknown
@ Unknown
llvm::ifs::IFSStub::NeededLibs
std::vector< std::string > NeededLibs
Definition: IFSStub.h:95
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::msgpack::Endianness
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
Definition: MsgPack.h:24
llvm::ifs::IFSBitWidthType
IFSBitWidthType
Definition: IFSStub.h:45
llvm::ifs
Definition: ELFObjHandler.h:25
llvm::ELF::ELFCLASS32
@ ELFCLASS32
Definition: ELF.h:328
llvm::ifs::IFSStub::IFSStub
IFSStub()
Definition: IFSStub.h:98
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::ifs::convertIFSSymbolTypeToELF
uint8_t convertIFSSymbolTypeToELF(IFSSymbolType SymbolType)
This function convert symbol type from IFS enum to ELF format Currently, STT_NOTYPE,...
Definition: IFSStub.cpp:83
llvm::ifs::IFSTarget::Arch
Optional< IFSArch > Arch
Definition: IFSStub.h:68
llvm::XCOFF::SymbolType
SymbolType
Definition: XCOFF.h:196
Error.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::ELF::ELFDATA2LSB
@ ELFDATA2LSB
Definition: ELF.h:335
llvm::ifs::convertELFSymbolTypeToIFS
IFSSymbolType convertELFSymbolTypeToIFS(uint8_t SymbolType)
This function extracts symbol type from a symbol's st_info member and maps it to an IFSSymbolType enu...
Definition: IFSStub.cpp:119
llvm::ELF::STT_TLS
@ STT_TLS
Definition: ELF.h:1162
llvm::ifs::IFSBitWidthType::Unknown
@ Unknown
ELF.h
llvm::ifs::IFSSymbolType
IFSSymbolType
Definition: IFSStub.h:27
llvm::ifs::convertIFSBitWidthToELF
uint8_t convertIFSBitWidthToELF(IFSBitWidthType BitWidth)
This function convert bit width type from IFS enum to ELF format Currently, ELFCLASS32 and ELFCLASS64...
Definition: IFSStub.cpp:61
llvm::ifs::IFSStub
Definition: IFSStub.h:90
llvm::ifs::IFSSymbolType::TLS
@ TLS
llvm::ifs::IFSTarget::empty
bool empty()
Definition: IFSStub.cpp:56
llvm::ifs::IFSStubTriple::IFSStubTriple
IFSStubTriple()
Definition: IFSStub.h:109
llvm::ifs::IFSBitWidthType::IFS32
@ IFS32
llvm::ifs::IFSEndiannessType::Big
@ Big
llvm::ifs::IFSStub::SoName
Optional< std::string > SoName
Definition: IFSStub.h:93
IFSStub.h
llvm::ELF::ELFDATA2MSB
@ ELFDATA2MSB
Definition: ELF.h:336
llvm::ELF::STT_FUNC
@ STT_FUNC
Definition: ELF.h:1158
llvm::ifs::IFSTarget::BitWidth
Optional< IFSBitWidthType > BitWidth
Definition: IFSStub.h:71
llvm::ifs::IFSEndiannessType::Unknown
@ Unknown
llvm::ifs::convertELFEndiannessToIFS
IFSEndiannessType convertELFEndiannessToIFS(uint8_t Endianness)
This function extracts ELF endianness from e_ident[EI_DATA] of an ELF file Currently,...
Definition: IFSStub.cpp:108
llvm::ifs::IFSTarget::ArchString
Optional< std::string > ArchString
Definition: IFSStub.h:69
llvm::ifs::IFSSymbolType::NoType
@ NoType
llvm::ELF::ELFCLASS64
@ ELFCLASS64
Definition: ELF.h:329
llvm::ifs::convertELFBitWidthToIFS
IFSBitWidthType convertELFBitWidthToIFS(uint8_t BitWidth)
This function extracts ELF bit width from e_ident[EI_CLASS] of an ELF file Currently,...
Definition: IFSStub.cpp:97
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::ifs::IFSBitWidthType::IFS64
@ IFS64
llvm::ifs::IFSEndiannessType::Little
@ Little
llvm::ifs::IFSStubTriple
Definition: IFSStub.h:108
llvm::ifs::convertIFSEndiannessToELF
uint8_t convertIFSEndiannessToELF(IFSEndiannessType Endianness)
This function convert endianness type from IFS enum to ELF format Currently, ELFDATA2LSB and ELFDATA2...
Definition: IFSStub.cpp:72
llvm::ifs::IFSEndiannessType
IFSEndiannessType
Definition: IFSStub.h:37
llvm::ELF::STT_OBJECT
@ STT_OBJECT
Definition: ELF.h:1157
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::ifs::IFSSymbolType::Func
@ Func
llvm::ifs::IFSStub::Target
IFSTarget Target
Definition: IFSStub.h:94
llvm::ifs::IFSStub::IfsVersion
VersionTuple IfsVersion
Definition: IFSStub.h:92
llvm::BitWidth
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147
llvm::ifs::IFSSymbolType::Object
@ Object
llvm::ifs::IFSStub::Symbols
std::vector< IFSSymbol > Symbols
Definition: IFSStub.h:96
llvm::ELF::STT_NOTYPE
@ STT_NOTYPE
Definition: ELF.h:1156
llvm::ifs::IFSTarget::ObjectFormat
Optional< std::string > ObjectFormat
Definition: IFSStub.h:67
llvm::ifs::IFSTarget::Endianness
Optional< IFSEndiannessType > Endianness
Definition: IFSStub.h:70