[PATCH 11/17] rust: export generated symbols
From: ojeda@kernel.org
Date: 2021-07-04 20:29:37
Also in:
linux-kbuild, lkml, rust-for-linux
Subsystem:
rust, the rest · Maintainers:
Miguel Ojeda, Linus Torvalds
From: Miguel Ojeda <ojeda@kernel.org>
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 <redacted>
Signed-off-by: Alex Gaynor <redacted>
Co-developed-by: Geoffrey Thomas <redacted>
Signed-off-by: Geoffrey Thomas <redacted>
Co-developed-by: Finn Behrens <redacted>
Signed-off-by: Finn Behrens <redacted>
Co-developed-by: Adam Bratschi-Kaye <redacted>
Signed-off-by: Adam Bratschi-Kaye <redacted>
Co-developed-by: Wedson Almeida Filho <redacted>
Signed-off-by: Wedson Almeida Filho <redacted>
Co-developed-by: Boqun Feng <redacted>
Signed-off-by: Boqun Feng <redacted>
Co-developed-by: Sumera Priyadarsini <redacted>
Signed-off-by: Sumera Priyadarsini <redacted>
Co-developed-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Co-developed-by: Sven Van Asbroeck <redacted>
Signed-off-by: Sven Van Asbroeck <redacted>
Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Boris-Chengbiao Zhou <redacted>
Signed-off-by: Boris-Chengbiao Zhou <redacted>
Co-developed-by: Fox Chen <redacted>
Signed-off-by: Fox Chen <redacted>
Co-developed-by: Ayaan Zaidi <redacted>
Signed-off-by: Ayaan Zaidi <redacted>
Co-developed-by: Douglas Su <redacted>
Signed-off-by: Douglas Su <redacted>
Co-developed-by: Yuki Okushi <redacted>
Signed-off-by: Yuki Okushi <redacted>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
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"
--
2.32.0