Skip to content

Commit 0a7306d

Browse files
committed
Add link_section attribute template rules
1 parent f81f9f8 commit 0a7306d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/abi.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ The *`link_section` [attribute]* specifies the section of the object file that a
103103
r[abi.link_section.syntax]
104104
The `link_section` attribute uses the [MetaNameValueStr] syntax to specify the section name.
105105
106+
r[abi.link_section.allowed-positions]
107+
The `link_section` attribute may only be applied to:
108+
109+
- [Static items][items.static]
110+
- [Free functions][items.fn]
111+
- [Inherent associated functions][items.associated.fn]
112+
- [Trait impl functions][items.impl.trait]
113+
- [Trait definition functions][items.traits] with a body
114+
115+
> [!NOTE]
116+
> `rustc` currently warns in other positions, but this may be rejected in the future.
117+
118+
r[abi.link_section.duplicates]
119+
Only the last instance of `link_section` on an item is honored. Previous `link_section` attributes are ignored.
120+
121+
> [!NOTE]
122+
> `rustc` currently warns on preceding duplicate `link_section` attributes. This may become an error in the future.
123+
106124
r[abi.link_section.unsafe]
107125
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.
108126

0 commit comments

Comments
 (0)