Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an external static library to Trusted Application #901

Closed
haleyyew opened this issue Jul 6, 2016 · 6 comments
Closed

Adding an external static library to Trusted Application #901

haleyyew opened this issue Jul 6, 2016 · 6 comments

Comments

@haleyyew
Copy link

haleyyew commented Jul 6, 2016

Hi, I am trying to put the protobuf-c.a library into my Trusted Application. I tried this hackish way where I combined my static library with libutils.a. I also tried to add the static library independently by specifying it in ldargs-$(binary). However for both methods I got the following error:

/home/haoran/devel/optee/optee_app/../toolchains/aarch32/bin/arm-linux-gnueabihf-ld: /home/haoran/devel/optee/optee_os/out/arm/export-ta_arm32/lib/libutils.a(protobuf-c.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/haoran/devel/optee/optee_os/out/arm/export-ta_arm32/lib/libutils.a: error adding symbols: Bad value

I was wondering, if you can give me any pointers on how the static library for protobuf-c.a should be compiled or added to the build Makefile so the build for the TA works?

My make file currently looks like this:

CFG_TEE_TA_LOG_LEVEL = 2
CPPFLAGS += -DCFG_TEE_TA_LOG_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) -I../common
#CPPFLAGS += -I/usr/local/include 
CPPFLAGS += -I/home/haoran/devel/optee/toolchains/aarch32/arm-linux-gnueabihf/libc/include

BINARY=ffa39702-9ce0-47e0-a1cb4048cfdb847d

include $(TA_DEV_KIT_DIR)/mk/ta_dev_kit.mk
#ldargs-$(binary).elf += -lprotobuf-c -L/usr/local/lib
#ldargs-$(binary).elf += -lprotobuf-c -L/usr/lib 
#ldargs-$(binary).elf += -lprotobuf-c 
#/home/haoran/devel/optee/toolchains/aarch32/arm-linux-gnueabihf/libc/lib
#ldargs-$(binary).elf += /home/haoran/devel/optee/toolchains/aarch32/arm-linux-gnueabihf/libc/lib/libprotobuf-c.so.1.0.0
@jenswi-linaro
Copy link
Contributor

You'll find the interesting flags in $(TA_DEV_KIT_DIR)/mk/conf.mk

@haleyyew
Copy link
Author

haleyyew commented Jul 6, 2016

Can you be a little more specific on how a static .a library can be linked to the object files after compilation? There are only cflags in $(TA_DEV_KIT_DIR)/mk/conf.mk but I'm looking for ld that can be set to a static library.

Thanks

@peterfeifanchen
Copy link

perhaps try in ta_dev_kit.mk:

libdirs += $(ta-dev-kit-dir)/lib
libnames += utils utee mpa utils utee
libdeps += $(ta-dev-kit-dir)/lib/libutils.a
libdeps += $(ta-dev-kit-dir)/lib/libmpa.a
libdeps += $(ta-dev-kit-dir)/lib/libutee.a

Add your static library here and drop the library itself into the $(ta_dev_kit_dir)/lib. If it depends on any library such as libutils.a, make sure you add it before that.

@haleyyew
Copy link
Author

haleyyew commented Jul 7, 2016

After adding libdeps += $(ta-dev-kit-dir)/lib/libprotobuf-c.a in ta_dev_kit.mk, I still get the

relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC

error.
Help is much appreciated.

@jenswi-linaro
Copy link
Contributor

Try to recompile your static library with the compiler flags found in $(TA_DEV_KIT_DIR)/mk/conf.mk, it looks like something is incompatible.

@haleyyew
Copy link
Author

I managed to include the external library without having to link it to a TA. Since I already have the source code for the library, I didn't have to use the shared object of the library, I added all of the library's source code as part of the TA instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants