18e920a95Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
28e920a95Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
38e920a95Sopenharmony_ci# you may not use this file except in compliance with the License.
48e920a95Sopenharmony_ci# You may obtain a copy of the License at
58e920a95Sopenharmony_ci#
68e920a95Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
78e920a95Sopenharmony_ci#
88e920a95Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
98e920a95Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
108e920a95Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118e920a95Sopenharmony_ci# See the License for the specific language governing permissions and
128e920a95Sopenharmony_ci# limitations under the License.
138e920a95Sopenharmony_ci
148e920a95Sopenharmony_ciimport("//build/ohos.gni")
158e920a95Sopenharmony_ciimport("../../../code_signature.gni")
168e920a95Sopenharmony_ci
178e920a95Sopenharmony_ciconfig("public_jit_code_sign_configs") {
188e920a95Sopenharmony_ci  include_dirs = [ "include" ]
198e920a95Sopenharmony_ci}
208e920a95Sopenharmony_ci
218e920a95Sopenharmony_ciconfig("private_jit_code_sign_configs") {
228e920a95Sopenharmony_ci  cflags = [ "-march=armv8.4-a" ]
238e920a95Sopenharmony_ci  defines = [ "ARCH_PAC_SUPPORT" ]
248e920a95Sopenharmony_ci}
258e920a95Sopenharmony_ci
268e920a95Sopenharmony_ciohos_source_set("pac_sign_feature") {
278e920a95Sopenharmony_ci  sources = [ "src/pac_sign_ctx.cpp" ]
288e920a95Sopenharmony_ci  sanitize = {
298e920a95Sopenharmony_ci    cfi = true
308e920a95Sopenharmony_ci    cfi_cross_dso = true
318e920a95Sopenharmony_ci    debug = false
328e920a95Sopenharmony_ci  }
338e920a95Sopenharmony_ci  branch_protector_ret = "pac_ret"
348e920a95Sopenharmony_ci  public_configs = [
358e920a95Sopenharmony_ci    ":public_jit_code_sign_configs",
368e920a95Sopenharmony_ci    "${code_signature_root_dir}:common_public_config",
378e920a95Sopenharmony_ci  ]
388e920a95Sopenharmony_ci  configs = [
398e920a95Sopenharmony_ci    ":private_jit_code_sign_configs",
408e920a95Sopenharmony_ci    "${code_signature_root_dir}:common_utils_config",
418e920a95Sopenharmony_ci  ]
428e920a95Sopenharmony_ci  external_deps = [
438e920a95Sopenharmony_ci    "bounds_checking_function:libsec_shared",
448e920a95Sopenharmony_ci    "hilog:libhilog",
458e920a95Sopenharmony_ci  ]
468e920a95Sopenharmony_ci  part_name = "code_signature"
478e920a95Sopenharmony_ci  subsystem_name = "security"
488e920a95Sopenharmony_ci}
498e920a95Sopenharmony_ci
508e920a95Sopenharmony_ciohos_shared_library("libjit_code_sign") {
518e920a95Sopenharmony_ci  sources = [ "src/jit_code_signer_factory.cpp" ]
528e920a95Sopenharmony_ci  if (jit_code_sign_enable) {
538e920a95Sopenharmony_ci    defines = [ "JIT_CODE_SIGN_ENABLE" ]
548e920a95Sopenharmony_ci    sources += [
558e920a95Sopenharmony_ci      "src/jit_code_signer_base.cpp",
568e920a95Sopenharmony_ci      "src/jit_code_signer_hybrid.cpp",
578e920a95Sopenharmony_ci      "src/jit_code_signer_single.cpp",
588e920a95Sopenharmony_ci    ]
598e920a95Sopenharmony_ci    deps = [ ":pac_sign_feature" ]
608e920a95Sopenharmony_ci  }
618e920a95Sopenharmony_ci  cflags_cc = [
628e920a95Sopenharmony_ci    "-Os",
638e920a95Sopenharmony_ci    "-fno-asynchronous-unwind-tables",
648e920a95Sopenharmony_ci    "-fno-unwind-tables",
658e920a95Sopenharmony_ci  ]
668e920a95Sopenharmony_ci  branch_protector_ret = "pac_ret"
678e920a95Sopenharmony_ci  sanitize = {
688e920a95Sopenharmony_ci    cfi = true
698e920a95Sopenharmony_ci    cfi_cross_dso = true
708e920a95Sopenharmony_ci    debug = false
718e920a95Sopenharmony_ci  }
728e920a95Sopenharmony_ci  public_configs = [
738e920a95Sopenharmony_ci    ":public_jit_code_sign_configs",
748e920a95Sopenharmony_ci    "${code_signature_root_dir}:common_public_config",
758e920a95Sopenharmony_ci  ]
768e920a95Sopenharmony_ci  configs = [ "${code_signature_root_dir}:common_utils_config" ]
778e920a95Sopenharmony_ci  external_deps = [
788e920a95Sopenharmony_ci    "bounds_checking_function:libsec_shared",
798e920a95Sopenharmony_ci    "hilog:libhilog",
808e920a95Sopenharmony_ci  ]
818e920a95Sopenharmony_ci  part_name = "code_signature"
828e920a95Sopenharmony_ci  subsystem_name = "security"
838e920a95Sopenharmony_ci}
84