blob: 3c856714b28b93d9162f70c08e6e87339f4225b4 [file] [log] [blame]
Sam Cleggc94d3932017-11-17 18:14:09 +00001//===- InputSegment.cpp ---------------------------------------------------===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Sam Clegg5fa274b2018-01-10 01:13:34 +000010#include "InputChunks.h"
Sam Cleggc94d3932017-11-17 18:14:09 +000011#include "OutputSegment.h"
12#include "lld/Common/LLVM.h"
13
14#define DEBUG_TYPE "lld"
15
16using namespace llvm;
17using namespace lld::wasm;
18
19uint32_t InputSegment::translateVA(uint32_t Address) const {
20 assert(Address >= startVA() && Address < endVA());
Sam Clegg5fa274b2018-01-10 01:13:34 +000021 int32_t Delta = OutputSeg->StartVA + OutputOffset - startVA();
Sam Cleggc94d3932017-11-17 18:14:09 +000022 DEBUG(dbgs() << "translateVA: " << getName() << " Delta=" << Delta
23 << " Address=" << Address << "\n");
24 return Address + Delta;
25}
Sam Clegg5fa274b2018-01-10 01:13:34 +000026
27void InputChunk::copyRelocations(const WasmSection &Section) {
28 size_t Start = getInputSectionOffset();
29 size_t Size = getSize();
30 for (const WasmRelocation &R : Section.Relocations)
31 if (R.Offset >= Start && R.Offset < Start + Size)
32 Relocations.push_back(R);
33}