Coverage Report

Created: 2018-01-17 21:32

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/Writer.h
Line
Count
Source (jump to first uncovered line)
1
//===- Writer.h -------------------------------------------------*- C++ -*-===//
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
10
#ifndef LLD_COFF_WRITER_H
11
#define LLD_COFF_WRITER_H
12
13
#include "Chunks.h"
14
#include "llvm/ADT/StringRef.h"
15
#include "llvm/Object/COFF.h"
16
#include <chrono>
17
#include <cstdint>
18
#include <vector>
19
20
namespace lld {
21
namespace coff {
22
static const int PageSize = 4096;
23
24
void writeResult();
25
26
// OutputSection represents a section in an output file. It's a
27
// container of chunks. OutputSection and Chunk are 1:N relationship.
28
// Chunks cannot belong to more than one OutputSections. The writer
29
// creates multiple OutputSections and assign them unique,
30
// non-overlapping file offsets and RVAs.
31
class OutputSection {
32
public:
33
0
  OutputSection(llvm::StringRef N) : Name(N), Header({}) {}
34
  void setRVA(uint64_t);
35
  void setFileOffset(uint64_t);
36
  void addChunk(Chunk *C);
37
0
  llvm::StringRef getName() { return Name; }
38
0
  ArrayRef<Chunk *> getChunks() { return Chunks; }
39
  void addPermissions(uint32_t C);
40
  void setPermissions(uint32_t C);
41
0
  uint32_t getPermissions() { return Header.Characteristics & PermMask; }
42
0
  uint32_t getCharacteristics() { return Header.Characteristics; }
43
0
  uint64_t getRVA() { return Header.VirtualAddress; }
44
0
  uint64_t getFileOff() { return Header.PointerToRawData; }
45
  void writeHeaderTo(uint8_t *Buf);
46
47
  // Returns the size of this section in an executable memory image.
48
  // This may be smaller than the raw size (the raw size is multiple
49
  // of disk sector size, so there may be padding at end), or may be
50
  // larger (if that's the case, the loader reserves spaces after end
51
  // of raw data).
52
0
  uint64_t getVirtualSize() { return Header.VirtualSize; }
53
54
  // Returns the size of the section in the output file.
55
0
  uint64_t getRawSize() { return Header.SizeOfRawData; }
56
57
  // Set offset into the string table storing this section name.
58
  // Used only when the name is longer than 8 bytes.
59
0
  void setStringTableOff(uint32_t V) { StringTableOff = V; }
60
61
  // N.B. The section index is one based.
62
  uint32_t SectionIndex = 0;
63
64
private:
65
  llvm::StringRef Name;
66
  llvm::object::coff_section Header;
67
  uint32_t StringTableOff = 0;
68
  std::vector<Chunk *> Chunks;
69
};
70
71
}
72
}
73
74
#endif