Add dummy assembly funcs for in-swap probes 18/151718/6
authorAlexander Aksenov <a.aksenov@samsung.com>
Wed, 20 Sep 2017 16:34:32 +0000 (19:34 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 26 Sep 2017 14:37:30 +0000 (17:37 +0300)
Change-Id: I1767e2de8f45c33b871543c879528e29a54ee689
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
Makefile
helper/libdaprobe.c
include/arch_probe_dummies.h [new file with mode: 0644]
packaging/swap-probe.spec
sysdeps/arm/probe_dummies.S [new file with mode: 0644]
sysdeps/arm64/probe_dummies.S [new file with mode: 0644]
sysdeps/i386/probe_dummies.S [new file with mode: 0644]

index 2edb010..914511f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,7 @@ ASMFLAG = -O0 -g -Werror
 
 CFLAGS = $(WARN_CFLAGS) -fPIC
 CFLAGS+= -DLINKER_PATH=\"$(LINKER_PATH)\"
+CFLAGS+= -DARCH_DIR=\"$(ARCH_DIR)\"
 CFLAGS+= -DPROBELIB_MAIN=\"$(PROBELIB_MAIN)\"
 CFLAGS+= -DPROBELIB_EVENT=\"$(PROBELIB_EVENT)\"
 CFLAGS+= -DPROBELIB_CAPI=\"$(PROBELIB_CAPI)\"
@@ -186,10 +187,13 @@ TIZEN_SRCS =      $(COMMON_SRCS) \
 
 ASM_SRC = ./helper/da_call_original.S
 
+DUMMY_FUNCS_SRC = ./sysdeps/$(ARCH_DIR)/probe_dummies.S
+
 ## Totally brain-dead.
 ## FIXME: Rewrite this normally with eval.
 ASM_OBJ = $(patsubst %.S,%.o, $(ASM_SRC))
-TIZEN_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(TIZEN_SRCS))) $(ASM_OBJ)
+DUMMY_FUNCS_OBJ = $(patsubst %.S,%.o, $(DUMMY_FUNCS_SRC))
+TIZEN_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(TIZEN_SRCS))) $(ASM_OBJ) $(DUMMY_FUNCS_OBJ)
 PROBE_EVENT_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(PROBE_EVENT_SRCS)))
 PROBE_GRAPHICS_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(PROBE_GRAPHICS_SRCS)))
 PROBE_UI_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(PROBE_UI_SRCS)))
@@ -213,6 +217,9 @@ screenshot:     tizen $(PROBE_SCREENSHOT_TARGET)
 $(ASM_OBJ): $(ASM_SRC)
        $(CC) $(ASMFLAG) -c $^ -o $@
 
+$(DUMMY_FUNCS_OBJ): $(DUMMY_FUNCS_SRC)
+       $(CC) $(ASMFLAG) -c $^ -o $@
+
 API_NAME_LIST = scripts/api_names_all.txt
 GENERATED_HEADERS = include/api_id_mapping.h include/x_define_api_id_list.h
 SOURCE_HEADERS = include/api_ld_mapping.h
index 2d44719..e198422 100755 (executable)
@@ -65,6 +65,7 @@
 #include "common_probe_init.h"
 #include "lsan_open.h"
 #include "got_patching.h"
+#include "arch_probe_dummies.h"
 
 #define UDS_NAME "/run/swap/lib.socket"
 #define TIMERFD_INTERVAL 100000000      /* 0.1 sec */
@@ -798,25 +799,6 @@ uint64_t get_current_nsec(void)
        return (uint64_t)tv.tv_sec * 1000 * 1000 * 1000 + tv.tv_usec * 1000;
 }
 
-unsigned long get_caller_addr(unsigned long caller_addr)
-{
-       return caller_addr;
-}
-
-unsigned char get_call_type(unsigned char call_type)
-{
-       return call_type;
-}
-
-void write_msg(unsigned long __unused msg_buf,
-              size_t __unused len,
-              unsigned long __unused call_type_p,
-              unsigned long __unused caller_p,
-              unsigned long __unused caller_address,
-              unsigned long __unused orig_p)
-{
-       return;
-}
 
 /************************************************************************
  * probe functions
diff --git a/include/arch_probe_dummies.h b/include/arch_probe_dummies.h
new file mode 100644 (file)
index 0000000..7a0bc54
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __ARCH_PROBE_DUMBS_H__
+#define __ARCH_PROBE_DUMBS_H__
+
+/* Architecture-dependent includes */
+
+unsigned long get_caller_addr(unsigned long caller_addr);
+
+unsigned char get_call_type(unsigned char call_type);
+
+void write_msg(unsigned long msg_buf, size_t len, unsigned long call_type_p,
+              unsigned long caller_p, unsigned long caller_address,
+              unsigned long orig_p);
+
+
+#endif /* __ARHC_PROBE_DUMBS_H__ */
index 299c8cc..104b547 100644 (file)
@@ -44,6 +44,18 @@ BuildRequires:  pkgconfig(tizen-extension-client)
 BuildRequires: cmake
 %endif
 
+# Define architecture
+%ifarch armv7l
+       %define ARCH_DIR arm
+%else
+       %ifarch aarch64
+               %define ARCH_DIR arm64
+       %else
+               %define ARCH_DIR i386
+       %endif
+%endif
+
+
 # Applied python acceleration
 %ifarch armv7l
 BuildRequires: python-accel-armv7l-cross-arm
@@ -113,6 +125,7 @@ export BINDIR=%{_bindir}
 export LIBDIR=%{_libdir}
 export INCLUDEDIR=%{_includedir}
 export LIB=%{_lib}
+export ARCH_DIR=%{ARCH_DIR}
 
 # set linker path
 make -C elf_parsing
@@ -134,6 +147,7 @@ make ldheader
 export BINDIR=%{_bindir}
 export LIBDIR=%{_libdir}
 export INCLUDEDIR=%{_includedir}
+export ARCH_DIR=%{ARCH_DIR}
 
 rm -rf ${RPM_BUILD_ROOT}
 
diff --git a/sysdeps/arm/probe_dummies.S b/sysdeps/arm/probe_dummies.S
new file mode 100644 (file)
index 0000000..13ee917
--- /dev/null
@@ -0,0 +1,38 @@
+       .text
+
+@ void write_msg(unsigned long msg_buf, size_t len, unsigned long call_type_p,
+@               unsigned long caller_p, unsigned long caller_address,
+@               unsigned long orig_p);
+
+       .globl write_msg
+       .type write_msg, #function
+write_msg:
+       mov     r0, r0
+       bx      lr
+       .size write_msg, .-write_msg
+
+
+
+@ unsigned long get_caller_addr(unsigned long caller_addr);
+
+       .globl get_caller_addr
+       .type get_caller_addr, #function
+get_caller_addr:
+@ arm GCC standard call convention implies that both first arg and ret val are
+@ stored in r0, so do nothing
+       mov     r0, r0
+       bx      lr
+       .size get_caller_addr, .-get_caller_addr
+
+
+
+@ unsigned char get_call_type(unsigned char call_type);
+
+       .globl get_call_type
+       .type get_call_type, #function
+get_call_type:
+@ arm GCC standard call convention implies that both first arg and ret val are
+@ stored in r0, so do nothing
+       mov     r0, r0
+       bx      lr
+       .size get_call_type, .-get_call_type
diff --git a/sysdeps/arm64/probe_dummies.S b/sysdeps/arm64/probe_dummies.S
new file mode 100644 (file)
index 0000000..47a8733
--- /dev/null
@@ -0,0 +1,38 @@
+       .text
+
+# void write_msg(unsigned long msg_buf, size_t len, unsigned long call_type_p,
+#               unsigned long caller_p, unsigned long caller_address,
+#               unsigned long orig_p);
+
+       .globl write_msg
+       .type write_msg, @function
+write_msg:
+       nop
+       ret
+       .size write_msg, .-write_msg
+
+
+
+# unsigned long get_caller_addr(unsigned long caller_addr);
+
+       .globl get_caller_addr
+       .type get_caller_addr, @function
+get_caller_addr:
+# arm64 GCC standard call convention implies that both first arg and ret val
+# are stored in r0, so do nothing
+       nop
+       ret
+       .size get_caller_addr, .-get_caller_addr
+
+
+
+# unsigned char get_call_type(unsigned char call_type);
+
+       .globl get_call_type
+       .type get_call_type, @function
+get_call_type:
+# arm64 GCC standard call convention implies that both first arg and ret val
+# are stored in r0, so do nothing
+       nop
+       ret
+       .size get_call_type, .-get_call_type
diff --git a/sysdeps/i386/probe_dummies.S b/sysdeps/i386/probe_dummies.S
new file mode 100644 (file)
index 0000000..7c74176
--- /dev/null
@@ -0,0 +1,36 @@
+       .text
+
+# void write_msg(unsigned long msg_buf, size_t len, unsigned long call_type_p,
+#               unsigned long caller_p, unsigned long caller_address,
+#               unsigned long orig_p);
+
+       .globl write_msg
+       .type write_msg, @function
+write_msg:
+       nop
+       ret
+       .size write_msg, .-write_msg
+
+
+
+# unsigned long get_caller_addr(unsigned long caller_addr);
+
+       .globl get_caller_addr
+       .type get_caller_addr, @function
+get_caller_addr:
+# x86 GCC using cdecl stores both first arg and ret val in EAX, so do nothing
+       nop
+       ret
+       .size get_caller_addr, .-get_caller_addr
+
+
+
+# unsigned char get_call_type(unsigned char call_type);
+
+       .globl get_call_type
+       .type get_call_type, @function
+get_call_type:
+# x86 GCC using cdecl stores both first arg and ret val in EAX, so do nothing
+       nop
+       ret
+       .size get_call_type, .-get_call_type