1 //===- Sections.cpp ---------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
10 #include "InputSection.h"
11 #include "OutputSegment.h"
13 #include "llvm/ADT/StringSwitch.h"
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
)
24 uint32_t attr
= flags
& SECTION_ATTRIBUTES_USR
;
25 if (attr
== S_ATTR_PURE_INSTRUCTIONS
)
28 if (segName
== segment_names::text
)
29 return StringSwitch
<bool>(name
)
30 .Cases(section_names::textCoalNt
, section_names::staticInit
, true)
36 } // namespace lld::macho::sections