Skip to content

Commit 944458e

Browse files
jmberg-intelSasha Levin
authored and
Sasha Levin
committed
um: allow not setting extra rpaths in the linux binary
[ Upstream commit 386093c ] 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 <[email protected]> Signed-off-by: Richard Weinberger <[email protected]> Stable-dep-of: 846cfbe ("um: Fix adding '-no-pie' for clang") Signed-off-by: Sasha Levin <[email protected]>
1 parent b345d38 commit 944458e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

arch/um/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ config LD_SCRIPT_DYN
8888
depends on !LD_SCRIPT_STATIC
8989
select MODULE_REL_CRCS if MODVERSIONS
9090

91+
config LD_SCRIPT_DYN_RPATH
92+
bool "set rpath in the binary" if EXPERT
93+
default y
94+
depends on LD_SCRIPT_DYN
95+
help
96+
Add /lib (and /lib64 for 64-bit) to the linux binary's rpath
97+
explicitly.
98+
99+
You may need to turn this off if compiling for nix systems
100+
that have their libraries in random /nix directories and
101+
might otherwise unexpected use libraries from /lib or /lib64
102+
instead of the desired ones.
103+
91104
config HOSTFS
92105
tristate "Host filesystem"
93106
help

arch/um/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ archheaders:
119119
archprepare: include/generated/user_constants.h
120120

121121
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
122-
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
122+
LINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie)
123+
LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib
123124

124125
CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
125126
$(call cc-option, -fno-stack-protector,) \

arch/x86/Makefile.um

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ELF_FORMAT := elf64-x86-64
5151

5252
# Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
5353

54-
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
54+
LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib64
5555
LINK-y += -m64
5656

5757
# Do unit-at-a-time unconditionally on x86_64, following the host

0 commit comments

Comments
 (0)