Adding HIDL service to vendor with prebuilt libraries (Android P)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding HIDL service to vendor with prebuilt libraries (Android P)

Tore Offermann
Hello everyone,

I am currently fighting adding a vendor HIDL service with prebuilt libraries on Android Pie.

The HIDL service is created in vendor/...
It depends on some prebuilt libraries.

The prebuilt libraries are added to the Makefile for the service as follows:

include $(CLEAR_VARS)
LOCAL_PROPRIETARY_MODULE
:= true
LOCAL_MODULE_SUFFIX
:= .so
LOCAL_MODULE_CLASS
:= SHARED_LIBRARIES
LOCAL_MODULE
:= libTest
LOCAL_SRC_FILES
:= lib/libTest.so
#include $(BUILD_PREBUILT)

During android make the library is correctly copied to /vendor/lib and after I flash the device the lib is also available in that folder.

I added the lib to the HIDL service makefile:

include $(CLEAR_VARS)

LOCAL_MODULE := xxx.hardware.test@1.0-service
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_INIT_RC := [hidden email]
LOCAL_CFLAGS := -Werror

LOCAL_SRC_FILES := service.cpp

LOCAL_C_INCLUDES := $(subst ${ANDROID}/,,$(LOCAL_C_INCLUDES))


LOCAL_SHARED_LIBRARIES := \
    xxx.hardware.test@1.0 \
    libhidlbase \
    libhidltransport \
    libbase \
    liblog \
    libutils \
    libTest

include $(BUILD_EXECUTABLE)


No issues during make, but after I start the device the linker complains with:

08-08 10:13:34.014  6814  6814 F linker  : CANNOT LINK EXECUTABLE "/vendor/bin/hw/xxx.hardware.test@1.0-service": library "out/target/product/xxx/obj/lib/libTest.so" not found

Not sure how this can happen?
I would suppose that the linker should check for the lib in /vendor/lib.

Could it have something to do with:

LOCAL_PRELINK_MODULE := false

Thanks in advance!

BR,
Tore

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding HIDL service to vendor with prebuilt libraries (Android P)

Colin Cross
Likely libTest.so is built incorrectly and xxx.hardware.test@1.0-service is ending up with an incorrect DT_NEEDED entry.  Can you show the output of objdump -x lib/libTest.so and objdump -x $OUT/vendor/bin/hw/xxx.hardware.test@1.0-service?  My guess is that SONAME in libTest.so is "out/target/product/xxx/obj/lib/libTest.so" and that gets copied into NEEDED in xxx.hardware.test@1.0-service.

On Thu, Aug 8, 2019 at 9:50 AM Tore Offermann <[hidden email]> wrote:
Hello everyone,

I am currently fighting adding a vendor HIDL service with prebuilt libraries on Android Pie.

The HIDL service is created in vendor/...
It depends on some prebuilt libraries.

The prebuilt libraries are added to the Makefile for the service as follows:

include $(CLEAR_VARS)
LOCAL_PROPRIETARY_MODULE
:= true
LOCAL_MODULE_SUFFIX
:= .so
LOCAL_MODULE_CLASS
:= SHARED_LIBRARIES
LOCAL_MODULE
:= libTest
LOCAL_SRC_FILES
:= lib/libTest.so
#include $(BUILD_PREBUILT)

During android make the library is correctly copied to /vendor/lib and after I flash the device the lib is also available in that folder.

I added the lib to the HIDL service makefile:

include $(CLEAR_VARS)

LOCAL_MODULE := xxx.hardware.test@1.0-service
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_INIT_RC := [hidden email]
LOCAL_CFLAGS := -Werror

LOCAL_SRC_FILES := service.cpp

LOCAL_C_INCLUDES := $(subst ${ANDROID}/,,$(LOCAL_C_INCLUDES))


LOCAL_SHARED_LIBRARIES := \
    xxx.hardware.test@1.0 \
    libhidlbase \
    libhidltransport \
    libbase \
    liblog \
    libutils \
    libTest

include $(BUILD_EXECUTABLE)


No issues during make, but after I start the device the linker complains with:

08-08 10:13:34.014  6814  6814 F linker  : CANNOT LINK EXECUTABLE "/vendor/bin/hw/xxx.hardware.test@1.0-service": library "out/target/product/xxx/obj/lib/libTest.so" not found

Not sure how this can happen?
I would suppose that the linker should check for the lib in /vendor/lib.

Could it have something to do with:

LOCAL_PRELINK_MODULE := false

Thanks in advance!

BR,
Tore

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/CAMbhsRSmfp3KRh5OyauULYjbOyZhwjvb%3Dr2xWnY89y%2BAZdB_8A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding HIDL service to vendor with prebuilt libraries (Android P)

Tore Offermann
Thanks for the fast response!
Executing objdump -x on the service:

Dynamic Section:
 
...
  NEEDED               xxx
.hardware.test@1.0.so
  NEEDED               libhidlbase
.so
  NEEDED               libhidltransport
.so
  NEEDED               libbase
.so
  NEEDED               liblog
.so
  NEEDED               libutils
.so
  NEEDED              
out/target/product/xxx/obj/lib/libTest.so
  NEEDED               libc
++.so
  NEEDED               libc
.so
  NEEDED               libm
.so
  NEEDED               libdl
.so
  PREINIT_ARRAY        
0x00008ba0
  PREINIT_ARRAYSZ      
0x00000008
  INIT_ARRAY          
0x00008ba8
  INIT_ARRAYSZ        
0x00000008
  FINI_ARRAY          
0x00008bb0
  FINI_ARRAYSZ        
0x00000008
  FLAGS                
0x00000008
  FLAGS_1              
0x00000001
  VERSYM              
0x00004f34
  VERNEED              
0x0000511c
  VERNEEDNUM          
0x00000002

The libTest.so built with clang in own build environment does not have a SONAME.
Dynamic Section:
  PLTGOT              
0x00003f84
  PLTRELSZ            
0x000000e0
  JMPREL              
0x00000b08
  PLTREL              
0x00000011
  REL                  
0x00000a40
  RELSZ                
0x000000c8
  RELENT              
0x00000008
  RELCOUNT            
0x00000014
  SYMTAB              
0x000001cc
  SYMENT              
0x00000010
  STRTAB              
0x000004dc
  STRSZ                
0x00000398
  GNU_HASH            
0x00000874
  NEEDED               libdl
.so
  NEEDED               libc
.so
  FINI_ARRAY          
0x00003e28
  FINI_ARRAYSZ        
0x00000008
  FLAGS                
0x00000008
  FLAGS_1              
0x00000001
  VERSYM              
0x00000970
  VERDEF              
0x000009d4
  VERDEFNUM            
0x00000001
  VERNEED              
0x000009f0
  VERNEEDNUM          
0x00000002Cod
 
...

If the test library is built via the android make system the SONAME is set.
Do you think adding the soname via compiler flag like could solve the problem?
e,g,;
-Wl,-soname,libTest.so

Am Donnerstag, 8. August 2019 19:47:47 UTC+2 schrieb Colin Cross:
Likely libTest.so is built incorrectly and xxx.hardware.test@1.0-service is ending up with an incorrect DT_NEEDED entry.  Can you show the output of objdump -x lib/libTest.so and objdump -x $OUT/vendor/bin/hw/xxx.hardware.test@1.0-service?  My guess is that SONAME in libTest.so is "out/target/product/xxx/obj/lib/libTest.so" and that gets copied into NEEDED in xxx.hardware.test@1.0-service.

On Thu, Aug 8, 2019 at 9:50 AM Tore Offermann <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="UQbRtH-xDwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tore.o...@tara-systems.de> wrote:
Hello everyone,

I am currently fighting adding a vendor HIDL service with prebuilt libraries on Android Pie.

The HIDL service is created in vendor/...
It depends on some prebuilt libraries.

The prebuilt libraries are added to the Makefile for the service as follows:

include $(CLEAR_VARS)
LOCAL_PROPRIETARY_MODULE
:= true
LOCAL_MODULE_SUFFIX
:= .so
LOCAL_MODULE_CLASS
:= SHARED_LIBRARIES
LOCAL_MODULE
:= libTest
LOCAL_SRC_FILES
:= lib/libTest.so
#include $(BUILD_PREBUILT)

During android make the library is correctly copied to /vendor/lib and after I flash the device the lib is also available in that folder.

I added the lib to the HIDL service makefile:

include $(CLEAR_VARS)

LOCAL_MODULE := xxx.hardware.test@1.0-service
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_INIT_RC := xxx.hardware.test@1.0-service.rc
LOCAL_CFLAGS := -Werror

LOCAL_SRC_FILES := service.cpp

LOCAL_C_INCLUDES := $(subst ${ANDROID}/,,$(LOCAL_C_INCLUDES))


LOCAL_SHARED_LIBRARIES := \
    xxx.hardware.test@1.0 \
    libhidlbase \
    libhidltransport \
    libbase \
    liblog \
    libutils \
    libTest

include $(BUILD_EXECUTABLE)


No issues during make, but after I start the device the linker complains with:

08-08 10:13:34.014  6814  6814 F linker  : CANNOT LINK EXECUTABLE "/vendor/bin/hw/xxx.hardware.test@1.0-service": library "out/target/product/xxx/obj/lib/libTest.so" not found

Not sure how this can happen?
I would suppose that the linker should check for the lib in /vendor/lib.

Could it have something to do with:

LOCAL_PRELINK_MODULE := false

Thanks in advance!

BR,
Tore

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="UQbRtH-xDwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com
To unsubscribe from this group, send email to
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="UQbRtH-xDwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com
For more options, visit this group at
<a href="http://groups.google.com/group/android-building?hl=en" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/android-building?hl\x3den&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/android-building?hl\x3den&#39;;return true;">http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="UQbRtH-xDwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">android-...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-building/d6699eb8-3c08-4ac1-8e74-fb8634b1bd1f%40googlegroups.com.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email]
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/19f84a48-97b5-44fc-aa6e-25e78de20da6%40googlegroups.com.