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:
|
2018-02-23 13:08:53 +08:00
|
|
|
OutputSegment(StringRef N, uint32_t Index) : Name(N), Index(Index) {}
|
2017-11-18 02:14:09 +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;
|
2018-02-23 13:08:53 +08:00
|
|
|
const uint32_t Index;
|
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
|