Path: blob/main/contrib/llvm-project/lld/MachO/Sections.cpp
213726 views
//===- Sections.cpp ---------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "Sections.h"9#include "InputSection.h"10#include "OutputSegment.h"1112#include "llvm/ADT/StringSwitch.h"1314using namespace llvm;15using namespace llvm::MachO;1617namespace lld::macho::sections {18bool isCodeSection(StringRef name, StringRef segName, uint32_t flags) {19uint32_t type = sectionType(flags);20if (type != S_REGULAR && type != S_COALESCED)21return false;2223uint32_t attr = flags & SECTION_ATTRIBUTES_USR;24if (attr == S_ATTR_PURE_INSTRUCTIONS)25return true;2627if (segName == segment_names::text)28return StringSwitch<bool>(name)29.Cases(section_names::textCoalNt, section_names::staticInit, true)30.Default(false);3132return false;33}3435} // namespace lld::macho::sections363738