From 39c673c4b04036809f0fe6932ff468f12579e340 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Mon, 29 Jul 2024 12:19:09 +0800 Subject: [PATCH] =?UTF-8?q?so=E6=B2=99=E7=9B=92=E6=9D=83=E9=99=90=E6=95=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=B0=86dlopen=E4=B8=AD=E7=9A=84=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../src/componentloader/component_loader.cpp | 18 ++++-------------- utils/src/histreamer_query_tool.cpp | 8 ++------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp index f9a6165e..1e48f281 100644 --- a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp @@ -66,12 +66,6 @@ const std::string DEFAULT_LOC = ""; const int32_t DEFAULT_SA_ID = -1; const std::string DEFAULT_VERSION = "1.0"; -#ifdef __LP64__ -const std::string LIB_LOAD_PATH = "/system/lib64/"; -#else -const std::string LIB_LOAD_PATH = "/system/lib/"; -#endif - std::map g_mapDhTypeName = { { "UNKNOWN", DHType::UNKNOWN }, { "CAMERA", DHType::CAMERA }, @@ -371,17 +365,13 @@ void ComponentLoader::StoreLocalDHVersionInDB() void *ComponentLoader::GetHandler(const std::string &soName) { - char path[PATH_MAX + 1] = {0x00}; - if (soName.length() == 0 || (LIB_LOAD_PATH.length() + soName.length()) > PATH_MAX || - realpath((LIB_LOAD_PATH + soName).c_str(), path) == nullptr) { - std::string loadPath(path); - DHLOGE("File canonicalization failed, soName:%{public}s, path:%{public}s", soName.c_str(), - GetAnonyString(loadPath).c_str()); + if (soName.length() == 0 || soName.length() > PATH_MAX) { + DHLOGE("File canonicalization failed, soName: %{public}s", soName.c_str()); return nullptr; } - void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(soName.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); + DHLOGE("so: %{public}s load failed, failed reason: %{public}s", soName.c_str(), dlerror()); HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "dhfwk so open failed, soname : " + soName); return nullptr; diff --git a/utils/src/histreamer_query_tool.cpp b/utils/src/histreamer_query_tool.cpp index 63f5eb21..86a6ff5d 100644 --- a/utils/src/histreamer_query_tool.cpp +++ b/utils/src/histreamer_query_tool.cpp @@ -40,11 +40,7 @@ const std::string QueryVideoDecoderFuncName = "QueryVideoDecoderAbilityStr"; const uint32_t MAX_MESSAGES_LEN = 1 * 1024 * 1024; -#ifdef __LP64__ -const std::string LIB_LOAD_PATH = "/system/lib64/libhistreamer_ability_querier.z.so"; -#else -const std::string LIB_LOAD_PATH = "/system/lib/libhistreamer_ability_querier.z.so"; -#endif +const std::string LOAD_SO = "libhistreamer_ability_querier.z.so"; void HiStreamerQueryTool::Init() { @@ -52,7 +48,7 @@ void HiStreamerQueryTool::Init() return; } DHLOGI("Start Init HiStreamer Query SO"); - void *pHandler = dlopen(LIB_LOAD_PATH.c_str(), RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(LOAD_SO.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { DHLOGE("libhistreamer_ability_querier.z.so handler load failed, failed reason : %{public}s", dlerror()); return; -- Gitee