annotate lld/lib/Core/DefinedAtom.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===- DefinedAtom.cpp ------------------------------------------*- C++ -*-===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #include "llvm/Support/ErrorHandling.h"
anatofuz
parents:
diff changeset
10 #include "lld/Core/DefinedAtom.h"
anatofuz
parents:
diff changeset
11 #include "lld/Core/File.h"
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 namespace lld {
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 DefinedAtom::ContentPermissions DefinedAtom::permissions() const {
anatofuz
parents:
diff changeset
16 // By default base permissions on content type.
anatofuz
parents:
diff changeset
17 return permissions(this->contentType());
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 // Utility function for deriving permissions from content type
anatofuz
parents:
diff changeset
21 DefinedAtom::ContentPermissions DefinedAtom::permissions(ContentType type) {
anatofuz
parents:
diff changeset
22 switch (type) {
anatofuz
parents:
diff changeset
23 case typeCode:
anatofuz
parents:
diff changeset
24 case typeResolver:
anatofuz
parents:
diff changeset
25 case typeBranchIsland:
anatofuz
parents:
diff changeset
26 case typeBranchShim:
anatofuz
parents:
diff changeset
27 case typeStub:
anatofuz
parents:
diff changeset
28 case typeStubHelper:
anatofuz
parents:
diff changeset
29 case typeMachHeader:
anatofuz
parents:
diff changeset
30 return permR_X;
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 case typeConstant:
anatofuz
parents:
diff changeset
33 case typeCString:
anatofuz
parents:
diff changeset
34 case typeUTF16String:
anatofuz
parents:
diff changeset
35 case typeCFI:
anatofuz
parents:
diff changeset
36 case typeLSDA:
anatofuz
parents:
diff changeset
37 case typeLiteral4:
anatofuz
parents:
diff changeset
38 case typeLiteral8:
anatofuz
parents:
diff changeset
39 case typeLiteral16:
anatofuz
parents:
diff changeset
40 case typeDTraceDOF:
anatofuz
parents:
diff changeset
41 case typeCompactUnwindInfo:
anatofuz
parents:
diff changeset
42 case typeProcessedUnwindInfo:
anatofuz
parents:
diff changeset
43 case typeObjCImageInfo:
anatofuz
parents:
diff changeset
44 case typeObjCMethodList:
anatofuz
parents:
diff changeset
45 return permR__;
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 case typeData:
anatofuz
parents:
diff changeset
48 case typeDataFast:
anatofuz
parents:
diff changeset
49 case typeZeroFill:
anatofuz
parents:
diff changeset
50 case typeZeroFillFast:
anatofuz
parents:
diff changeset
51 case typeObjC1Class:
anatofuz
parents:
diff changeset
52 case typeLazyPointer:
anatofuz
parents:
diff changeset
53 case typeLazyDylibPointer:
anatofuz
parents:
diff changeset
54 case typeNonLazyPointer:
anatofuz
parents:
diff changeset
55 case typeThunkTLV:
anatofuz
parents:
diff changeset
56 return permRW_;
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 case typeGOT:
anatofuz
parents:
diff changeset
59 case typeConstData:
anatofuz
parents:
diff changeset
60 case typeCFString:
anatofuz
parents:
diff changeset
61 case typeInitializerPtr:
anatofuz
parents:
diff changeset
62 case typeTerminatorPtr:
anatofuz
parents:
diff changeset
63 case typeCStringPtr:
anatofuz
parents:
diff changeset
64 case typeObjCClassPtr:
anatofuz
parents:
diff changeset
65 case typeObjC2CategoryList:
anatofuz
parents:
diff changeset
66 case typeInterposingTuples:
anatofuz
parents:
diff changeset
67 case typeTLVInitialData:
anatofuz
parents:
diff changeset
68 case typeTLVInitialZeroFill:
anatofuz
parents:
diff changeset
69 case typeTLVInitializerPtr:
anatofuz
parents:
diff changeset
70 return permRW_L;
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 case typeUnknown:
anatofuz
parents:
diff changeset
73 case typeTempLTO:
anatofuz
parents:
diff changeset
74 case typeSectCreate:
anatofuz
parents:
diff changeset
75 case typeDSOHandle:
anatofuz
parents:
diff changeset
76 return permUnknown;
anatofuz
parents:
diff changeset
77 }
anatofuz
parents:
diff changeset
78 llvm_unreachable("unknown content type");
anatofuz
parents:
diff changeset
79 }
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 } // namespace