Skip to contentSkip to conversation

package/libusb: compile with -fPIC when BR2_PIC_PIE is set

PATCH Superseded Ankur Tyagi 1 participant 1 message Sep 28, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

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

---
 package/libusb/libusb.mk | 5 +++++
 1 file changed, 5 insertions(+)
package/libusb/libusb.mk +5 -0
index 28efcadefc..aca1305b2c 100644
@@ -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))
Signature · 15 lines
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.
###########################################################################
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot