liveBook · Manning

No_mangle

no_mangle is a Rust attribute that prevents name mangling for an item, preserving its symbol name in compiled output.

How 3 Manning books explain it

Refactoring to Rust

The no_mangle attribute prevents the Rust compiler from applying symbol name mangling to an item.

How it is used
Uses unmangled symbols to make Rust functions available to C callers that locate them by name.
How deep it goes
Explains symbol naming and export annotations through function signatures, while leaving the mangling algorithm unexplored.
Examples
Contrasts a C-callable calculator function with an NGINX request handler and an address-passed callback.
What you can do after
Apply it to expose a Rust function by name to C while choosing appropriate visibility, calling conventions, and a collision-resistant name.

Read how Refactoring to Rust explains no_mangle →

Embedded Software with Rust

The Rust no_mangle attribute preserves an item's externally visible symbol name instead of applying name mangling.

How it is used
Preserves linker-visible names for bare-metal startup symbols and Rust functions or data exposed to C.
How deep it goes
Explains name mangling and the attribute’s unsafe qualification, then distinguishes symbol naming from calling conventions and section placement.
Examples
Demonstrates a custom _start entry point, C-callable arithmetic functions, and an exported static constant.
What you can do after
Apply it to expose named symbols and verify an exported static-library function with nm.

Read how Embedded Software with Rust explains no_mangle →

Rust in Action: Systems programming concepts and techniques

no_mangle is a Rust attribute that suppresses compiler name mangling for an item’s externally visible symbol.

How it is used
Controls Rust symbol names when a bare-metal kernel or external component must locate an item predictably.
How deep it goes
Explains symbol strings, name-mangling collisions, and boot failure risk, but stops short of linker-level details.
Examples
Uses a kernel’s panic handler and _start entry point as concrete no_mangle examples.
What you can do after
Apply no_mangle to preserve predictable symbols in a Rust kernel or external-component interface.

Read how Rust in Action: Systems programming concepts and techniques explains no_mangle →

Also covered in

What to know first

Related concepts

Questions about no_mangle

What is no_mangle?

no_mangle is a Rust attribute that prevents name mangling for an item, preserving its symbol name in compiled output.

Which Manning books explain no_mangle?

Refactoring to Rust, Embedded Software with Rust and Rust in Action: Systems programming concepts and techniques.

What should I know before learning no_mangle?

Manning books that teach no_mangle usually introduce Rust first.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.