diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index a41c37e9b34691283028495f8edeaff677399be3..2e2c26c32d9da184d78f787c33e9df6551d1cdf8 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -112,14 +112,22 @@ ohos_shared_library("distributed_av_receiver") { "//build/config/compiler:no_rtti", "//build/config/compiler:no_exceptions", ] + cflags = [ "-O2", "-fPIC", "-Wall", "-fexceptions", + "-fstack-protector-strong", ] cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + part_name = "distributed_hardware_fwk" subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index 02c2c58265b64a0a8b33154f4400237326fda852..37a4483c1f13c606994c2dde93dc043c694b8b3a 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -106,14 +106,22 @@ ohos_shared_library("distributed_av_sender") { "//build/config/compiler:no_rtti", "//build/config/compiler:no_exceptions", ] + cflags = [ "-O2", "-fPIC", "-Wall", "-fexceptions", + "-fstack-protector-strong", ] cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + part_name = "distributed_hardware_fwk" subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn b/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn index 2abf00976a356210eb792c9436a514aef447ca25..cf00397a6f5a6a519a753b58502e5a469187ca89 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn +++ b/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -72,10 +72,17 @@ ohos_shared_library("histreamer_ability_querier") { "-fexceptions", "-Wno-unused-but-set-variable", "-Wno-format", + "-fstack-protector-strong", ] cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + remove_configs = [ "//build/config/compiler:no_rtti", "//build/config/compiler:no_exceptions", diff --git a/av_transport/framework/BUILD.gn b/av_transport/framework/BUILD.gn index e9285316fed92473db541f310d3beef9d5817ef2..c4672acfd16b107865b49405e47578d504e87dba 100644 --- a/av_transport/framework/BUILD.gn +++ b/av_transport/framework/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -85,9 +85,16 @@ ohos_shared_library("distributed_av_pipeline_fwk") { "-O2", "-Wall", "-Wno-c++20-extensions", + "-fstack-protector-strong", ] cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + part_name = "distributed_hardware_fwk" subsystem_name = "distributedhardware" } diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 998f56396bb16070ffd770ddc0b06659f2fea866..cf6108c5704657b599b5cb38633e8165d66f1517 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -90,6 +90,12 @@ ohos_shared_library("libdhfwk_sdk") { "-O2", ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + subsystem_name = "distributedhardware" part_name = "distributed_hardware_fwk" diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 55425a977a158121be905c7c4328ac45e09bf189..e5ad6f8d9921e5efdd9427c1786178b8ffb4d62f 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -15,6 +15,13 @@ import("//build/ohos.gni") import("../../../distributedhardwarefwk.gni") ohos_shared_library("hardwaremanager") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + branch_protector_ret = "pac_ret" + include_dirs = [ "include", "${common_path}/log/include", @@ -52,6 +59,12 @@ ohos_shared_library("hardwaremanager") { cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index ea3349e6c91061ec1828e132447fee9cfa8017ed..b3b10248826c76e97230e7fc53f7f0620a5fac2e 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -129,6 +129,12 @@ ohos_shared_library("distributedhardwarefwksvr") { cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + if (distributed_hardware_fwk_low_latency) { defines += [ "DHARDWARE_LOW_LATENCY" ] } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 3a30e04bed50c72ce3c650a2c4b58a970bda04e2..4ffdda813305fa4a1ebd019f2380dadf515a09b2 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -66,6 +66,12 @@ ohos_shared_library("distributedhardwareutils") { cflags_cc = cflags + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "cJSON:cjson", "c_utils:utils",