Skip to content

Commit 5ce38b4

Browse files
committed
Showcase platform-specificness in link_section example
1 parent d66a8fd commit 5ce38b4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/abi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ The *`link_section` attribute* specifies the section of the object file that a
9696
r[abi.link_section.syntax]
9797
The `link_section` attribute uses the [MetaNameValueStr] syntax to specify the section name.
9898

99-
<!-- no_run: don't link. The format of the section name is platform-specific. -->
100-
```rust,no_run
99+
```rust
101100
#[unsafe(no_mangle)]
102-
#[unsafe(link_section = ".example_section")]
101+
#[cfg_attr(target_os = "linux", unsafe(link_section = ".example_section"))]
102+
#[cfg_attr(target_os = "macos", unsafe(link_section = "__DATA,example_section"))]
103103
pub static VAR1: u32 = 1;
104104
```
105105

0 commit comments

Comments
 (0)