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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLD_WASM_OUTPUT_SEGMENT_H 10 #define LLD_WASM_OUTPUT_SEGMENT_H 11 12 #include "InputChunks.h" 13 #include "lld/Common/ErrorHandler.h" 14 #include "llvm/Object/Wasm.h" 15 16 namespace lld { 17 namespace wasm { 18 19 class InputSegment; 20 21 class OutputSegment { 22 public: OutputSegment(StringRef n)23 OutputSegment(StringRef n) : name(n) {} 24 addInputSegment(InputSegment * inSeg)25 void addInputSegment(InputSegment *inSeg) { 26 alignment = std::max(alignment, inSeg->getAlignment()); 27 inputSegments.push_back(inSeg); 28 size = llvm::alignTo(size, 1ULL << inSeg->getAlignment()); 29 inSeg->outputSeg = this; 30 inSeg->outputSegmentOffset = size; 31 size += inSeg->getSize(); 32 } 33 34 StringRef name; 35 bool isBss = false; 36 uint32_t index = 0; 37 uint32_t initFlags = 0; 38 uint32_t sectionOffset = 0; 39 uint32_t alignment = 0; 40 uint64_t startVA = 0; 41 std::vector<InputSegment *> inputSegments; 42 43 // Sum of the size of the all the input segments 44 uint32_t size = 0; 45 46 // Segment header 47 std::string header; 48 }; 49 50 } // namespace wasm 51 } // namespace lld 52 53 #endif // LLD_WASM_OUTPUT_SEGMENT_H 54