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"
14 #include "lld/Common/LLVM.h"
15 #include "llvm/ADT/TinyPtrVector.h"
23 namespace segment_names
{
25 constexpr const char dataConst
[] = "__DATA_CONST";
26 constexpr const char dataDirty
[] = "__DATA_DIRTY";
27 constexpr const char data
[] = "__DATA";
28 constexpr const char dwarf
[] = "__DWARF";
29 constexpr const char import
[] = "__IMPORT";
30 constexpr const char ld
[] = "__LD"; // output only with -r
31 constexpr const char linkEdit
[] = "__LINKEDIT";
32 constexpr const char llvm
[] = "__LLVM";
33 constexpr const char pageZero
[] = "__PAGEZERO";
34 constexpr const char textExec
[] = "__TEXT_EXEC";
35 constexpr const char text
[] = "__TEXT";
37 } // namespace segment_names
44 void addOutputSection(OutputSection
*os
);
45 void sortOutputSections();
46 void assignAddressesToStartEndSymbols();
48 const std::vector
<OutputSection
*> &getSections() const { return sections
; }
49 size_t numNonHiddenSections() const;
52 uint64_t fileSize
= 0;
55 int inputOrder
= UnspecifiedInputOrder
;
58 uint32_t initProt
= 0;
61 llvm::TinyPtrVector
<Defined
*> segmentStartSymbols
;
62 llvm::TinyPtrVector
<Defined
*> segmentEndSymbols
;
65 std::vector
<OutputSection
*> sections
;
68 extern std::vector
<OutputSegment
*> outputSegments
;
70 void sortOutputSegments();
72 OutputSegment
*getOrCreateOutputSegment(StringRef name
);