Open seritools opened 2 months ago
I believe this is because lld-link
(and rust-lld
by extension) doesn't discard the .retplne
section and instead retains it in the final binary without any attributes set. Merging the section with e.g. INIT
or .rdata
fixes issue.
You'll also need to manually specify sections as non-pageable since the /kernel
flag in lld-link
doesn't do anything yet (see https://github.com/DropDemBits/rust-ndis-examples/blob/c09e42f87c749be338305223f7ebf832a3e4d57b/driver/wdf-kmdf-build/src/lib.rs#L43 for an example).
Not sure if this would be in scope for the repo, but would be nice to have documented somewhere.
I wasn't able to get a valid kernel driver binary going. Even the minimal
return 0
DriverEntry example resulted in:It turns out I had a linker override set in my .cargo\config.toml:
This which works fine for user-mode rust application, but apparently doesn't support all the linker args for kernel drivers correctly.