Remove libelf dependency from libexec-checker.so 70/264770/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 29 Sep 2021 10:22:44 +0000 (19:22 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 29 Sep 2021 10:22:44 +0000 (19:22 +0900)
Currently, aul has a license problem that conflicts with GPL-2.0+.
This patch removes codes related to libelf library.

TODO:
 - Implement finding main symbol using Elf64_Sym

Change-Id: Ib7e6fef06e3461b156cd4ad35893dbc794c343f1
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
packaging/aul.spec
parser/exec-checker/CMakeLists.txt
parser/exec-checker/src/exec_checker.cc

index 52962fa..bc0e00a 100644 (file)
@@ -52,7 +52,6 @@ PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace)
 PKG_CHECK_MODULES(UUID_DEPS REQUIRED uuid)
 PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
 PKG_CHECK_MODULES(XDGMIME_DEPS REQUIRED xdgmime)
-PKG_CHECK_MODULES(LIBELF_DEPS REQUIRED libelf)
 
 ## Target sources
 AUX_SOURCE_DIRECTORY(src SRCS)
index dbda68e..d6a2132 100644 (file)
@@ -37,7 +37,6 @@ BuildRequires:  pkgconfig(uuid)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  pkgconfig(gmock)
 BuildRequires:  pkgconfig(parcel)
-BuildRequires:  pkgconfig(libelf)
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
index e1b9b95..4716f73 100644 (file)
@@ -20,7 +20,6 @@ APPLY_PKG_CONFIG(${TARGET_CHECK_EXEC_PLUGIN_PARSER} PUBLIC
   LIBXML_DEPS
   PKGMGR_INFO_DEPS
   PKGMGR_INSTALLER_DEPS
-  LIBELF_DEPS
 )
 
 INSTALL(TARGETS ${TARGET_CHECK_EXEC_PLUGIN_PARSER}
index 5ef73c5..de48835 100644 (file)
@@ -18,8 +18,6 @@
 #include <elf.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <gelf.h>
-#include <libelf.h>
 #include <linux/limits.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -86,45 +84,7 @@ bool ExecChecker::IsShared() {
 }
 
 bool ExecChecker::CheckMainSymbol() {
-  int fd = open(path_.c_str(), O_RDONLY);
-  if (fd < 0) {
-    LOGE_STD("Failed to open file(%s). errno(%d)", path_.c_str(), errno);
-    return false;
-  }
-
-  elf_version(EV_CURRENT);
-
-  auto elf_destructor = [fd] (Elf* elf) -> void {
-      close(fd);
-      elf_end(elf);
-    };
-  auto elf = std::unique_ptr<Elf, decltype(elf_destructor)>
-      (elf_begin(fd, ELF_C_READ, nullptr), elf_destructor);
-  if (elf == nullptr) {
-    LOGE_STD("Out of memory");
-    return false;
-  }
-
-  Elf_Scn* scn = nullptr;
-  GElf_Shdr shdr;
-  while ((scn = elf_nextscn(elf.get(), scn)) != nullptr) {
-    gelf_getshdr(scn, &shdr);
-    if (shdr.sh_type == SHT_SYMTAB)
-      break;
-  }
-
-  Elf_Data* data = elf_getdata(scn, nullptr);
-  int count = (shdr.sh_entsize == 0 ? 0 : shdr.sh_size / shdr.sh_entsize);
-
-  for (int i = 0; i < count; ++i) {
-    GElf_Sym sym;
-    gelf_getsym(data, i, &sym);
-    char* symbol = elf_strptr(elf.get(), shdr.sh_link, sym.st_name);
-    if (symbol != nullptr && strcmp("main", symbol) == 0)
-      return true;
-  }
-
-  LOGW_STD("Not found main symbol(%s)", path_.c_str());
+  // TODO: Implement finding main symbol using Elf64_Sym & Elf32_Sym
   return false;
 }