[IMPROVE] Add plt syms search for x86 75/46475/5
authorAlexander Aksenov <a.aksenov@samsung.com>
Fri, 21 Aug 2015 08:53:04 +0000 (11:53 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Fri, 21 Aug 2015 10:27:26 +0000 (13:27 +0300)
Change-Id: I7daef682d4e95204c10d8fec74c97342712ee92b
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
Makefile [new file with mode: 0644]
daemon/Makefile
daemon/cpp/elf/FileElf.cpp
daemon/cpp/elf/FileElf.h
scripts/gen_nsp_data.sh

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..a9eb211
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+START_SH = scripts/start.sh
+STOP_SH = scripts/stop.sh
+TARGET = da_manager
+DASCRIPT = da_command
+
+
+install: BINDIR = $(DESTDIR)/usr/bin
+install: OPTDIR = $(DESTDIR)/opt/swap/sdk
+
index 61c03a7..bc4af9b 100644 (file)
@@ -59,7 +59,8 @@ LDFLAGS := \
        -lecore \
        -lcapi-system-info \
        -lwebsockets \
-       -ljson-c
+       -ljson-c \
+       -lparserelf
 
 # CALL_MNGR
 ifeq ($(CALL_MNGR),y)
index 1c67a02..ce315cf 100644 (file)
@@ -1,7 +1,9 @@
 #include "FileElf.h"
 #include <elf.h>
 #include <cerrno>
+#include <cstring>
 #include "swap_debug.h"
+#include <parse_elf.h>
 
 
 static int checkFhdr(const Elf32_Ehdr *fhdr)
@@ -254,13 +256,8 @@ putSectRel:
     return ret;
 }
 
-int FileElf::getAddrPlt(const char *names[], uint32_t addrs[], size_t cnt)
+int FileElf::doGetAddrPltARM(const char *names[], uint32_t addrs[], size_t cnt)
 {
-    if (_fhdr.e_machine != EM_ARM) {
-        LOGE("mach[%lu] is not support\n", _fhdr.e_machine);
-        return -EINVAL;
-    }
-
     int ret = makeRelocMap(R_ARM_JUMP_SLOT);
     if (ret)
         return ret;
@@ -331,6 +328,34 @@ int FileElf::getAddrPlt(const char *names[], uint32_t addrs[], size_t cnt)
     return 0;
 }
 
+int FileElf::doGetAddrPlt386(const char *names[], uint32_t addrs[], size_t cnt)
+{
+    const char *filename = this->path().c_str();
+    int ret;
+
+    ret = get_plt_addrs(filename, names, cnt, &addrs);
+    if (ret != 0) {
+        LOGE("Error getting .plt: %s\n", get_str_error(ret));
+        return -EINVAL;
+    }
+
+    return 0;
+}
+
+int FileElf::getAddrPlt(const char *names[], uint32_t addrs[], size_t cnt)
+{
+    switch (_fhdr.e_machine) {
+    case EM_ARM:
+        return doGetAddrPltARM(names, addrs, cnt);
+    case EM_386:
+        return doGetAddrPlt386(names, addrs, cnt);
+    default:
+        LOGE("mach[%lu] is not support\n", _fhdr.e_machine);
+    }
+
+    return -EINVAL;
+}
+
 FileElf::FileElf()
 {
 }
index 9b1da01..1816f60 100644 (file)
@@ -30,6 +30,9 @@ private:
     int makeRelocMap(const uint8_t jump_slot);
     const Elf32_Shdr *getShdr(const std::string &name);
 
+    int doGetAddrPltARM(const char *names[], uint32_t addrs[], size_t cnt);
+    int doGetAddrPlt386(const char *names[], uint32_t addrs[], size_t cnt);
+
     typedef std::map <std::string, Elf32_Shdr> ShdrMap;
     typedef std::map <uint32_t, std::string> RelocMap;
 
index 3022362..49c200b 100755 (executable)
@@ -54,9 +54,6 @@ check_null_or_exit addr_do_app
 
 
 tmp=$(mktemp)
-# launchpad
-addr_dlopen_plt=$(su root -c "parse_elf $path_launchpad -r dlopen")
-addr_dlsym_plt=$(su root -c "parse_elf $path_launchpad -r dlsym")
 
 # libappcore-efl.so
 addr_appcore_init_plt=$(parse_elf $path_app_core_efl -r appcore_init)
@@ -64,8 +61,8 @@ addr_elm_run_plt=$(parse_elf $path_app_core_efl -r elm_run)
 
 
 # PLT
-addr_dlopen_plt=${addr_dlopen_plt:-0}
-addr_dlsym_plt=${addr_dlsym_plt:-0}
+addr_dlopen_plt=0
+addr_dlsym_plt=0
 addr_appcore_init_plt=${addr_appcore_init_plt:-0}
 addr_elm_run_plt=${addr_elm_run_plt:-0}