2017-11-18 02:14:09 +08:00
|
|
|
//===- OutputSegment.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-11-18 02:14:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_OUTPUT_SEGMENT_H
|
|
|
|
#define LLD_WASM_OUTPUT_SEGMENT_H
|
|
|
|
|
2018-01-10 09:13:34 +08:00
|
|
|
#include "InputChunks.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "lld/Common/ErrorHandler.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
|
|
|
class InputSegment;
|
|
|
|
|
|
|
|
class OutputSegment {
|
|
|
|
public:
|
2019-09-19 09:14:59 +08:00
|
|
|
OutputSegment(StringRef n) : name(n) {}
|
2019-07-11 13:40:30 +08:00
|
|
|
|
2018-02-28 08:20:29 +08:00
|
|
|
void addInputSegment(InputSegment *inSeg) {
|
|
|
|
alignment = std::max(alignment, inSeg->getAlignment());
|
|
|
|
inputSegments.push_back(inSeg);
|
2019-01-18 06:09:09 +08:00
|
|
|
size = llvm::alignTo(size, 1ULL << inSeg->getAlignment());
|
2018-02-28 08:20:29 +08:00
|
|
|
inSeg->outputSeg = this;
|
|
|
|
inSeg->outputSegmentOffset = size;
|
|
|
|
size += inSeg->getSize();
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef name;
|
2019-10-16 03:05:11 +08:00
|
|
|
bool isBss = false;
|
2019-09-19 09:14:59 +08:00
|
|
|
uint32_t index = 0;
|
2019-07-04 06:04:54 +08:00
|
|
|
uint32_t initFlags = 0;
|
2018-04-06 03:37:31 +08:00
|
|
|
uint32_t sectionOffset = 0;
|
2017-11-18 02:14:09 +08:00
|
|
|
uint32_t alignment = 0;
|
|
|
|
uint32_t startVA = 0;
|
2017-12-20 04:45:15 +08:00
|
|
|
std::vector<InputSegment *> inputSegments;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
// Sum of the size of the all the input segments
|
|
|
|
uint32_t size = 0;
|
|
|
|
|
|
|
|
// Segment header
|
|
|
|
std::string header;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif // LLD_WASM_OUTPUT_SEGMENT_H
|