diff options
author | Lang Hames <lhames@gmail.com> | 2019-05-10 22:24:37 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2019-05-10 22:24:37 +0000 |
commit | b0cecfc90701e01e26bea8c21802918ea275a184 (patch) | |
tree | 22ffc8147d46462e6d89b416a18edcbc61f6c71b /llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h | |
parent | c10f80eb7b4a546899ded220b3cd6cbaef0c7019 (diff) | |
download | bcm5719-llvm-b0cecfc90701e01e26bea8c21802918ea275a184.tar.gz bcm5719-llvm-b0cecfc90701e01e26bea8c21802918ea275a184.zip |
[JITLink][MachO] Mark atoms in sections 'no-dead-strip' set live by default.
If a MachO section has the no-dead-strip attribute set then its atoms should
be preserved, regardless of whether they're public or referenced elsewhere in
the object.
llvm-svn: 360477
Diffstat (limited to 'llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h')
-rw-r--r-- | llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h index 540e2c366f0..f5cd0ea1853 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h +++ b/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.h @@ -34,17 +34,10 @@ protected: public: MachOSection() = default; - /// Create a MachO section with the given content. + /// Create a MachO section with the given address and alignment. MachOSection(Section &GenericSection, JITTargetAddress Address, - unsigned Alignment, StringRef Content) + unsigned Alignment) : Address(Address), GenericSection(&GenericSection), - ContentPtr(Content.data()), Size(Content.size()), - Alignment(Alignment) {} - - /// Create a zero-fill MachO section with the given size. - MachOSection(Section &GenericSection, JITTargetAddress Address, - unsigned Alignment, size_t ZeroFillSize) - : Address(Address), GenericSection(&GenericSection), Size(ZeroFillSize), Alignment(Alignment) {} /// Create a section without address, content or size (used for common @@ -61,6 +54,19 @@ protected: return GenericSection->getName(); } + MachOSection &setContent(StringRef Content) { + assert(!ContentPtr && !Size && "Content/zeroFill already set"); + ContentPtr = Content.data(); + Size = Content.size(); + return *this; + } + + MachOSection &setZeroFill(uint64_t Size) { + assert(!ContentPtr && !Size && "Content/zeroFill already set"); + this->Size = Size; + return *this; + } + bool isZeroFill() const { return !ContentPtr; } bool empty() const { return getSize() == 0; } @@ -76,12 +82,20 @@ protected: unsigned getAlignment() const { return Alignment; } + MachOSection &setNoDeadStrip(bool NoDeadStrip) { + this->NoDeadStrip = NoDeadStrip; + return *this; + } + + bool isNoDeadStrip() const { return NoDeadStrip; } + private: JITTargetAddress Address = 0; Section *GenericSection = nullptr; const char *ContentPtr = nullptr; - size_t Size = 0; + uint64_t Size = 0; unsigned Alignment = 0; + bool NoDeadStrip = false; }; using CustomAtomizeFunction = std::function<Error(MachOSection &S)>; |