13d4e9d5eSLang Hames //===---------- ObjectFormats.cpp - Object format details for ORC ---------===// 23d4e9d5eSLang Hames // 33d4e9d5eSLang Hames // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43d4e9d5eSLang Hames // See https://llvm.org/LICENSE.txt for license information. 53d4e9d5eSLang Hames // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63d4e9d5eSLang Hames // 73d4e9d5eSLang Hames //===----------------------------------------------------------------------===// 83d4e9d5eSLang Hames // 93d4e9d5eSLang Hames // ORC-specific object format details. 103d4e9d5eSLang Hames // 113d4e9d5eSLang Hames //===----------------------------------------------------------------------===// 123d4e9d5eSLang Hames 133d4e9d5eSLang Hames #include "llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h" 143d4e9d5eSLang Hames 153d4e9d5eSLang Hames namespace llvm { 163d4e9d5eSLang Hames namespace orc { 173d4e9d5eSLang Hames 183d4e9d5eSLang Hames StringRef ELFEHFrameSectionName = ".eh_frame"; 19e76ac807SJeff Niu 203d4e9d5eSLang Hames StringRef ELFInitArrayFuncSectionName = ".init_array"; 21e76ac807SJeff Niu StringRef ELFInitFuncSectionName = ".init"; 22e76ac807SJeff Niu StringRef ELFFiniArrayFuncSectionName = ".fini_array"; 23e76ac807SJeff Niu StringRef ELFFiniFuncSectionName = ".fini"; 24e76ac807SJeff Niu StringRef ELFCtorArrayFuncSectionName = ".ctors"; 25e76ac807SJeff Niu StringRef ELFDtorArrayFuncSectionName = ".dtors"; 26e76ac807SJeff Niu 27e76ac807SJeff Niu StringRef ELFInitSectionNames[3]{ 28e76ac807SJeff Niu ELFInitArrayFuncSectionName, 29e76ac807SJeff Niu ELFInitFuncSectionName, 30e76ac807SJeff Niu ELFCtorArrayFuncSectionName, 31e76ac807SJeff Niu }; 323d4e9d5eSLang Hames 333d4e9d5eSLang Hames StringRef ELFThreadBSSSectionName = ".tbss"; 343d4e9d5eSLang Hames StringRef ELFThreadDataSectionName = ".tdata"; 353d4e9d5eSLang Hames 363d4e9d5eSLang Hames bool isMachOInitializerSection(StringRef QualifiedName) { 373d4e9d5eSLang Hames for (auto &InitSection : MachOInitSectionNames) 383d4e9d5eSLang Hames if (InitSection == QualifiedName) 393d4e9d5eSLang Hames return true; 403d4e9d5eSLang Hames return false; 413d4e9d5eSLang Hames } 423d4e9d5eSLang Hames 433d4e9d5eSLang Hames bool isELFInitializerSection(StringRef SecName) { 44e76ac807SJeff Niu for (StringRef InitSection : ELFInitSectionNames) { 45e76ac807SJeff Niu StringRef Name = SecName; 46e76ac807SJeff Niu if (Name.consume_front(InitSection) && (Name.empty() || Name[0] == '.')) 473d4e9d5eSLang Hames return true; 48e76ac807SJeff Niu } 493d4e9d5eSLang Hames return false; 503d4e9d5eSLang Hames } 513d4e9d5eSLang Hames 523d4e9d5eSLang Hames bool isCOFFInitializerSection(StringRef SecName) { 53*586ecdf2SKazu Hirata return SecName.starts_with(".CRT"); 543d4e9d5eSLang Hames } 553d4e9d5eSLang Hames 563d4e9d5eSLang Hames } // namespace orc 573d4e9d5eSLang Hames } // namespace llvm 58