Skip to content

Commit d0dc4f9

Browse files
committed
Document Mach-O link section format
1 parent 18d4246 commit d0dc4f9

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/abi.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,35 @@ r[abi.link_section.edition2024]
117117
> [!EDITION-2024]
118118
> Before the 2024 edition it is allowed to use the `link_section` attribute without the `unsafe` qualification.
119119
120+
r[abi.link_section.format]
121+
The format of the `link_section` attribute is platform-specific, and the
122+
supported options varies depending on the underlying object file format.
123+
124+
r[abi.link_section.mach-o]
125+
### Link section Mach-O format
126+
127+
<!-- Parsing done by LLVM in https://github.com/llvm/llvm-project/blob/llvmorg-22.1.3/llvm/lib/MC/MCSectionMachO.cpp -->
128+
r[abi.link_section.mach-o.syntax]
129+
```grammar,attributes
130+
MachOLinkSection -> MachOSegment `,` MachOSection (`,` (MachOSectionType (`,` (MachOSectionAttributes)?)?)?)?
131+
132+
MachOSegment -> <0 to 16 bytes>
133+
134+
MachOSection -> <0 to 16 bytes>
135+
136+
MachOSectionType -> `regular` | `zerofill` | `cstring_literals` | `4byte_literals` | `8byte_literals` | `literal_pointers` | `non_lazy_symbol_pointers` | `lazy_symbol_pointers` | `symbol_stubs` | `mod_init_funcs` | `mod_term_funcs` | `coalesced` | `interposing` | `16byte_literals` | `thread_local_regular` | `thread_local_zerofill` | `thread_local_variables` | `thread_local_variable_pointers` | `thread_local_init_function_pointers`
137+
138+
MachOSectionAttributes -> MachOSectionAttribute (`+` MachOSectionAttribute)*
139+
140+
MachOSectionAttribute -> `pure_instructions` | `no_toc` | `strip_static_syms` | `no_dead_strip` | `live_support`, `self_modifying_code` | `debug`
141+
```
142+
143+
r[abi.link_section.mach-o.intro]
144+
Mach-O has four configurable fields: the segment, the section, the section type and the section attributes.
145+
146+
r[abi.link_section.mach-o.default-type]
147+
The section type defaults to `regular` if not set.
148+
120149
r[abi.export_name]
121150
## The `export_name` attribute
122151

0 commit comments

Comments
 (0)