blob: 22bca359748a7bae9cecb6f37a59a656dd49b127 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
//===- Chunks.cpp ---------------------------------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Chunks.h"
#include "Error.h"
#include "InputFiles.h"
using namespace llvm;
using namespace llvm::ELF;
using namespace lld;
using namespace lld::elf2;
template <class ELFT>
InputSection<ELFT>::InputSection(ObjectFile<ELFT> *F, const Elf_Shdr *Header)
: File(F), Header(Header) {}
template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
if (Header->sh_type == SHT_NOBITS)
return;
// Copy section contents from source object file to output file.
ArrayRef<uint8_t> Data = *File->getObj()->getSectionContents(Header);
memcpy(Buf + OutputSectionOff, Data.data(), Data.size());
}
template <class ELFT> StringRef InputSection<ELFT>::getSectionName() const {
ErrorOr<StringRef> Name = File->getObj()->getSectionName(Header);
error(Name);
return *Name;
}
namespace lld {
namespace elf2 {
template class InputSection<object::ELF32LE>;
template class InputSection<object::ELF32BE>;
template class InputSection<object::ELF64LE>;
template class InputSection<object::ELF64BE>;
}
}
|