173
|
1 //===- OutputSegment.h ------------------------------------------*- C++ -*-===//
|
|
2 //
|
|
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
4 // See https://llvm.org/LICENSE.txt for license information.
|
|
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
6 //
|
|
7 //===----------------------------------------------------------------------===//
|
|
8
|
|
9 #ifndef LLD_MACHO_OUTPUT_SEGMENT_H
|
|
10 #define LLD_MACHO_OUTPUT_SEGMENT_H
|
|
11
|
|
12 #include "OutputSection.h"
|
|
13 #include "lld/Common/LLVM.h"
|
207
|
14
|
|
15 #include <limits>
|
|
16 #include <vector>
|
173
|
17
|
|
18 namespace lld {
|
|
19 namespace macho {
|
|
20
|
|
21 namespace segment_names {
|
|
22
|
207
|
23 constexpr const char dataConst[] = "__DATA_CONST";
|
|
24 constexpr const char dataDirty[] = "__DATA_DIRTY";
|
|
25 constexpr const char data[] = "__DATA";
|
|
26 constexpr const char dwarf[] = "__DWARF";
|
|
27 constexpr const char import[] = "__IMPORT";
|
|
28 constexpr const char ld[] = "__LD"; // output only with -r
|
|
29 constexpr const char linkEdit[] = "__LINKEDIT";
|
|
30 constexpr const char llvm[] = "__LLVM";
|
|
31 constexpr const char pageZero[] = "__PAGEZERO";
|
|
32 constexpr const char textExec[] = "__TEXT_EXEC";
|
|
33 constexpr const char text[] = "__TEXT";
|
173
|
34
|
|
35 } // namespace segment_names
|
|
36
|
|
37 class OutputSection;
|
|
38 class InputSection;
|
|
39
|
|
40 class OutputSegment {
|
|
41 public:
|
207
|
42 const OutputSection *firstSection() const { return sections.front(); }
|
|
43 const OutputSection *lastSection() const { return sections.back(); }
|
173
|
44
|
207
|
45 void addOutputSection(OutputSection *os);
|
|
46 void sortOutputSections();
|
173
|
47
|
207
|
48 const std::vector<OutputSection *> &getSections() const { return sections; }
|
173
|
49 size_t numNonHiddenSections() const;
|
|
50
|
|
51 uint64_t fileOff = 0;
|
207
|
52 uint64_t fileSize = 0;
|
|
53 uint64_t vmSize = 0;
|
|
54 int inputOrder = std::numeric_limits<int>::max();
|
173
|
55 StringRef name;
|
|
56 uint32_t maxProt = 0;
|
|
57 uint32_t initProt = 0;
|
|
58 uint8_t index;
|
|
59
|
|
60 private:
|
207
|
61 std::vector<OutputSection *> sections;
|
173
|
62 };
|
|
63
|
|
64 extern std::vector<OutputSegment *> outputSegments;
|
|
65
|
207
|
66 void sortOutputSegments();
|
|
67
|
173
|
68 OutputSegment *getOrCreateOutputSegment(StringRef name);
|
|
69
|
|
70 } // namespace macho
|
|
71 } // namespace lld
|
|
72
|
|
73 #endif
|