Skip to content

Add a test for Mach-O #[link_section] API inherited from LLVM#155517

Open
madsmtm wants to merge 1 commit intorust-lang:mainfrom
madsmtm:test-macho-link-section-attrs
Open

Add a test for Mach-O #[link_section] API inherited from LLVM#155517
madsmtm wants to merge 1 commit intorust-lang:mainfrom
madsmtm:test-macho-link-section-attrs

Conversation

@madsmtm
Copy link
Copy Markdown
Contributor

@madsmtm madsmtm commented Apr 19, 2026

The format of the #[link_section] attribute is under-documented, but on Mach-O, I think it's roughly the following BNF:

LinkSection -> Segment `,` Section (`,` (SectionType (`,` (SectionAttributes)?)?)?)?
Segment -> <0 to 16 bytes>
Section -> <0 to 16 bytes>
SectionType -> `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`
SectionAttributes -> SectionAttribute (`+` SectionAttribute)*
SectionAttribute -> `pure_instructions` | `no_toc` | `strip_static_syms` | `no_dead_strip` | `live_support`, `self_modifying_code` | `debug`

This PR adds a small test for a little part of this.

Once #154429 is resolved, this should make it possible to test rust-lang/rustc_codegen_cranelift#1648 end-to-end.

r? bjorn3

@madsmtm madsmtm added A-linkage Area: linking into static, shared libraries and binaries O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) labels Apr 19, 2026
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2026
@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm force-pushed the test-macho-link-section-attrs branch from 7691a07 to 709530e Compare April 19, 2026 14:32
Comment thread tests/run-make/macho-link-section/foo.rs Outdated
@madsmtm madsmtm force-pushed the test-macho-link-section-attrs branch from 709530e to eae9611 Compare April 19, 2026 21:36
@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm force-pushed the test-macho-link-section-attrs branch from eae9611 to 3695fef Compare April 19, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linkage Area: linking into static, shared libraries and binaries A-run-make Area: port run-make Makefiles to rmake.rs O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants