Skip to content

Commit f81f9f8

Browse files
committed
Move link_section example to the intro
1 parent 24fedea commit f81f9f8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/abi.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ r[abi.link_section]
9090
## The `link_section` attribute
9191

9292
r[abi.link_section.intro]
93+
The *`link_section` [attribute]* specifies the section of the object file that a [function] or [static]'s content will be placed into.
94+
95+
> [!EXAMPLE]
96+
> <!-- no_run: don't link. The format of the section name is platform-specific. -->
97+
> ```rust,no_run
98+
> #[unsafe(no_mangle)]
99+
> #[unsafe(link_section = ".example_section")]
100+
> pub static VAR1: u32 = 1;
101+
> ```
93102
94103
r[abi.link_section.syntax]
95104
The `link_section` attribute uses the [MetaNameValueStr] syntax to specify the section name.
96-
The *`link_section` [attribute]* specifies the section of the object file that a [function] or [static]'s content will be placed into.
97-
98-
<!-- no_run: don't link. The format of the section name is platform-specific. -->
99-
```rust,no_run
100-
#[unsafe(no_mangle)]
101-
#[unsafe(link_section = ".example_section")]
102-
pub static VAR1: u32 = 1;
103-
```
104105
105106
r[abi.link_section.unsafe]
106107
This attribute is unsafe as it allows users to place data and code into sections of memory not expecting them, such as mutable data into read-only areas.

0 commit comments

Comments
 (0)