1 | //===---------- ObjectFormats.cpp - Object format details for ORC ---------===// |
---|---|
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 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // ORC-specific object format details. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h" |
14 | #include "llvm/ADT/STLExtras.h" |
15 | |
16 | namespace llvm { |
17 | namespace orc { |
18 | |
19 | StringRef ELFEHFrameSectionName = ".eh_frame"; |
20 | |
21 | StringRef ELFInitArrayFuncSectionName = ".init_array"; |
22 | StringRef ELFInitFuncSectionName = ".init"; |
23 | StringRef ELFFiniArrayFuncSectionName = ".fini_array"; |
24 | StringRef ELFFiniFuncSectionName = ".fini"; |
25 | StringRef ELFCtorArrayFuncSectionName = ".ctors"; |
26 | StringRef ELFDtorArrayFuncSectionName = ".dtors"; |
27 | |
28 | StringRef ELFInitSectionNames[3]{ |
29 | ELFInitArrayFuncSectionName, |
30 | ELFInitFuncSectionName, |
31 | ELFCtorArrayFuncSectionName, |
32 | }; |
33 | |
34 | StringRef ELFThreadBSSSectionName = ".tbss"; |
35 | StringRef ELFThreadDataSectionName = ".tdata"; |
36 | |
37 | bool isMachOInitializerSection(StringRef QualifiedName) { |
38 | return llvm::is_contained(Range&: MachOInitSectionNames, Element: QualifiedName); |
39 | } |
40 | |
41 | bool isELFInitializerSection(StringRef SecName) { |
42 | for (StringRef InitSection : ELFInitSectionNames) { |
43 | StringRef Name = SecName; |
44 | if (Name.consume_front(Prefix: InitSection) && (Name.empty() || Name[0] == '.')) |
45 | return true; |
46 | } |
47 | return false; |
48 | } |
49 | |
50 | bool isCOFFInitializerSection(StringRef SecName) { |
51 | return SecName.starts_with(Prefix: ".CRT"); |
52 | } |
53 | |
54 | } // namespace orc |
55 | } // namespace llvm |
56 |