Skip to content

Commit f922c4a

Browse files
Ard Biesheuveltorvalds
authored andcommitted
module: allow symbol exports to be disabled
To allow existing C code to be incorporated into the decompressor or the UEFI stub, introduce a CPP macro that turns all EXPORT_SYMBOL_xxx declarations into nops, and #define it in places where such exports are undesirable. Note that this gets rid of a rather dodgy redefine of linux/export.h's header guard. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ard Biesheuvel <[email protected]> Acked-by: Nicolas Pitre <[email protected]> Acked-by: Michael Ellerman <[email protected]> Reviewed-by: Will Deacon <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: James Morris <[email protected]> Cc: James Morris <[email protected]> Cc: Jessica Yu <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Kees Cook <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Russell King <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Garnier <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 271ca78 commit f922c4a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

arch/x86/boot/compressed/kaslr.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
* _ctype[] in lib/ctype.c is needed by isspace() of linux/ctype.h.
2424
* While both lib/ctype.c and lib/cmdline.c will bring EXPORT_SYMBOL
2525
* which is meaningless and will cause compiling error in some cases.
26-
* So do not include linux/export.h and define EXPORT_SYMBOL(sym)
27-
* as empty.
2826
*/
29-
#define _LINUX_EXPORT_H
30-
#define EXPORT_SYMBOL(sym)
27+
#define __DISABLE_EXPORTS
3128

3229
#include "misc.h"
3330
#include "error.h"

drivers/firmware/efi/libstub/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
2424
-D__NO_FORTIFY \
2525
$(call cc-option,-ffreestanding) \
2626
$(call cc-option,-fno-stack-protector) \
27+
-D__DISABLE_EXPORTS
2728

2829
GCOV_PROFILE := n
2930
KASAN_SANITIZE := n

include/linux/export.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ extern struct module __this_module;
6666
__attribute__((section("___ksymtab" sec "+" #sym), used)) \
6767
= { (unsigned long)&sym, __kstrtab_##sym }
6868

69-
#if defined(__KSYM_DEPS__)
69+
#if defined(__DISABLE_EXPORTS)
70+
71+
/*
72+
* Allow symbol exports to be disabled completely so that C code may
73+
* be reused in other execution contexts such as the UEFI stub or the
74+
* decompressor.
75+
*/
76+
#define __EXPORT_SYMBOL(sym, sec)
77+
78+
#elif defined(__KSYM_DEPS__)
7079

7180
/*
7281
* For fine grained build dependencies, we want to tell the build system

0 commit comments

Comments
 (0)