]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: allow not setting extra rpaths in the linux binary
authorJohannes Berg <johannes.berg@intel.com>
Mon, 8 Mar 2021 13:02:37 +0000 (14:02 +0100)
committerRichard Weinberger <richard@nod.at>
Thu, 17 Jun 2021 19:54:15 +0000 (21:54 +0200)
There doesn't seem to be any reason for the rpath being set in
the binaries, at on systems that I tested on. On the other hand,
setting rpath is actually harming binaries in some cases, e.g.
if using nix-based compilation environments where /lib & /lib64
are not part of the actual environment.

Add a new Kconfig option (under EXPERT, for less user confusion)
that allows disabling the rpath additions.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/Kconfig
arch/um/Makefile
arch/x86/Makefile.um

index 328ba973c07d1763ba9056db6c1372ece2e6f658..fe6d898aeb8564cef44cd26d84f98b88f39f2afe 100644 (file)
@@ -106,6 +106,19 @@ config LD_SCRIPT_DYN
        depends on !LD_SCRIPT_STATIC
        select MODULE_REL_CRCS if MODVERSIONS
 
+config LD_SCRIPT_DYN_RPATH
+       bool "set rpath in the binary" if EXPERT
+       default y
+       depends on LD_SCRIPT_DYN
+       help
+         Add /lib (and /lib64 for 64-bit) to the linux binary's rpath
+         explicitly.
+
+         You may need to turn this off if compiling for nix systems
+         that have their libraries in random /nix directories and
+         might otherwise unexpected use libraries from /lib or /lib64
+         instead of the desired ones.
+
 config HOSTFS
        tristate "Host filesystem"
        help
index 1cea46ff9bb78dd1a397e4fceb4a80442c2cc4c9..12a7acef0357c13cb3c215df89c0c07712fefcde 100644 (file)
@@ -118,7 +118,8 @@ archprepare:
        $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h
 
 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
-LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
+LINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie)
+LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib
 
 CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
        -fno-stack-protector $(call cc-option, -fno-stack-protector-all)
index 1db7913795f5168e20126b8b819740d359ebf8fe..b3c1ae084180dc6afab8cecc1fa319fe4a947524 100644 (file)
@@ -44,7 +44,7 @@ ELF_FORMAT := elf64-x86-64
 
 # Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
 
-LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
+LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib64
 LINK-y += -m64
 
 endif