summaryrefslogtreecommitdiff
path: root/wasm/OutputSegment.h
diff options
context:
space:
mode:
Diffstat (limited to 'wasm/OutputSegment.h')
-rw-r--r--wasm/OutputSegment.h56
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