[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / lld / wasm / OutputSegment.h
blob701df1fecc4b891f00c3aa2fa1c271b3d56fddf8
1 //===- OutputSegment.h ------------------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_WASM_OUTPUT_SEGMENT_H
10 #define LLD_WASM_OUTPUT_SEGMENT_H
12 #include "InputChunks.h"
13 #include "lld/Common/ErrorHandler.h"
14 #include "llvm/Object/Wasm.h"
16 namespace lld::wasm {
18 class InputSegment;
20 class OutputSegment {
21 public:
22 OutputSegment(StringRef n) : name(n) {}
24 void addInputSegment(InputChunk *inSeg);
25 void finalizeInputSegments();
26 // In most circumstances BSS segments don't need to be written
27 // to the output binary. However if the memory is imported, and
28 // we can't use memory.fill during startup (due to lack of bulk
29 // memory feature) then we include BSS segments verbatim.
30 bool requiredInBinary() const { return !isBss || ctx.emitBssSegments; }
32 bool isTLS() const { return name == ".tdata"; }
34 StringRef name;
35 bool isBss = false;
36 uint32_t index = 0;
37 uint32_t linkingFlags = 0;
38 uint32_t initFlags = 0;
39 uint32_t sectionOffset = 0;
40 uint32_t alignment = 0;
41 uint64_t startVA = 0;
42 std::vector<InputChunk *> inputSegments;
44 // Sum of the size of the all the input segments
45 uint32_t size = 0;
47 // Segment header
48 std::string header;
51 } // namespace lld::wasm
53 #endif // LLD_WASM_OUTPUT_SEGMENT_H