@@ -29,20 +29,42 @@ static void init_libcutils() {
2929 }
3030
3131 ashmem_create_region = dlsym (libcutils, " ashmem_create_region" );
32+ if (ashmem_create_region == nullptr ) {
33+ ALOGE (" Failed to load symbol ashmem_create_region from libcutils.so" );
34+ goto exit;
35+ }
36+
3237 ashmem_set_prot_region = dlsym (libcutils, " ashmem_set_prot_region" );
38+ if (ashmem_set_prot_region == nullptr ) {
39+ ALOGE (" Failed to load symbol ashmem_set_prot_region from libcutils.so" );
40+ goto exit;
41+ }
3342
3443 native_handle_create = dlsym (libcutils, " native_handle_create" );
44+ if (native_handle_create == nullptr ) {
45+ ALOGE (" Failed to load symbol native_handle_create from libcutils.so" );
46+ goto exit;
47+ }
48+
3549 native_handle_close = dlsym (libcutils, " native_handle_close" );
36- native_handle_delete = dlsym (libcutils, " native_handle_delete" );
50+ if (native_handle_close == nullptr ) {
51+ ALOGE (" Failed to load symbol native_handle_close from libcutils.so" );
52+ goto exit;
53+ }
3754
38- if (ashmem_create_region == nullptr ||
39- ashmem_set_prot_region == nullptr ||
40- native_handle_create == nullptr ||
41- native_handle_close == nullptr ||
42- native_handle_delete == nullptr ) {
43- ALOGE (" Failed to load symbols from libcutils.so" );
55+ native_handle_delete = dlsym (libcutils, " native_handle_delete" );
56+ if (native_handle_delete == nullptr ) {
57+ ALOGE (" Failed to load symbol native_handle_delete from libcutils.so" );
58+ goto exit;
4459 }
4560
61+ ALOGD (" ashmem_create_region: %p" , ashmem_create_region);
62+ ALOGD (" ashmem_set_prot_region: %p" , ashmem_set_prot_region);
63+ ALOGD (" native_handle_create: %p" , native_handle_create);
64+ ALOGD (" native_handle_close: %p" , native_handle_close);
65+ ALOGD (" native_handle_delete: %p" , native_handle_delete);
66+
67+ exit:
4668 dlclose (libcutils);
4769}
4870
@@ -54,26 +76,42 @@ static void init_libfmq() {
5476 }
5577
5678 _ZN7android8hardware7details5checkEbPKc = dlsym (libfmq, " _ZN7android8hardware7details5checkEbPKc" );
79+ if (_ZN7android8hardware7details5checkEbPKc == nullptr ) {
80+ ALOGE (" Failed to load symbol _ZN7android8hardware7details5checkEbPKc from libfmq.so" );
81+ goto exit;
82+ }
83+
5784 // ndk variant, real symbol: _ZN7android8hardware7details8logErrorERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
5885 _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE = dlsym (libfmq, " _ZN7android8hardware7details8logErrorERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE" );
86+ if (_ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE == nullptr ) {
87+ ALOGE (" Failed to load symbol _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE from libfmq.so" );
88+ goto exit;
89+ }
90+
5991 // ndk variant, real symbol: _ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_
6092 _ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ = dlsym (libfmq, " _ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_" );
61- _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ = dlsym (libfmq, " _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_" );
93+ if (_ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ == nullptr ) {
94+ ALOGE (" Failed to load symbol _ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_ from libfmq.so" );
95+ goto exit;
96+ }
6297
63- if (_ZN7android8hardware7details5checkEbPKc == nullptr ||
64- _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE == nullptr ||
65- _ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ == nullptr ||
66- _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ == nullptr ) {
67- ALOGE (" Failed to load symbols from libfmq.so" );
98+ _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ = dlsym (libfmq, " _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_" );
99+ if (_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ == nullptr ) {
100+ ALOGE (" Failed to load symbol _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ from libfmq.so" );
101+ goto exit;
68102 }
69103
104+ ALOGD (" _ZN7android8hardware7details5checkEbPKc: %p" , _ZN7android8hardware7details5checkEbPKc);
105+ ALOGD (" _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE: %p" , _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE);
106+ ALOGD (" _ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_: %p" , _ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_);
107+ ALOGD (" _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_: %p" , _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_);
108+
109+ exit:
70110 dlclose (libfmq);
71111}
72112
73113__attribute__ ((constructor))
74114void shim_init() {
75- ALOGD (" shim_init" );
76115 init_libcutils ();
77116 init_libfmq ();
78- ALOGD (" shim_init done" );
79117}
0 commit comments