Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / MachO / OutputSegment.h
blob7a0c4a2065a15be9acb64bf4ad4490c987150ba5
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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_MACHO_OUTPUT_SEGMENT_H
10 #define LLD_MACHO_OUTPUT_SEGMENT_H
12 #include "OutputSection.h"
13 #include "Symbols.h"
14 #include "lld/Common/LLVM.h"
15 #include "llvm/ADT/TinyPtrVector.h"
17 #include <limits>
18 #include <vector>
20 namespace lld::macho {
22 namespace segment_names {
24 constexpr const char dataConst[] = "__DATA_CONST";
25 constexpr const char dataDirty[] = "__DATA_DIRTY";
26 constexpr const char data[] = "__DATA";
27 constexpr const char dwarf[] = "__DWARF";
28 constexpr const char import[] = "__IMPORT";
29 constexpr const char ld[] = "__LD"; // output only with -r
30 constexpr const char linkEdit[] = "__LINKEDIT";
31 constexpr const char llvm[] = "__LLVM";
32 constexpr const char pageZero[] = "__PAGEZERO";
33 constexpr const char textExec[] = "__TEXT_EXEC";
34 constexpr const char text[] = "__TEXT";
36 } // namespace segment_names
38 class OutputSection;
39 class InputSection;
41 class OutputSegment {
42 public:
43 void addOutputSection(OutputSection *os);
44 void sortOutputSections();
45 void assignAddressesToStartEndSymbols();
47 const std::vector<OutputSection *> &getSections() const { return sections; }
48 size_t numNonHiddenSections() const;
50 uint64_t fileOff = 0;
51 uint64_t fileSize = 0;
52 uint64_t addr = 0;
53 uint64_t vmSize = 0;
54 int inputOrder = UnspecifiedInputOrder;
55 StringRef name;
56 uint32_t maxProt = 0;
57 uint32_t initProt = 0;
58 uint32_t flags = 0;
59 uint8_t index;
61 llvm::TinyPtrVector<Defined *> segmentStartSymbols;
62 llvm::TinyPtrVector<Defined *> segmentEndSymbols;
64 private:
65 std::vector<OutputSection *> sections;
68 extern std::vector<OutputSegment *> outputSegments;
70 void sortOutputSegments();
71 void resetOutputSegments();
73 OutputSegment *getOrCreateOutputSegment(StringRef name);
75 } // namespace lld::macho
77 #endif