[mlir] Attempt to resolve edge cases in PassPipeline textual format (#118877)
[llvm-project.git] / lld / MachO / Sections.cpp
bloba27d902c0a227315e77b8f97342223bba6e8874f
1 //===- Sections.cpp ---------------------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "Sections.h"
10 #include "InputSection.h"
11 #include "OutputSegment.h"
13 #include "llvm/ADT/StringSwitch.h"
15 using namespace llvm;
16 using namespace llvm::MachO;
18 namespace lld::macho::sections {
19 bool isCodeSection(StringRef name, StringRef segName, uint32_t flags) {
20 uint32_t type = sectionType(flags);
21 if (type != S_REGULAR && type != S_COALESCED)
22 return false;
24 uint32_t attr = flags & SECTION_ATTRIBUTES_USR;
25 if (attr == S_ATTR_PURE_INSTRUCTIONS)
26 return true;
28 if (segName == segment_names::text)
29 return StringSwitch<bool>(name)
30 .Cases(section_names::textCoalNt, section_names::staticInit, true)
31 .Default(false);
33 return false;
36 } // namespace lld::macho::sections