From b35d9328163f84e2d7dc6f2504c5e7c3fffc92dd Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 24 Feb 2015 12:46:49 +0100 Subject: toolchain: add cross prelinking tool from yoctoproject and hook it into build system --- mk/image.mk | 15 ++++++++++++++- target/config/Config.in.adk | 12 ++++++++++++ toolchain/Makefile | 3 +++ toolchain/prelink-cross/Config.in | 1 + toolchain/prelink-cross/Makefile | 34 ++++++++++++++++++++++++++++++++++ toolchain/prelink-cross/Makefile.inc | 8 ++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 toolchain/prelink-cross/Config.in create mode 100644 toolchain/prelink-cross/Makefile create mode 100644 toolchain/prelink-cross/Makefile.inc diff --git a/mk/image.mk b/mk/image.mk index 1563c2a63..7d982d773 100644 --- a/mk/image.mk +++ b/mk/image.mk @@ -37,7 +37,7 @@ else $(error No login shell configured!) endif -imageprepare: image-prepare-post extra-install +imageprepare: image-prepare-post extra-install prelink # if an extra directory exist in ADK_TOPDIR, copy all content over the # root directory, do the same if make extra=/dir/to/extra is used @@ -79,6 +79,19 @@ ifneq ($(ADK_TARGET_ARCH_AARCH64)$(ADK_TARGET_ARCH_X86_64)$(ADK_TARGET_ARCH_PPC6 (cd ${TARGET_DIR}/usr ; ln -sf ${ADK_TARGET_LIBC_PATH} lib) endif +ifeq (${ADK_PRELINK},) +prelink: +else +${TARGET_DIR}/etc/prelink.conf: + echo '/' > $@ + +prelink: ${TARGET_DIR}/etc/prelink.conf + $(TRACE) target/prelink + ${TARGET_CROSS}prelink ${ADK_PRELINK_OPTS} \ + --ld-library-path=${STAGING_TARGET_DIR}/usr/lib:${STAGING_TARGET_DIR}/lib \ + --root=${TARGET_DIR} -a $(MAKE_TRACE) +endif + KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg KERNEL_PKG:=$(PACKAGE_DIR)/kernel_$(KERNEL_VERSION)_$(ADK_TARGET_CPU_ARCH).$(PKG_SUFFIX) TARGET_KERNEL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_FS}-kernel diff --git a/target/config/Config.in.adk b/target/config/Config.in.adk index 86f38c2dd..90759cea2 100644 --- a/target/config/Config.in.adk +++ b/target/config/Config.in.adk @@ -110,4 +110,16 @@ config ADK_HOST_CYGWIN bool "Cygwin" endchoice + +config ADK_PRELINK + prompt "Prelink binaries and libraries in Image" + boolean + help + Do prelinking for faster loading of binaries. + +config ADK_PRELINK_OPTS + string "additional options to pass to prelink" + default "-mR" + depends on ADK_PRELINK + endmenu diff --git a/toolchain/Makefile b/toolchain/Makefile index 23f206ee7..e06e58de9 100644 --- a/toolchain/Makefile +++ b/toolchain/Makefile @@ -44,6 +44,9 @@ ifeq ($(ADK_TARGET_ARCH_ARC),) TARGETS+=gdb GDB:=gdb-install endif +ifeq (${ADK_PRELINK},y) +TARGETS+=prelink-cross +endif DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS)) TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS)) diff --git a/toolchain/prelink-cross/Config.in b/toolchain/prelink-cross/Config.in new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/toolchain/prelink-cross/Config.in @@ -0,0 +1 @@ + diff --git a/toolchain/prelink-cross/Makefile b/toolchain/prelink-cross/Makefile new file mode 100644 index 000000000..d1cc58c07 --- /dev/null +++ b/toolchain/prelink-cross/Makefile @@ -0,0 +1,34 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include $(ADK_TOPDIR)/rules.mk +include ../rules.mk +include Makefile.inc +include ${ADK_TOPDIR}/mk/buildhlp.mk + +$(WRKBUILD)/.headers: +$(WRKBUILD)/.configured: + (cd $(WRKBUILD)/trunk; \ + ./configure \ + --prefix=$(STAGING_HOST_DIR) \ + --build=$(GNU_HOST_NAME) \ + --host=$(GNU_HOST_NAME) \ + --target=$(REAL_GNU_TARGET_NAME) \ + --disable-dependency-tracking \ + --disable-libtool-lock \ + --with-gnu-ld \ + ); + touch $@ + +$(WRKBUILD)/.compiled: + $(MAKE) -C $(WRKBUILD)/trunk CFLAGS="-fPIC ${CFLAGS_FOR_BUILD}" + touch $@ + +$(WRKBUILD)/.installed: + install -c ${WRKBUILD}/trunk/src/prelink \ + ${TARGET_CROSS}prelink + install -c ${WRKBUILD}/trunk/src/prelink-rtld \ + ${TARGET_CROSS}prelink-rtld + touch $@ + +include ${ADK_TOPDIR}/mk/toolchain.mk diff --git a/toolchain/prelink-cross/Makefile.inc b/toolchain/prelink-cross/Makefile.inc new file mode 100644 index 000000000..634a18b84 --- /dev/null +++ b/toolchain/prelink-cross/Makefile.inc @@ -0,0 +1,8 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +# this is branch cross_prelink_r185 in git +PKG_NAME:= prelink-cross +PKG_VERSION:= 909470ee441237563d6236c505cb2d02ddc48704 +PKG_RELEASE:= 1 +PKG_SITES:= git://git.yoctoproject.org/prelink-cross -- cgit v1.2.3