Coverage Report

Created: 2017-10-03 07:32

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