mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
x86/purgatory: Compile purgatory with -D__NO_FORTIFY and -D__DISABLE_EXPORTS
A subsequent patch will add #include <linux/string.h> to <crypto/sha2.h>
to use memzero_explicit() there. This will introduce a conflict with the
purgatory code: purgatory.c includes both, the <crypto/sha2.h> header and
the arch/x86/boot/string.h header. The latter provides its own prototypes
for a lot of string functions which clash with the fortified macros
from <linux/string.h>, causing the compiler to emit errors like this:
In file included from .../linux/include/linux/string.h:383,
from .../linux/include/crypto/sha2.h:10,
from .../linux/arch/x86/purgatory/purgatory.c:14:
.../linux/include/linux/fortify-string.h:576:63: error: expected identifier or ‘(’ before ‘{’ token
576 | p_size_field, q_size_field, op) ({ \
| ^
.../linux/include/linux/fortify-string.h:644:27: note: in expansion of macro ‘__fortify_memcpy_chk’
644 | #define memmove(p, q, s) __fortify_memcpy_chk(p, q, s, \
| ^~~~~~~~~~~~~~~~~~~~
.../linux/arch/x86/purgatory/../boot/string.h:11:7: note: in expansion of macro ‘memmove’
11 | void *memmove(void *dst, const void *src, size_t len);
| ^~~~~~~
.../linux/include/linux/fortify-string.h:208:9: error: expected identifier or ‘(’ before ‘__builtin_choose_expr’
208 | __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)), \
| ^~~~~~~~~~~~~~~~~~~~~
./linux/arch/x86/purgatory/../boot/string.h:23:15: note: in expansion of macro ‘strlen’
23 | extern size_t strlen(const char *s);
| ^~~~~~
To avoid the problem, let's compile the whole code in the purgatory with
-D__NO_FORTIFY, so <linux/string.h> can properly be included from headers
like <crypto/sha2.h> in the purgatory, too.
When compiling/linking with the LLVM tools, and CONFIG_CFI=y, there is
an additional problem during linking:
ld.lld: error: undefined symbol: __memset
>>> referenced by string.c
>>> arch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memset_5)
ld.lld: error: undefined symbol: __memmove
>>> referenced by string.c
>>> arch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memmove_6)
This can be fixed by moving the -D__DISABLE_EXPORTS to the general CFLAGS
of the purgatory, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://patch.msgid.link/20260928083055.104266-2-thuth@redhat.com
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
parent
6df7613758
commit
e5fc547739
|
|
@ -11,8 +11,6 @@ $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
|
|||
$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
|
||||
$(call if_changed_rule,cc_o_c)
|
||||
|
||||
CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
|
||||
|
||||
# When profile-guided optimization is enabled, llvm emits two different
|
||||
# overlapping text sections, which is not supported by kexec. Remove profile
|
||||
# optimization flags.
|
||||
|
|
@ -37,6 +35,7 @@ PURGATORY_CFLAGS := -mcmodel=small -ffreestanding -fno-zero-initialized-in-bss -
|
|||
PURGATORY_CFLAGS += -fpic -fvisibility=hidden
|
||||
PURGATORY_CFLAGS += $(DISABLE_KSTACK_ERASE) -DDISABLE_BRANCH_PROFILING
|
||||
PURGATORY_CFLAGS += -fno-stack-protector
|
||||
PURGATORY_CFLAGS += -D__DISABLE_EXPORTS -D__NO_FORTIFY
|
||||
|
||||
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
|
||||
# in turn leaves some undefined symbols like __fentry__ in purgatory and not
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user