Skip to content

Commit 2e8cf29

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 c1a7a26 commit 2e8cf29

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
@@ -92,6 +92,19 @@ config LD_SCRIPT_DYN
9292
depends on !LD_SCRIPT_STATIC
9393
select MODULE_REL_CRCS if MODVERSIONS
9494

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

arch/um/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ archprepare:
118118
$(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h
119119

120120
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
121-
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
121+
LINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie)
122+
LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib
122123

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

arch/x86/Makefile.um

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

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

47-
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
47+
LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib64
4848
LINK-y += -m64
4949

5050
endif

0 commit comments

Comments
 (0)