Skip to content

global_asm! should document that it doesn't guarantee section placement #138247

Closed
@Qix-

Description

@Qix-

Location

https://doc.rust-lang.org/stable/core/arch/macro.global_asm.html

Summary

Ran into a surprising bug today - global_asm! stuck some executable code into .rodata under release mode. The fix was simple - just needed to add a .section .text directive, but was surprising and neither the docs nor the book seem to mention this (maybe I missed it).

I documented my findings here: https://github.com/oro-os/development-notes/blob/master/Development%20Notes/x86/Scheduler%20Refactor%20(Mar%20'25).md#9-march-2025-fun-with-global_asm-linkage

Would you accept a PR to add a note about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-inline-assemblyArea: Inline assembly (`asm!(…)`)T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions