blob: 701df1fecc4b891f00c3aa2fa1c271b3d56fddf8 [file] [log] [blame]
Sam Cleggc94d3932017-11-17 18:14:091//===- OutputSegment.h ------------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:563// 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
Sam Cleggc94d3932017-11-17 18:14:096//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_WASM_OUTPUT_SEGMENT_H
10#define LLD_WASM_OUTPUT_SEGMENT_H
11
Sam Clegg5fa274b2018-01-10 01:13:3412#include "InputChunks.h"
Sam Cleggc94d3932017-11-17 18:14:0913#include "lld/Common/ErrorHandler.h"
14#include "llvm/Object/Wasm.h"
15
Sam Cleggd32f71a2023-03-06 17:55:0016namespace lld::wasm {
Sam Cleggc94d3932017-11-17 18:14:0917
18class InputSegment;
19
20class OutputSegment {
21public:
Thomas Lively21143b92019-09-19 01:14:5922 OutputSegment(StringRef n) : name(n) {}
Sam Cleggc94d3932017-11-17 18:14:0923
Sam Clegg5a9b25e2021-05-14 23:25:0424 void addInputSegment(InputChunk *inSeg);
Sam Clegg3b8d2be2021-02-27 00:09:3225 void finalizeInputSegments();
Sam Clegg1eb79e72021-10-27 01:08:0726 // 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.
Sam Clegg184c22d2024-01-18 23:01:2130 bool requiredInBinary() const { return !isBss || ctx.emitBssSegments; }
Sam Cleggc94d3932017-11-17 18:14:0931
Sam Cleggbda8b842021-05-07 03:29:0532 bool isTLS() const { return name == ".tdata"; }
33
Rui Ueyama136d27a2019-07-11 05:40:3034 StringRef name;
Thomas Lively190dacc2019-10-15 19:05:1135 bool isBss = false;
Thomas Lively21143b92019-09-19 01:14:5936 uint32_t index = 0;
Sam Clegg3b8d2be2021-02-27 00:09:3237 uint32_t linkingFlags = 0;
Rui Ueyama136d27a2019-07-11 05:40:3038 uint32_t initFlags = 0;
39 uint32_t sectionOffset = 0;
Guillaume Chatelet15653172022-12-20 10:56:0840 uint32_t alignment = 0;
Wouter van Oortmerssen582fd472020-08-07 20:24:4341 uint64_t startVA = 0;
Sam Clegg5a9b25e2021-05-14 23:25:0442 std::vector<InputChunk *> inputSegments;
Sam Cleggc94d3932017-11-17 18:14:0943
44 // Sum of the size of the all the input segments
Rui Ueyama136d27a2019-07-11 05:40:3045 uint32_t size = 0;
Sam Cleggc94d3932017-11-17 18:14:0946
47 // Segment header
Rui Ueyama136d27a2019-07-11 05:40:3048 std::string header;
Sam Cleggc94d3932017-11-17 18:14:0949};
50
Sam Cleggd32f71a2023-03-06 17:55:0051} // namespace lld::wasm
Sam Cleggc94d3932017-11-17 18:14:0952
53#endif // LLD_WASM_OUTPUT_SEGMENT_H