2017-11-18 02:14:09 +08:00
|
|
|
//===- OutputSegment.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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);
|
|
|
|
Size = llvm::alignTo(Size, InSeg->getAlignment());
|
|
|
|
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
|