[lkml]   [2021]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 11/17] rust: export generated symbols
From: Miguel Ojeda <>

All symbols are reexported reusing the `EXPORT_SYMBOL_GPL` macro
from C. The lists of symbols are generated on the fly.

There are three main sets of symbols to distinguish:

- The ones from the `core` and `alloc` crates (from the Rust
standard library). The code is licensed as Apache/MIT.

- The ones from our abstractions in the `kernel` crate.

- The helpers (already exported since they are not generated).

We export everything as GPL. This ensures we do not mistakenly
expose GPL kernel symbols/features as non-GPL, even indirectly.

Co-developed-by: Alex Gaynor <>
Signed-off-by: Alex Gaynor <>
Co-developed-by: Geoffrey Thomas <>
Signed-off-by: Geoffrey Thomas <>
Co-developed-by: Finn Behrens <>
Signed-off-by: Finn Behrens <>
Co-developed-by: Adam Bratschi-Kaye <>
Signed-off-by: Adam Bratschi-Kaye <>
Co-developed-by: Wedson Almeida Filho <>
Signed-off-by: Wedson Almeida Filho <>
Co-developed-by: Boqun Feng <>
Signed-off-by: Boqun Feng <>
Co-developed-by: Sumera Priyadarsini <>
Signed-off-by: Sumera Priyadarsini <>
Co-developed-by: Michael Ellerman <>
Signed-off-by: Michael Ellerman <>
Co-developed-by: Sven Van Asbroeck <>
Signed-off-by: Sven Van Asbroeck <>
Co-developed-by: Gary Guo <>
Signed-off-by: Gary Guo <>
Co-developed-by: Boris-Chengbiao Zhou <>
Signed-off-by: Boris-Chengbiao Zhou <>
Co-developed-by: Fox Chen <>
Signed-off-by: Fox Chen <>
Co-developed-by: Ayaan Zaidi <>
Signed-off-by: Ayaan Zaidi <>
Co-developed-by: Douglas Su <>
Signed-off-by: Douglas Su <>
Co-developed-by: Yuki Okushi <>
Signed-off-by: Yuki Okushi <>
Signed-off-by: Miguel Ojeda <>
rust/exports.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 rust/exports.c

diff --git a/rust/exports.c b/rust/exports.c
new file mode 100644
index 00000000000..d7dff1b3b91
--- /dev/null
+++ b/rust/exports.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+// A hack to export Rust symbols for loadable modules without having to redo
+// the entire `include/linux/export.h` logic in Rust.
+// This requires the Rust's new/future `v0` mangling scheme because the default
+// one ("legacy") uses invalid characters for C identifiers (thus we cannot use
+// the `EXPORT_SYMBOL_*` macros).
+#include <linux/module.h>
+#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym);
+#include "exports_core_generated.h"
+#include "exports_alloc_generated.h"
+#include "exports_kernel_generated.h"
 \ /
  Last update: 2021-07-04 22:31    [W:0.796 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site