[Buildroot] [PATCH 1/1] package/libusb: compile with -fPIC when BR2_PIC_PIE is set

Ankur Tyagi ankur.tyagi at gallagher.com
Tue Sep 28 22:50:45 UTC 2021


Otherwise build fails with following error:
Toolchain wrapper executing: '/tools/arm-unknown-linux-gnueabi/bin//arm-unknown-linux-gnueabi-gcc' '--sysroot' '/home/user/work/buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot' '-mabi=aapcs-linux' '-msoft-float' '-marm' '-fstack-protector-strong' '-march=armv5te' '-msoft-float' '-mfpu=vfp' '-mfloat-abi=soft' '-mcpu=arm926ej-s' '-fPIE' '-Wl,-z,now' '-Wl,-z,relro' '-shared' '.libs/core.o' '.libs/descriptor.o' '.libs/hotplug.o' '.libs/io.o' '.libs/strerror.o' '.libs/sync.o' 'os/.libs/events_posix.o' 'os/.libs/threads_posix.o' 'os/.libs/linux_usbfs.o' 'os/.libs/linux_netlink.o' '-lpthread' '-pthread' '-Os' '-g2' '-pthread' '-Wl,-soname' '-Wl,libusb-1.0.so.0' '-o' '.libs/libusb-1.0.so.0.3.0'
/tools/arm-unknown-linux-gnueabi/bin/../lib/gcc/arm-unknown-linux-gnueabi/7.3.0/../../../../arm-unknown-linux-gnueabi/bin/ld: os/.libs/threads_posix.o(.text+0x284): R_ARM_TLS_LE32 relocation not permitted in shared object
os/.libs/threads_posix.o: In function `usbi_get_tid':
/home/user/work/buildroot/output/build/libusb-1.0.24/libusb/os/threads_posix.c:129:(.text+0x284): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
Makefile:584: recipe for target 'libusb-1.0.la' failed
make[4]: *** [libusb-1.0.la] Error 1

Signed-off-by: Ankur Tyagi <ankur.tyagi at gallagher.com>
---
 package/libusb/libusb.mk | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/package/libusb/libusb.mk b/package/libusb/libusb.mk
index 28efcadefc..aca1305b2c 100644
--- a/package/libusb/libusb.mk
+++ b/package/libusb/libusb.mk
@@ -34,5 +34,10 @@ endef
 LIBUSB_POST_INSTALL_TARGET_HOOKS += LIBUSB_INSTALL_TARGET_EXAMPLES
 endif
 
+ifeq ($(BR2_PIC_PIE),y)
+LIBUSB_CFLAGS += -fPIC
+LIBUSB_CONF_OPTS += --enable-gcc-hardening CFLAGS="$(LIBUSB_CFLAGS)"
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
-- 
2.25.1

###########################################################################
This email is confidential and may contain information subject to legal 
privilege.  If you are not the intended recipient please advise us of our
error by return e-mail then delete this email and any attached files.  
You may not copy, disclose or use the contents in any way.  

The views expressed in this email may not be those of Gallagher Group 
Ltd or subsidiary companies thereof.
###########################################################################


More information about the buildroot mailing list