blob: ffb43263badbb0e5ed6170203e0ec2286497ef57 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
//===- lib/ReaderWriter/ELF/DynamicFile.h ---------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_READER_WRITER_ELF_DYNAMIC_FILE_H
#define LLD_READER_WRITER_ELF_DYNAMIC_FILE_H
#include "Atoms.h"
#include "lld/Core/SharedLibraryFile.h"
#include <unordered_map>
namespace lld {
class ELFLinkingContext;
namespace elf {
template <class ELFT> class DynamicFile : public SharedLibraryFile {
public:
DynamicFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
static std::error_code isCompatible(const MemoryBuffer &mb,
ELFLinkingContext &ctx);
const SharedLibraryAtom *exports(StringRef name,
bool dataSymbolOnly) const override;
StringRef getDSOName() const override;
static bool canParse(file_magic magic);
protected:
std::error_code doParse() override;
private:
mutable llvm::BumpPtrAllocator _alloc;
std::unique_ptr<llvm::object::ELFFile<ELFT>> _objFile;
/// \brief DT_SONAME
StringRef _soname;
struct SymAtomPair {
const typename llvm::object::ELFFile<ELFT>::Elf_Sym *_symbol = nullptr;
const SharedLibraryAtom *_atom = nullptr;
};
std::unique_ptr<MemoryBuffer> _mb;
ELFLinkingContext &_ctx;
bool _useShlibUndefines;
mutable std::unordered_map<StringRef, SymAtomPair> _nameToSym;
};
} // end namespace elf
} // end namespace lld
#endif
|