GOT patcher: add pthread's data initialization 47/93747/3 accepted/tizen/common/20161027.073730 accepted/tizen/ivi/20161028.151920 accepted/tizen/mobile/20161028.151831 accepted/tizen/tv/20161028.151854 accepted/tizen/wearable/20161028.151905 submit/tizen/20161027.065329
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 25 Oct 2016 13:16:19 +0000 (16:16 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Wed, 26 Oct 2016 17:48:46 +0000 (20:48 +0300)
Issue:
Now GOT patcher module uses probes on pthread init function, so
it needs data about pthread's path and __pthread_initialize_minimal()
offset.

Solution:
Add to swap_gtp_init.sh generation getting and writing neccessary
information.

Change-Id: If0b8f50d1ccb981d3e6a5e62df14a1a7b50659f6
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
scripts/gen_gtp_data.sh

index e1a7b2e..7eb56e2 100644 (file)
@@ -5,6 +5,8 @@ handlers_lib="/usr/lib/da_probe_tizen.so"
 fixup_handler="__dl_fixup_wrapper"
 reloc_handler="__dl_reloc_wrapper"
 linker_info_header="/usr/local/include/linker_info.h"
+libpthread_pkg_name="glibc"
+libpthread_init_func="__pthread_initialize_minimal"
 
 output=$1
 
@@ -71,6 +73,17 @@ function print_dl_reloc_handler_off()
     echo -e "/bin/echo \"$addr\" > /sys/kernel/debug/swap/got_patcher/handler/reloc_handler_off" >> $filename
 }
 
+function print_libpthread()
+{
+    filename=$1
+
+    libpthread_path=$(rpm -ql $libpthread_pkg_name | grep "/lib/libpthread" | head -1)
+    addr=$(readelf -sW $libpthread_path | grep $libpthread_init_func | awk '{print "0x" $2}')
+
+    echo -e "/bin/echo \"$libpthread_path\" > /sys/kernel/debug/swap/got_patcher/pthread/path" >> $filename
+    echo -e "/bin/echo \"$addr\" > /sys/kernel/debug/swap/got_patcher/pthread/minimal_init_off" >> $filename
+}
+
 function print_enable()
 {
     filename=$1
@@ -85,4 +98,5 @@ print_dl_reloc_off $output
 print_probe_lib $output
 print_dl_fixup_handler_off $output
 print_dl_reloc_handler_off $output
+print_libpthread $output
 print_enable $output