Index: include/lld/Core/DefinedAtom.h =================================================================== --- include/lld/Core/DefinedAtom.h +++ include/lld/Core/DefinedAtom.h @@ -173,13 +173,6 @@ sectionCustomRequired // linker must place in specific section }; - enum SectionPosition { - sectionPositionStart, // atom must be at start of section (and zero size) - sectionPositionEarly, // atom should be near start of section - sectionPositionAny, // atom can be anywhere in section - sectionPositionEnd // atom must be at end of section (and zero size) - }; - enum DeadStripKind { deadStripNormal, // linker may dead strip this atom deadStripNever, // linker must never dead strip this atom @@ -273,9 +266,6 @@ virtual StringRef customSectionName() const = 0; /// \brief constraints on whether the linker may dead strip away this atom. - virtual SectionPosition sectionPosition() const = 0; - - /// \brief constraints on whether the linker may dead strip away this atom. virtual DeadStripKind deadStrip() const = 0; /// \brief Under which conditions should this atom be dynamically exported. Index: include/lld/Core/Simple.h =================================================================== --- include/lld/Core/Simple.h +++ include/lld/Core/Simple.h @@ -199,10 +199,6 @@ return DefinedAtom::sectionBasedOnContent; } - SectionPosition sectionPosition() const override { - return DefinedAtom::sectionPositionAny; - } - StringRef customSectionName() const override { return StringRef(); } DeadStripKind deadStrip() const override { return DefinedAtom::deadStripNormal; Index: lib/Core/Resolver.cpp =================================================================== --- lib/Core/Resolver.cpp +++ lib/Core/Resolver.cpp @@ -182,11 +182,6 @@ << atom.name() << "\n"); - // Verify on zero-size atoms are pinned to start or end of section. - assert((atom.sectionPosition() != DefinedAtom::sectionPositionStart && - atom.sectionPosition() != DefinedAtom::sectionPositionEnd) || - atom.size() == 0); - // add to list of known atoms _atoms.push_back(&atom); Index: lib/ReaderWriter/CoreLinkingContext.cpp =================================================================== --- lib/ReaderWriter/CoreLinkingContext.cpp +++ lib/ReaderWriter/CoreLinkingContext.cpp @@ -51,8 +51,6 @@ StringRef customSectionName() const override { return StringRef(); } - SectionPosition sectionPosition() const override { return sectionPositionAny; } - DeadStripKind deadStrip() const override { return DefinedAtom::deadStripNormal; } @@ -114,8 +112,6 @@ StringRef customSectionName() const override { return StringRef(); } - SectionPosition sectionPosition() const override { return sectionPositionAny; } - DeadStripKind deadStrip() const override { return DefinedAtom::deadStripNormal; } Index: lib/ReaderWriter/ELF/Atoms.h =================================================================== --- lib/ReaderWriter/ELF/Atoms.h +++ lib/ReaderWriter/ELF/Atoms.h @@ -335,10 +335,6 @@ return _sectionName; } - SectionPosition sectionPosition() const override { - return sectionPositionAny; - } - // It isn't clear that __attribute__((used)) is transmitted to the ELF object // file. DeadStripKind deadStrip() const override { return deadStripNormal; } @@ -496,10 +492,6 @@ StringRef customSectionName() const override { return _sectionName; } - SectionPosition sectionPosition() const override { - return sectionPositionAny; - } - DeadStripKind deadStrip() const override { return deadStripNormal; } ContentPermissions permissions() const override { return permR__; } @@ -577,10 +569,6 @@ StringRef customSectionName() const override { return ".bss"; } - SectionPosition sectionPosition() const override { - return sectionPositionAny; - } - DeadStripKind deadStrip() const override { return deadStripNormal; } ContentPermissions permissions() const override { return permRW_; } Index: lib/ReaderWriter/MachO/LayoutPass.cpp =================================================================== --- lib/ReaderWriter/MachO/LayoutPass.cpp +++ lib/ReaderWriter/MachO/LayoutPass.cpp @@ -166,13 +166,12 @@ #endif // #ifndef NDEBUG /// The function compares atoms by sorting atoms in the following order -/// a) Sorts atoms by Section position preference -/// b) Sorts atoms by their ordinal overrides (layout-after/ingroup) -/// c) Sorts atoms by their permissions -/// d) Sorts atoms by their content -/// e) Sorts atoms by custom sorter -/// f) Sorts atoms on how they appear using File Ordinality -/// g) Sorts atoms on how they appear within the File +/// a) Sorts atoms by their ordinal overrides (layout-after/ingroup) +/// b) Sorts atoms by their permissions +/// c) Sorts atoms by their content +/// d) Sorts atoms by custom sorter +/// e) Sorts atoms on how they appear using File Ordinality +/// f) Sorts atoms on how they appear within the File static bool compareAtomsSub(const LayoutPass::SortKey &lc, const LayoutPass::SortKey &rc, LayoutPass::SortOverride customSorter, @@ -184,19 +183,6 @@ return false; } - // Sort by section position preference. - DefinedAtom::SectionPosition leftPos = left->sectionPosition(); - DefinedAtom::SectionPosition rightPos = right->sectionPosition(); - - bool leftSpecialPos = (leftPos != DefinedAtom::sectionPositionAny); - bool rightSpecialPos = (rightPos != DefinedAtom::sectionPositionAny); - if (leftSpecialPos || rightSpecialPos) { - if (leftPos != rightPos) { - DEBUG(reason = formatReason("sectionPos", (int)leftPos, (int)rightPos)); - return leftPos < rightPos; - } - } - // Find the root of the chain if it is a part of a follow-on chain. const DefinedAtom *leftRoot = lc._root; const DefinedAtom *rightRoot = rc._root; Index: lib/ReaderWriter/Native/NativeFileFormat.h =================================================================== --- lib/ReaderWriter/Native/NativeFileFormat.h +++ lib/ReaderWriter/Native/NativeFileFormat.h @@ -151,7 +151,7 @@ uint8_t interposable; uint8_t merge; uint8_t contentType; - uint8_t sectionChoiceAndPosition; // high nibble is choice, low is position + uint8_t sectionChoice; uint8_t deadStrip; uint8_t dynamicExport; uint8_t permissions; Index: lib/ReaderWriter/Native/ReaderNative.cpp =================================================================== --- lib/ReaderWriter/Native/ReaderNative.cpp +++ lib/ReaderWriter/Native/ReaderNative.cpp @@ -71,17 +71,11 @@ } DefinedAtom::SectionChoice sectionChoice() const override { - return (DefinedAtom::SectionChoice)( - attributes().sectionChoiceAndPosition >> 4); + return (DefinedAtom::SectionChoice)(attributes().sectionChoice); } StringRef customSectionName() const override; - SectionPosition sectionPosition() const override { - return (DefinedAtom::SectionPosition)( - attributes().sectionChoiceAndPosition & 0xF); - } - DefinedAtom::DeadStripKind deadStrip() const override { return (DefinedAtom::DeadStripKind)(attributes().deadStrip); } Index: lib/ReaderWriter/Native/WriterNative.cpp =================================================================== --- lib/ReaderWriter/Native/WriterNative.cpp +++ lib/ReaderWriter/Native/WriterNative.cpp @@ -422,8 +422,7 @@ attrs.interposable = atom.interposable(); attrs.merge = atom.merge(); attrs.contentType = atom.contentType(); - attrs.sectionChoiceAndPosition - = atom.sectionChoice() << 4 | atom.sectionPosition(); + attrs.sectionChoice = atom.sectionChoice(); attrs.deadStrip = atom.deadStrip(); attrs.dynamicExport = atom.dynamicExport(); attrs.codeModel = atom.codeModel(); Index: lib/ReaderWriter/PECOFF/Atoms.h =================================================================== --- lib/ReaderWriter/PECOFF/Atoms.h +++ lib/ReaderWriter/PECOFF/Atoms.h @@ -99,9 +99,6 @@ Merge merge() const override { return mergeNo; } Alignment alignment() const override { return Alignment(0); } StringRef customSectionName() const override { return ""; } - SectionPosition sectionPosition() const override { - return sectionPositionAny; - } DeadStripKind deadStrip() const override { return deadStripNormal; } Kind getKind() const { return _kind; } Index: lib/ReaderWriter/YAML/ReaderWriterYAML.cpp =================================================================== --- lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -332,15 +332,6 @@ } }; -template <> struct ScalarEnumerationTraits { - static void enumeration(IO &io, lld::DefinedAtom::SectionPosition &value) { - io.enumCase(value, "start", lld::DefinedAtom::sectionPositionStart); - io.enumCase(value, "early", lld::DefinedAtom::sectionPositionEarly); - io.enumCase(value, "any", lld::DefinedAtom::sectionPositionAny); - io.enumCase(value, "end", lld::DefinedAtom::sectionPositionEnd); - } -}; - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, lld::DefinedAtom::Interposable &value) { io.enumCase(value, "no", DefinedAtom::interposeNo); @@ -810,7 +801,6 @@ _scope(atom->scope()), _interpose(atom->interposable()), _merge(atom->merge()), _contentType(atom->contentType()), _alignment(atom->alignment()), _sectionChoice(atom->sectionChoice()), - _sectionPosition(atom->sectionPosition()), _deadStrip(atom->deadStrip()), _dynamicExport(atom->dynamicExport()), _codeModel(atom->codeModel()), _permissions(atom->permissions()), _size(atom->size()), @@ -862,7 +852,6 @@ SectionChoice sectionChoice() const override { return _sectionChoice; } StringRef customSectionName() const override { return _sectionName; } uint64_t sectionSize() const override { return _sectionSize; } - SectionPosition sectionPosition() const override { return _sectionPosition; } DeadStripKind deadStrip() const override { return _deadStrip; } DynamicExport dynamicExport() const override { return _dynamicExport; } CodeModel codeModel() const override { return _codeModel; } @@ -908,7 +897,6 @@ ContentType _contentType; Alignment _alignment; SectionChoice _sectionChoice; - SectionPosition _sectionPosition; DeadStripKind _deadStrip; DynamicExport _dynamicExport; CodeModel _codeModel; @@ -954,8 +942,6 @@ io.mapOptional("section-choice", keys->_sectionChoice, DefinedAtom::sectionBasedOnContent); io.mapOptional("section-name", keys->_sectionName, StringRef()); - io.mapOptional("section-position", keys->_sectionPosition, - DefinedAtom::sectionPositionAny); io.mapOptional("section-size", keys->_sectionSize, (uint64_t)0); io.mapOptional("dead-strip", keys->_deadStrip, DefinedAtom::deadStripNormal);