[Buildroot] [PATCH 2/2] package/elf2flt: replace hard-links with script wrappers to fix rpath

Yann E. MORIN yann.morin.1998 at free.fr
Fri May 25 20:43:02 UTC 2018


Do for elf2flt what we did for binutils: replace the hardlinks (which
break rpath handling) with script wrappers.

See previous commit (package/binutils: switch from symlinks to script
wrappers) and commit f9cffb6af4 (binutils: replace hard-links with
soft-links to fix rpath) for the complete story.

Fixes: #11031.

Reported-by: Christophe Priouzeau <christophe.priouzeau at st.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
Cc: Peter Korsgaard <peter at korsgaard.com>
Cc: Christophe Priouzeau <christophe.priouzeau at st.com>
---
 package/elf2flt/elf2flt.mk | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/package/elf2flt/elf2flt.mk b/package/elf2flt/elf2flt.mk
index 995dfedebd..6ce5cd34a2 100644
--- a/package/elf2flt/elf2flt.mk
+++ b/package/elf2flt/elf2flt.mk
@@ -29,4 +29,21 @@ endif
 
 HOST_ELF2FLT_CONF_ENV = LIBS="$(HOST_ELF2FLT_LIBS)"
 
+# Hardlinks between binaries in different directories cause a problem
+# # with rpath fixup, so we de-hardlink those binaries, and replace them
+# with wrapper scripts. ld and ld.real are already wrappers, but they
+# point to the binutils, so we have to replace them with wrappers to
+# the elf2flt ones.
+ELF2FLT_TOOLS = elf2flt flthdr ld ld.real
+define HOST_ELF2FLT_FIXUP_HARDLINKS
+	$(foreach tool,$(ELF2FLT_TOOLS),\
+		rm -f $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) && \
+		printf '#!/usr/bin/env bash\nexec -a "$${0}" "$${0%%/*}/%s-$${0##*/}" "$${@}"\n' \
+			../../bin/$(GNU_TARGET_NAME) \
+			>$(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool)
+	)
+	chmod +x $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/*
+endef
+HOST_ELF2FLT_POST_INSTALL_HOOKS += HOST_ELF2FLT_FIXUP_HARDLINKS
+
 $(eval $(host-autotools-package))
-- 
2.14.1




More information about the buildroot mailing list