Bionic libhybris path

Тут оказывается надо ещё в исходники лезть бионика из за несовместимости некоторых вызовов. Таких как errno и tls. Спускаться так низко по стеку ни когда не случалось. Если честно доки пришлось читать в огромном количестве и многие из них, как патч в официальном репосе, только запутывал. На данный момент получился таким...

Код DIFF:
  1. diff -Naur bionic_orig/libc/Android.mk bionic/libc/Android.mk
  2. --- bionic_orig/libc/Android.mk 2015-04-08 10:06:24.000000000 +0300
  3. +++ bionic/libc/Android.mk 2016-07-23 18:58:11.107212738 +0300
  4. @@ -248,7 +248,6 @@
  5. tzcode/localtime.c
  6. tzcode/strftime.c
  7. tzcode/strptime.c
  8. - bionic/__set_errno.c
  9. bionic/cpuacct.c
  10. bionic/arc4random.c
  11. bionic/basename.c
  12. @@ -643,6 +642,7 @@
  13. LOCAL_SRC_FILES :=
  14. $(libc_arch_static_src_files)
  15. $(libc_static_common_src_files)
  16. + bionic/__set_errno.c
  17. bionic/libc_init_static.c
  18.  
  19. LOCAL_C_INCLUDES := $(libc_common_c_includes)
  20. @@ -655,6 +655,33 @@
  21.  
  22. include $(BUILD_STATIC_LIBRARY)
  23.  
  24. +# ========================================================
  25. +# libdsyscalls.so
  26. +# ========================================================
  27. +include $(CLEAR_VARS)
  28. +
  29. +LOCAL_SRC_FILES :=
  30. + $(libc_arch_static_src_files)
  31. + $(libc_static_common_src_files)
  32. + bionic/dlmalloc.c
  33. + bionic/__set_errno.c
  34. + bionic/malloc_debug_common.c
  35. + hybris/libdsyscalls.c
  36. +
  37. +LOCAL_C_INCLUDES := $(libc_common_c_includes)
  38. +LOCAL_CFLAGS := $(libc_common_cflags)
  39. +
  40. +LOCAL_MODULE:= libdsyscalls
  41. +
  42. +LOCAL_SHARED_LIBRARIES := libdl
  43. +LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
  44. +LOCAL_SYSTEM_SHARED_LIBRARIES :=
  45. +
  46. +LOCAL_LDFLAGS := -Wl,--exclude-libs=libgcc.a
  47. +
  48. +LOCAL_MODULE_TAGS := optional
  49. +
  50. +include $(BUILD_SHARED_LIBRARY)
  51.  
  52. # ========================================================
  53. # libc.a
  54. @@ -665,6 +692,7 @@
  55. $(libc_arch_static_src_files)
  56. $(libc_static_common_src_files)
  57. bionic/dlmalloc.c
  58. + bionic/__set_errno.c
  59. bionic/malloc_debug_common.c
  60. bionic/libc_init_static.c
  61.  
  62. @@ -689,6 +717,7 @@
  63. LOCAL_SRC_FILES :=
  64. $(libc_arch_dynamic_src_files)
  65. $(libc_static_common_src_files)
  66. + bionic/__set_errno.c
  67. bionic/dlmalloc.c
  68. bionic/malloc_debug_common.c
  69. bionic/libc_init_dynamic.c
  70. @@ -703,7 +732,7 @@
  71. # create an "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
  72. # you wanted!
  73.  
  74. -LOCAL_SHARED_LIBRARIES := libdl
  75. +LOCAL_SHARED_LIBRARIES := libdl libdsyscalls
  76. LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
  77. LOCAL_SYSTEM_SHARED_LIBRARIES :=
  78.  
  79. @@ -764,6 +793,7 @@
  80. LOCAL_SHARED_LIBRARIES := libc
  81. LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
  82. LOCAL_SYSTEM_SHARED_LIBRARIES :=
  83. +LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
  84.  
  85. # Don't install on release build
  86. LOCAL_MODULE_TAGS := eng debug
  87. diff -Naur bionic_orig/libc/bionic/logd_write.c bionic/libc/bionic/logd_write.c
  88. --- bionic_orig/libc/bionic/logd_write.c 2015-04-08 10:06:24.000000000 +0300
  89. +++ bionic/libc/bionic/logd_write.c 2016-07-23 19:09:27.963079430 +0300
  90. @@ -41,10 +41,10 @@
  91. #include "logd.h"
  92.  
  93. /* should match system/core/include/cutils/logger.h */
  94. -#define LOGGER_LOG_MAIN "log/main"
  95. -#define LOGGER_LOG_RADIO "log/radio"
  96. -#define LOGGER_LOG_EVENTS "log/events"
  97. -#define LOGGER_LOG_SYSTEM "log/system"
  98. +#define LOGGER_LOG_MAIN "alog/main"
  99. +#define LOGGER_LOG_RADIO "alog/radio"
  100. +#define LOGGER_LOG_EVENTS "alog/events"
  101. +#define LOGGER_LOG_SYSTEM "alog/system"
  102.  
  103. #include <pthread.h>
  104.  
  105. diff -Naur bionic_orig/libc/bionic/pthread.c bionic/libc/bionic/pthread.c
  106. --- bionic_orig/libc/bionic/pthread.c 2015-04-08 10:06:24.000000000 +0300
  107. +++ bionic/libc/bionic/pthread.c 2016-07-24 12:44:59.624395635 +0300
  108. @@ -178,7 +178,8 @@
  109.  
  110. void __init_tls(void** tls, void* thread)
  111. {
  112. - int nn;
  113. + *((int *) 0) = -1;
  114. +/* int nn;
  115.  
  116. ((pthread_internal_t*)thread)->tls = tls;
  117.  
  118. @@ -189,7 +190,7 @@
  119. for (nn = TLS_SLOT_ERRNO; nn < BIONIC_TLS_SLOTS; nn++)
  120. tls[nn] = 0;
  121.  
  122. - __set_tls( (void*)tls );
  123. + __set_tls( (void*)tls );*/
  124. }
  125.  
  126.  
  127. diff -Naur bionic_orig/libc/bionic/__set_errno.c bionic/libc/bionic/__set_errno.c
  128. --- bionic_orig/libc/bionic/__set_errno.c 2015-04-08 10:06:24.000000000 +0300
  129. +++ bionic/libc/bionic/__set_errno.c 2016-07-23 18:30:56.257012751 +0300
  130. @@ -28,13 +28,13 @@
  131.  
  132. #include <errno.h>
  133.  
  134. -
  135. +#ifdef LIBC_STATIC
  136. int __set_errno(int n)
  137. {
  138. errno = n;
  139. return -1;
  140. }
  141. -
  142. +#endif
  143. /*
  144. * this function is called from syscall stubs,
  145. * (tail-called in the case of 0-4 arg versions)
  146. diff -Naur bionic_orig/libc/hybris/libdsyscalls.c bionic/libc/hybris/libdsyscalls.c
  147. --- bionic_orig/libc/hybris/libdsyscalls.c 1970-01-01 03:00:00.000000000 +0300
  148. +++ bionic/libc/hybris/libdsyscalls.c 2016-07-15 10:53:54.000000000 +0300
  149. @@ -0,0 +1,27 @@
  150. +/*
  151. + * Copyright (C) 2007 The Android Open Source Project
  152. + *
  153. + * Licensed under the Apache License, Version 2.0 (the "License");
  154. + * you may not use this file except in compliance with the License.
  155. + * You may obtain a copy of the License at
  156. + *
  157. + * http://www.apache.org/licenses/LICENSE-2.0
  158. + *
  159. + * Unless required by applicable law or agreed to in writing, software
  160. + * distributed under the License is distributed on an "AS IS" BASIS,
  161. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  162. + * See the License for the specific language governing permissions and
  163. + * limitations under the License.
  164. + */
  165. +
  166. +#include <errno.h>
  167. +
  168. +/* Define __set_errno here so it can be hijacked by libhybris
  169. + * at runtime (called from __set_syscall_errno)
  170. + */
  171. +
  172. +int __set_errno(int n)
  173. +{
  174. + errno = n;
  175. + return -1;
  176. +}
  177. diff -Naur bionic_orig/libc/private/bionic_tls.h bionic/libc/private/bionic_tls.h
  178. --- bionic_orig/libc/private/bionic_tls.h 2015-04-08 10:06:24.000000000 +0300
  179. +++ bionic/libc/private/bionic_tls.h 2016-07-23 13:53:05.041534260 +0300
  180. @@ -55,17 +55,17 @@
  181. /* Well known TLS slots */
  182. #define TLS_SLOT_SELF 0
  183. #define TLS_SLOT_THREAD_ID 1
  184. -#define TLS_SLOT_ERRNO 2
  185. +#define TLS_SLOT_ERRNO 4
  186.  
  187. -#define TLS_SLOT_OPENGL_API 3
  188. -#define TLS_SLOT_OPENGL 4
  189. +#define TLS_SLOT_OPENGL_API 5
  190. +#define TLS_SLOT_OPENGL 6
  191.  
  192. /* this slot is only used to pass information from the dynamic linker to
  193. * libc.so when the C library is loaded in to memory. The C runtime init
  194. * function will then clear it. Since its use is extremely temporary,
  195. * we reuse an existing location.
  196. */
  197. -#define TLS_SLOT_BIONIC_PREINIT (TLS_SLOT_ERRNO+1)
  198. +#define TLS_SLOT_BIONIC_PREINIT 3
  199.  
  200. /* small technical note: it is not possible to call pthread_setspecific
  201. * on keys that are <= TLS_SLOT_MAX_WELL_KNOWN, which is why it is set to
  202. @@ -76,7 +76,7 @@
  203. * pthread_key_create() to initialize them. on the other hand, there is
  204. * no destructor associated to them (we might need to implement this later)
  205. */
  206. -#define TLS_SLOT_MAX_WELL_KNOWN TLS_SLOT_ERRNO
  207. +#define TLS_SLOT_MAX_WELL_KNOWN 2
  208.  
  209. #define TLS_DEFAULT_ALLOC_MAP 0x0000001F
  210.  
  211. diff -Naur bionic_orig/libdl/libdl.c bionic/libdl/libdl.c
  212. --- bionic_orig/libdl/libdl.c 2015-04-08 10:06:24.000000000 +0300
  213. +++ bionic/libdl/libdl.c 2016-07-23 17:00:06.322221604 +0300
  214. @@ -13,7 +13,6 @@
  215. * See the License for the specific language governing permissions and
  216. * limitations under the License.
  217. */
  218. -
  219. #include <dlfcn.h>
  220. /* These are stubs for functions that are actually defined
  221. * in the dynamic linker (dlfcn.c), and hijacked at runtime.
  222. @@ -24,6 +23,9 @@
  223. int dladdr(const void *addr, Dl_info *info) { return 0; }
  224. int dlclose(void *handle) { return 0; }
  225.  
  226. +int *__errno() { return 0; };
  227. +void __set_errno(int f) {};
  228. +
  229. #ifdef __arm__
  230. void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
  231. #elif defined(__i386__) || defined(__sh__)
  232. diff -Naur bionic_orig/linker/linker_format.c bionic/linker/linker_format.c
  233. --- bionic_orig/linker/linker_format.c 2015-04-08 10:06:24.000000000 +0300
  234. +++ bionic/linker/linker_format.c 2016-07-25 11:35:04.813739094 +0300
  235. @@ -270,7 +270,7 @@
  236. result = vformat_buffer(buf, sizeof buf, fmt, args);
  237.  
  238. if (log_fd < 0) {
  239. - log_fd = open("/dev/log/main", O_WRONLY);
  240. + log_fd = open("/dev/alog/main", O_WRONLY);
  241. if (log_fd < 0)
  242. return result;
  243. }
  244. diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
  245. index 0a842bd..ecfb3ac 100644
  246. --- a/libc/include/sys/_system_properties.h
  247. +++ b/libc/include/sys/_system_properties.h
  248. @@ -58,6 +58,8 @@ struct prop_msg
  249. };
  250.  
  251. #define PROP_MSG_SETPROP 1
  252. +#define PROP_MSG_GETPROP 2
  253. +#define PROP_MSG_LISTPROP 3
  254.  
  255.  
Комментарии (0)

Нет комментариев. Ваш будет первым!

Copyright 2016-2024 NeoChapay