1# Copyright (c) 2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("../../../code_signature.gni")
16
17config("public_jit_code_sign_configs") {
18  include_dirs = [ "include" ]
19}
20
21config("private_jit_code_sign_configs") {
22  cflags = [ "-march=armv8.4-a" ]
23  defines = [ "ARCH_PAC_SUPPORT" ]
24}
25
26ohos_source_set("pac_sign_feature") {
27  sources = [ "src/pac_sign_ctx.cpp" ]
28  sanitize = {
29    cfi = true
30    cfi_cross_dso = true
31    debug = false
32  }
33  branch_protector_ret = "pac_ret"
34  public_configs = [
35    ":public_jit_code_sign_configs",
36    "${code_signature_root_dir}:common_public_config",
37  ]
38  configs = [
39    ":private_jit_code_sign_configs",
40    "${code_signature_root_dir}:common_utils_config",
41  ]
42  external_deps = [
43    "bounds_checking_function:libsec_shared",
44    "hilog:libhilog",
45  ]
46  part_name = "code_signature"
47  subsystem_name = "security"
48}
49
50ohos_shared_library("libjit_code_sign") {
51  sources = [ "src/jit_code_signer_factory.cpp" ]
52  if (jit_code_sign_enable) {
53    defines = [ "JIT_CODE_SIGN_ENABLE" ]
54    sources += [
55      "src/jit_code_signer_base.cpp",
56      "src/jit_code_signer_hybrid.cpp",
57      "src/jit_code_signer_single.cpp",
58    ]
59    deps = [ ":pac_sign_feature" ]
60  }
61  branch_protector_ret = "pac_ret"
62  sanitize = {
63    cfi = true
64    cfi_cross_dso = true
65    debug = false
66  }
67  public_configs = [
68    ":public_jit_code_sign_configs",
69    "${code_signature_root_dir}:common_public_config",
70  ]
71  configs = [ "${code_signature_root_dir}:common_utils_config" ]
72  external_deps = [
73    "bounds_checking_function:libsec_shared",
74    "hilog:libhilog",
75  ]
76  part_name = "code_signature"
77  subsystem_name = "security"
78}
79