diff --git a/.travis.yml b/.travis.yml index 8deb01c5..d86cd470 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ matrix: include: - - dist: trusty - dist: xenial language: rust diff --git a/hello-world/src/lib.rs b/hello-world/src/lib.rs index 2413fe0a..e56de246 100644 --- a/hello-world/src/lib.rs +++ b/hello-world/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(alloc)] +#![feature(alloc, const_str_as_bytes)] extern crate alloc; use alloc::borrow::ToOwned; @@ -27,6 +27,7 @@ impl Drop for HelloWorldModule { println!("Goodbye kernel module!"); } } + kernel_module!( HelloWorldModule, author: "Alex Gaynor and Geoffrey Thomas", diff --git a/src/lib.rs b/src/lib.rs index 3cba6a18..7e0383db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,9 +60,9 @@ macro_rules! kernel_module { #[link_section = ".modinfo"] #[allow(non_upper_case_globals)] // TODO: Generate a name the same way the kernel's `__MODULE_INFO` does. - // TODO: This needs to be a `&'static [u8]`, since the kernel defines this as a - // `const char []`. - pub static $name: &'static str = concat!(stringify!($name), "=", $value); + // TODO: This needs to be a `[u8; _]`, since the kernel defines this as a `const char []`. + // See https://github.com/rust-lang/rfcs/pull/2545 + pub static $name: &'static [u8] = concat!(stringify!($name), "=", $value, '\0').as_bytes(); }; } diff --git a/tests/printk/src/lib.rs b/tests/printk/src/lib.rs index 3db1517a..dc0d8f4d 100644 --- a/tests/printk/src/lib.rs +++ b/tests/printk/src/lib.rs @@ -1,4 +1,5 @@ #![no_std] +#![feature(const_str_as_bytes)] #[macro_use] extern crate linux_kernel_module; diff --git a/tests/sysctl/src/lib.rs b/tests/sysctl/src/lib.rs index 45fbc871..84e9a052 100644 --- a/tests/sysctl/src/lib.rs +++ b/tests/sysctl/src/lib.rs @@ -1,4 +1,5 @@ #![no_std] +#![feature(const_str_as_bytes)] use core::sync::atomic::AtomicBool; diff --git a/x86_64-linux-kernel-module.json b/x86_64-linux-kernel-module.json index 93159324..fd5353af 100644 --- a/x86_64-linux-kernel-module.json +++ b/x86_64-linux-kernel-module.json @@ -24,6 +24,7 @@ }, "relocation-model": "static", "relro-level": "full", + "needs-plt": true, "target-c-int-width": "32", "target-endian": "little", "target-family": "unix",