diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:21 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:21 +0000 |
commit | eb1ff93d02b5f17b6b409e83c6d9be585f4a04b3 (patch) | |
tree | 7490b4a8943293f251ad733465936e6ec302b3e9 /wasm/OutputSegment.h | |
parent | bafea25f368c63f0b39789906adfed6e39219e64 (diff) |
Notes
Diffstat (limited to 'wasm/OutputSegment.h')
-rw-r--r-- | wasm/OutputSegment.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/wasm/OutputSegment.h b/wasm/OutputSegment.h new file mode 100644 index 0000000000000..1375aefae92ff --- /dev/null +++ b/wasm/OutputSegment.h @@ -0,0 +1,56 @@ +//===- OutputSegment.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_WASM_OUTPUT_SEGMENT_H +#define LLD_WASM_OUTPUT_SEGMENT_H + +#include "InputSegment.h" +#include "lld/Common/ErrorHandler.h" +#include "llvm/Object/Wasm.h" + +namespace lld { +namespace wasm { + +class InputSegment; + +class OutputSegment { +public: + OutputSegment(StringRef N) : Name(N) {} + + void addInputSegment(InputSegment *Segment) { + Alignment = std::max(Alignment, Segment->getAlignment()); + InputSegments.push_back(Segment); + Size = llvm::alignTo(Size, Segment->getAlignment()); + Segment->setOutputSegment(this, Size); + Size += Segment->getSize(); + } + + uint32_t getSectionOffset() const { return SectionOffset; } + + void setSectionOffset(uint32_t Offset) { SectionOffset = Offset; } + + StringRef Name; + uint32_t Alignment = 0; + uint32_t StartVA = 0; + std::vector<const InputSegment *> InputSegments; + + // Sum of the size of the all the input segments + uint32_t Size = 0; + + // Segment header + std::string Header; + +private: + uint32_t SectionOffset = 0; +}; + +} // namespace wasm +} // namespace lld + +#endif // LLD_WASM_OUTPUT_SEGMENT_H |