From 72d751cba9cda9ce3ae46d5e6ab962d2f675e970 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 10 Jan 2017 11:37:47 +0100 Subject: build: rework library bundling Rework the bundle-libraries.sh implementation to use a more robust approach for executing host binaries through the shipped ELF loader and libraries. The previous approach relied on symlinks pointing to a wrapper script which caused various issues, especially with multicall binaries as the original argv[0] name was not preserved through the ld.so invocation. Another down- side was the fact that the actual binaries got moved into another directory which caused executables to fail looking up resources with paths relative to the executable location. The new library wrapper implements the following improvements: - Instead of symlinks pointing to a common wrapper, each ELF executable is now replaced by a unqiue shell script which retains the original program name getting called - Instead of letting ld.so invoke the ELF executable directly, launch the final ELF binary through a helper program which fixes up the argv[0] argument for the target program - Support sharing a common location for the bundled libraries instead of having one copy in each directory containing wrapped binaries Finally modify the SDK build to wrap the staging_dir and toolchain binaries which allows to use the SDK on systems with a different glibc version. Signed-off-by: Jo-Philipp Wich --- target/imagebuilder/Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'target/imagebuilder') diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile index b43662b6ac..8a7c2093b9 100644 --- a/target/imagebuilder/Makefile +++ b/target/imagebuilder/Makefile @@ -66,16 +66,20 @@ endif $(PKG_BUILD_DIR)/target/linux/*/patches{,-*} -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here -cp $(LINUX_DIR)/.config $(IB_LDIR)/ - -$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \ - $(LINUX_DIR)/scripts/dtc/dtc + if [ -x $(LINUX_DIR)/scripts/dtc/dtc ]; then \ + $(INSTALL_DIR) $(IB_LDIR)/scripts/dtc; \ + $(INSTALL_BIN) $(LINUX_DIR)/scripts/dtc/dtc $(IB_LDIR)/scripts/dtc/dtc; \ + fi if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \ $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \ fi $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \ | $(XARGS) rm -rf - find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \ - | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/ + $(INSTALL_DIR) $(PKG_BUILD_DIR)/staging_dir/host/bin + $(CP) $(STAGING_DIR_HOST)/bin/* $(PKG_BUILD_DIR)/staging_dir/host/bin/ + (cd $(PKG_BUILD_DIR); find staging_dir/host/bin/ $(IB_LDIR)/scripts/dtc/ -type f | \ + $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host) STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/ $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -zc -7e > $@ -- cgit v1.2.3