1 //===- OutputSegment.h ------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_MACHO_OUTPUT_SEGMENT_H
10 #define LLD_MACHO_OUTPUT_SEGMENT_H
12 #include "OutputSection.h"
13 #include "lld/Common/LLVM.h"
18 namespace segment_names {
20 constexpr const char pageZero[] = "__PAGEZERO";
21 constexpr const char text[] = "__TEXT";
22 constexpr const char data[] = "__DATA";
23 constexpr const char linkEdit[] = "__LINKEDIT";
24 constexpr const char dataConst[] = "__DATA_CONST";
26 } // namespace segment_names
33 const OutputSection *firstSection() const { return sections.front(); }
34 const OutputSection *lastSection() const { return sections.back(); }
36 void addOutputSection(OutputSection *os);
37 void sortOutputSections(
38 llvm::function_ref<bool(OutputSection *, OutputSection *)> comparator) {
39 llvm::stable_sort(sections, comparator);
42 const std::vector<OutputSection *> &getSections() const { return sections; }
43 size_t numNonHiddenSections() const;
48 uint32_t initProt = 0;
52 std::vector<OutputSection *> sections;
55 extern std::vector<OutputSegment *> outputSegments;
57 OutputSegment *getOrCreateOutputSegment(StringRef name);