brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 5f39734 Raw
79 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLD_MACHO_OUTPUT_SEGMENT_H10#define LLD_MACHO_OUTPUT_SEGMENT_H11 12#include "OutputSection.h"13#include "Symbols.h"14#include "lld/Common/LLVM.h"15#include "llvm/ADT/TinyPtrVector.h"16 17#include <limits>18#include <vector>19 20namespace lld::macho {21 22namespace segment_names {23 24constexpr const char dataConst[] = "__DATA_CONST";25constexpr const char dataDirty[] = "__DATA_DIRTY";26constexpr const char data[] = "__DATA";27constexpr const char dwarf[] = "__DWARF";28constexpr const char import[] = "__IMPORT";29constexpr const char ld[] = "__LD"; // output only with -r30constexpr const char linkEdit[] = "__LINKEDIT";31constexpr const char llvm[] = "__LLVM";32constexpr const char pageZero[] = "__PAGEZERO";33constexpr const char textExec[] = "__TEXT_EXEC";34constexpr const char text[] = "__TEXT";35 36} // namespace segment_names37 38class OutputSection;39class InputSection;40 41class OutputSegment {42public:43  void addOutputSection(OutputSection *os);44  void sortOutputSections();45  void assignAddressesToStartEndSymbols();46 47  const std::vector<OutputSection *> &getSections() const { return sections; }48  size_t numNonHiddenSections() const;49 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;60  bool needsThunks = false;61 62  llvm::TinyPtrVector<Defined *> segmentStartSymbols;63  llvm::TinyPtrVector<Defined *> segmentEndSymbols;64 65private:66  std::vector<OutputSection *> sections;67};68 69extern std::vector<OutputSegment *> outputSegments;70 71void sortOutputSegments();72void resetOutputSegments();73 74OutputSegment *getOrCreateOutputSegment(StringRef name);75 76} // namespace lld::macho77 78#endif79