Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
arm64: Switch to CROSS_COMPILE_COMPAT for vDSO32 compilation
Browse files Browse the repository at this point in the history
Preparing for upstream commit 0fa97e9403c767a4af63cfb5a3badbbe69426085
("arm64: vdso32: Allow ld.lld to properly link the VDSO") and more.

Signed-off-by: Nauval Rizky <enuma.alrizky@gmail.com>
Signed-off-by: shygosh <mossynine@gmail.com>
  • Loading branch information
nullxception authored and shygosh committed Mar 22, 2024
1 parent 4079878 commit 27050d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1471,21 +1471,21 @@ config COMPAT_VDSO
help
Warning: a 32-bit toolchain is necessary to build the vDSO. You
must explicitly define which toolchain should be used by setting
CROSS_COMPILE_ARM32 to the prefix of the 32-bit toolchain (same format
as CROSS_COMPILE). If CROSS_COMPILE_ARM32 is empty, a warning will be
CROSS_COMPILE_COMPAT to the prefix of the 32-bit toolchain (same format
as CROSS_COMPILE). If CROSS_COMPILE_COMPAT is empty, a warning will be
printed and the kernel will be built as if COMPAT_VDSO had not been
set. If CROSS_COMPILE_ARM32 is set to an invalid prefix, compilation
set. If CROSS_COMPILE_COMPAT is set to an invalid prefix, compilation
will be aborted.

Provide a vDSO to 32-bit processes. It includes the symbols provided
by the vDSO from the 32-bit kernel, so that a 32-bit libc can use
the compat vDSO without modification. It also provides sigreturn
trampolines, replacing the sigreturn page.

config CROSS_COMPILE_ARM32
config CROSS_COMPILE_COMPAT
string "32-bit toolchain prefix"
help
Same as setting CROSS_COMPILE_ARM32 in the environment, but saved for
Same as setting CROSS_COMPILE_COMPAT in the environment, but saved for
future builds. The environment variable overrides this config option.

endmenu
Expand Down
24 changes: 12 additions & 12 deletions arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,33 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
endif

ifeq ($(CONFIG_COMPAT_VDSO), y)
CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%)
CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT:"%"=%)

# Check that the user has provided a valid prefix for the 32-bit toolchain.
# To prevent selecting the system $(cc-name) by default, the prefix is not
# allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the
# system $(cc-name) is actually the 32-bit ARM compiler to be used, the
# variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/).
# variable can be set to the dirname (e.g. CROSS_COMPILE_COMPAT=/usr/bin/).
# Note: this Makefile is read both before and after regenerating the config
# (if needed). Any warning appearing before the config has been regenerated
# should be ignored. If the error is triggered and you set
# CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value
# when invoking make and fix CONFIG_CROSS_COMPILE_ARM32.
ifeq ($(CROSS_COMPILE_ARM32),)
$(error CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built)
# CONFIG_CROSS_COMPILE_COMPAT, set CROSS_COMPILE_COMPAT to an appropriate value
# when invoking make and fix CONFIG_CROSS_COMPILE_COMPAT.
ifeq ($(CROSS_COMPILE_COMPAT),)
$(error CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
else ifeq ($(cc-name),clang)
export CLANG_TRIPLE_ARM32 ?= $(CROSS_COMPILE_ARM32)
export CLANG_TRIPLE_ARM32 ?= $(CROSS_COMPILE_COMPAT)
export CLANG_TARGET_ARM32 := --target=$(notdir $(CLANG_TRIPLE_ARM32:%-=%))
export GCC_TOOLCHAIN32_DIR := $(dir $(shell which $(CROSS_COMPILE_ARM32)ld))
export GCC_TOOLCHAIN32_DIR := $(dir $(shell which $(CROSS_COMPILE_COMPAT)ld))
export GCC_TOOLCHAIN32 := $(realpath $(GCC_TOOLCHAIN32_DIR)/..)
export CLANG_PREFIX32 := --prefix=$(GCC_TOOLCHAIN32_DIR)$(notdir $(CROSS_COMPILE_ARM32))
export CLANG_PREFIX32 := --prefix=$(GCC_TOOLCHAIN32_DIR)$(notdir $(CROSS_COMPILE_COMPAT))
export CLANG_GCC32_TC := --gcc-toolchain=$(GCC_TOOLCHAIN32)
export CONFIG_VDSO32 := y
vdso32 := -DCONFIG_VDSO32=1
else ifeq ($(shell which $(CROSS_COMPILE_ARM32)$(cc-name) 2> /dev/null),)
$(error $(CROSS_COMPILE_ARM32)$(cc-name) not found, check CROSS_COMPILE_ARM32)
else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)$(cc-name) 2> /dev/null),)
$(error $(CROSS_COMPILE_COMPAT)$(cc-name) not found, check CROSS_COMPILE_COMPAT)
else
export CROSS_COMPILE_ARM32
export CROSS_COMPILE_COMPAT
export CONFIG_VDSO32 := y
vdso32 := -DCONFIG_VDSO32=1
endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/vdso32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ifeq ($(cc-name),clang)
CC_ARM32 := $(CC) $(CLANG_TARGET_ARM32) -no-integrated-as $(CLANG_GCC32_TC) $(CLANG_PREFIX32)
else
CC_ARM32 := $(CROSS_COMPILE_ARM32)$(cc-name)
CC_ARM32 := $(CROSS_COMPILE_COMPAT)$(cc-name)
endif

# Same as cc-*option, but using CC_ARM32 instead of CC
Expand Down

0 comments on commit 27050d2

Please sign in to comment.