2017-11-17 18:14:09 +00:00
|
|
|
//===- OutputSegment.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 08:50:56 +00: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-17 18:14:09 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_OUTPUT_SEGMENT_H
|
|
|
|
#define LLD_WASM_OUTPUT_SEGMENT_H
|
|
|
|
|
2018-01-10 01:13:34 +00:00
|
|
|
#include "InputChunks.h"
|
2017-11-17 18:14:09 +00:00
|
|
|
#include "lld/Common/ErrorHandler.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
|
|
|
class InputSegment;
|
|
|
|
|
|
|
|
class OutputSegment {
|
|
|
|
public:
|
2018-02-23 05:08:53 +00:00
|
|
|
OutputSegment(StringRef n, uint32_t index) : name(n), index(index) {}
|
2019-07-11 05:40:30 +00:00
|
|
|
|
2018-02-28 00:20:29 +00:00
|
|
|
void addInputSegment(InputSegment *inSeg) {
|
|
|
|
alignment = std::max(alignment, inSeg->getAlignment());
|
|
|
|
inputSegments.push_back(inSeg);
|
2019-01-17 22:09:09 +00:00
|
|
|
size = llvm::alignTo(size, 1ULL << inSeg->getAlignment());
|
2018-02-28 00:20:29 +00:00
|
|
|
inSeg->outputSeg = this;
|
|
|
|
inSeg->outputSegmentOffset = size;
|
|
|
|
size += inSeg->getSize();
|
2017-11-17 18:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef name;
|
2018-02-23 05:08:53 +00:00
|
|
|
const uint32_t index;
|
2019-07-03 22:04:54 +00:00
|
|
|
uint32_t initFlags = 0;
|
2018-04-05 19:37:31 +00:00
|
|
|
uint32_t sectionOffset = 0;
|
2017-11-17 18:14:09 +00:00
|
|
|
uint32_t alignment = 0;
|
|
|
|
uint32_t startVA = 0;
|
2017-12-19 20:45:15 +00:00
|
|
|
std::vector<InputSegment *> inputSegments;
|
2017-11-17 18:14:09 +00: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
|