Mercurial > hg > CbC > CbC_llvm
diff lld/MachO/OutputSection.h @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | 5f17cb93ff66 |
line wrap: on
line diff
--- a/lld/MachO/OutputSection.h Mon May 25 11:55:54 2020 +0900 +++ b/lld/MachO/OutputSection.h Tue Jun 08 06:07:14 2021 +0900 @@ -12,6 +12,8 @@ #include "lld/Common/LLVM.h" #include "llvm/ADT/DenseMap.h" +#include <limits> + namespace lld { namespace macho { @@ -25,7 +27,7 @@ class OutputSection { public: enum Kind { - MergedKind, + ConcatKind, SyntheticKind, }; @@ -37,7 +39,7 @@ uint64_t getSegmentOffset() const; // How much space the section occupies in the address space. - virtual size_t getSize() const = 0; + virtual uint64_t getSize() const = 0; // How much space the section occupies in the file. Most sections are copied // as-is so their file size is the same as their address space size. virtual uint64_t getFileSize() const { return getSize(); } @@ -47,10 +49,6 @@ // Unneeded sections are omitted entirely (header and body). virtual bool isNeeded() const { return true; } - // Some sections may allow coalescing other raw input sections. - virtual void mergeInput(InputSection *input); - - // Specifically finalizes addresses and section size, not content. virtual void finalize() { // TODO investigate refactoring synthetic section finalization logic into // overrides of this function. @@ -60,49 +58,23 @@ StringRef name; OutputSegment *parent = nullptr; + // For output sections that don't have explicit ordering requirements, their + // output order should be based on the order of the input sections they + // contain. + int inputOrder = std::numeric_limits<int>::max(); uint32_t index = 0; uint64_t addr = 0; uint64_t fileOff = 0; uint32_t align = 1; uint32_t flags = 0; + uint32_t reserved1 = 0; + uint32_t reserved2 = 0; private: Kind sectionKind; }; -class OutputSectionComparator { -public: - OutputSectionComparator(uint32_t segmentOrder, - const std::vector<StringRef> §Ordering) - : segmentOrder(segmentOrder) { - for (uint32_t j = 0, m = sectOrdering.size(); j < m; ++j) - sectionOrdering[sectOrdering[j]] = j; - } - - uint32_t sectionOrder(StringRef secname) { - auto sectIt = sectionOrdering.find(secname); - if (sectIt != sectionOrdering.end()) - return sectIt->second; - return sectionOrdering.size(); - } - - // Sort sections within a common segment, which stores them in - // a MapVector of section name -> section - bool operator()(const std::pair<StringRef, OutputSection *> &a, - const std::pair<StringRef, OutputSection *> &b) { - return sectionOrder(a.first) < sectionOrder(b.first); - } - - bool operator<(const OutputSectionComparator &b) { - return segmentOrder < b.segmentOrder; - } - -private: - uint32_t segmentOrder; - llvm::DenseMap<StringRef, uint32_t> sectionOrdering; -}; - } // namespace macho } // namespace lld