summaryrefslogtreecommitdiffstats
path: root/package/pkg-generic.mk
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2015-11-13 22:48:51 +0100
committerPeter Korsgaard <peter@korsgaard.com>2015-11-18 22:47:10 +0100
commit5c0c38522605413170a10c45ac08d46c4ed076af (patch)
treeabc523fd7be104cafce85ab769f9f6785cd3b81e /package/pkg-generic.mk
parent2619ccbb948c6c7c383e95607e82eb1c304992d1 (diff)
downloadbuildroot-5c0c38522605413170a10c45ac08d46c4ed076af.tar.gz
buildroot-5c0c38522605413170a10c45ac08d46c4ed076af.zip
core: check host executables have appropriate RPATH
When we build our host programs, and they depend on a host library we also build, we want to ensure that program actually uses that library at runtime, and not the one from the system. We currently ensure that in two ways: - we add a RPATH tag that points to our host library directory, - we export LD_LIBRARY_PATH to point to that same directory. With these two in place, we're pretty much confident that our host libraries will be used by our host programs. However, it turns our that not all the host programs we build end up with an RPATH tag: - some packages do not use our $(HOST_LDFLAGS) - some packages' build system are oblivious to those LDFLAGS In this case, there are two situations: - the program is not linked to one of our host libraries: it in fact does not need an RPATH tag [0] - the program actually uses one of our host libraries: in that case it should have had an RPATH tag pointing to the host directory. For libraries, they only need an RPATH if they depend on another library that is not installed in the standard library path. However, any system library will already be in the standard library path, and any library we install ourselves is in $(HOST_DIR)/usr/lib so already in RPATH. We add a new support script that checks that all ELF executables have a proper DT_RPATH (or DT_RUNPATH) tag when they link to our host libraries, and reports those file that are missing an RPATH. If a file missing an RPATH is an executable, the script aborts; if only libraries are are missing an RPATH, the script does not abort. [0] Except if it were to dlopen() it, of course, but the only program I'm aware of that does that is openssl, and it has a correct RPATH tag. [Peter: reworded as suggested by Arnout, fix HOT_DIR typo in comment] Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Arnout Vandecappelle <arnout@mind.be> Cc: Peter Korsgaard <jacmet@uclibc.org> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'package/pkg-generic.mk')
-rw-r--r--package/pkg-generic.mk8
1 files changed, 8 insertions, 0 deletions
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 08f4f31532..357a5c7b9e 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -87,6 +87,14 @@ define step_pkg_size
endef
GLOBAL_INSTRUMENTATION_HOOKS += step_pkg_size
+# This hook checks that host packages that need libraries that we build
+# have a proper DT_RPATH or DT_RUNPATH tag
+define check_host_rpath
+ $(if $(filter install-host,$(2)),\
+ $(if $(filter end,$(1)),support/scripts/check-host-rpath $(3) $(HOST_DIR)))
+endef
+GLOBAL_INSTRUMENTATION_HOOKS += check_host_rpath
+
# User-supplied script
ifneq ($(BR2_INSTRUMENTATION_SCRIPTS),)
define step_user
OpenPOWER on IntegriCloud