`global_asm!` blocks have weird file/line mappings
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
The report provides a reproducer in src/main.rs using core::arch::global_asm!, plus symbol and address lookup output from rust-objdump and addr2line. Start by reproducing the mismatch and inspecting the debug line information around asm_func at address 0x530. Done means stepping through asm_func reports its correct symbol and source location instead of unrelated libcore mappings.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I tried this code:
cargo new --bin asm-sample
cd asm-sample
cargo add cortex-m-rt
cargo add semihosting --features=stdio
cat > src/main.rs << EOF
#![no_std]
#![no_main]
#[cortex_m_rt::entry]
fn main() -> ! {
semihosting::println!("Hello!");
asm_func();
semihosting::process::exit(0);
}
unsafe extern "C" {
safe fn asm_func();
}
core::arch::global_asm!(r#"
.text
.global asm_func
.type asm_func, %function
.p2align 2
asm_func:
.fnstart
.cfi_sections .debug_frame
.cfi_startproc
nop
nop
bx lr
.size asm_func, . - asm_func
.cfi_endproc
"#);
#[panic_handler]
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
semihosting::println!("PANIC!: {}", info);
semihosting::process::exit(1);
}
EOF
cat > memory.x << EOF
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 4M
RAM : ORIGIN = 0x20000000, LENGTH = 4M
}
EOF
mkdir .cargo
cat > .cargo/config.toml << EOF
[build]
target = ["thumbv7em-none-eabihf"]
[target.thumbv7em-none-eabihf]
runner = [
"qemu-system-arm",
"-machine", "mps2-an386",
"-cpu", "cortex-m4",
"-semihosting",
"-display", "none",
"-kernel"
]
EOF
cat > build.rs << EOF
fn main() {
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
std::fs::write(out.join("memory.x"), include_bytes!("memory.x")).expect("Writing memory.x");
println!("cargo::rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg=-Tlink.x");
println!("cargo:rustc-link-search={}", out.display());
}
EOF
cat > command.gdb << EOF
target remote :1234
break asm_func
layout split
continue
EOF
echo "In another window run 'rust-gdb -x command.gdb ./target/thumbv7em-none-eabihf/debug/asm-sample'"
cargo run -- -s -S
I expected to see this happen: stepping through asm_func shows the right symbol name and file/line info
Instead, this happened: I get shown random symbols from libcore, and lots of errors
warning: (Internal error: pc 0x400 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x400 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x400 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
(gdb) bt
#0 0x00000530 in core::num::imp::flt2dec::strategy::grisu::format_shortest_opt ()
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
#1 0x000005a8 in asm_sample::__cortex_m_rt_main () at src/main.rs:7
#2 0x000005de in asm_sample::__cortex_m_rt_main_trampoline () at src/main.rs:4
warning: (Internal error: pc 0x530 in read in CU, but not in symtab.)
Where did it get core::num::imp::flt2dec::strategy::grisu::format_shortest_opt from? I'm in asm_func.
I note the same issue comes from addr2line:
$ rust-objdump -t ./target/thumbv7em-none-eabihf/debug/asm-sample | grep asm_func
00000530 g F .text 00000006 asm_func
$ arm-none-eabi-addr2line -e ./target/thumbv7em-none-eabihf/debug/asm-sample 0x530
/rustc/58cf8f9c35b355199727627d07ae34a4e2846d67/library/core/src/num/imp/int_log10.rs:90
My Rust code at least appears to be mapped to the right file (and line 4 is right, but line 33 seems wrong):
$ rust-objdump -Ct ./target/thumbv7em-none-eabihf/debug/asm-sample | grep main
0000058e l F .text 00000048 asm_sample::__cortex_m_rt_main
000005d6 g F .text 00000008 main
$ arm-none-eabi-addr2line -e ./target/thumbv7em-none-eabihf/debug/asm-sample 0x583 0x5d6
/Users/jonathan/Documents/asm-bug/asm-sample/src/main.rs:33
/Users/jonathan/Documents/asm-bug/asm-sample/src/main.rs:4
Meta
rustc --version --verbose:
rustc --version -v
rustc 1.99.1 (58cf8f9c3 2026-10-13)
binary: rustc
commit-hash: 58cf8f9c35b355199727627d07ae34a4e2846d67
commit-date: 2026-10-13
host: aarch64-apple-darwin
release: 1.99.1
LLVM version: 23.1.1
- Lenguaje dominante
- Rust
- Estrellas
- 122k
- Forks
- 16.7k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 515
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rust
-
Remove unnecessary parentheses when suggesting to remove '&' from a patternPosiblemente ocupada @BartSimpson001 la tomó hace 1 día. AbiertoA-diagnostics D-invalid-suggestion T-compiler
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`Posiblemente ocupada @ChrisDenton la tomó hace 11 días. AbiertoA-filesystem C-bug O-windows T-libs
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
rust-lang/rust#165504 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
relnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/rust
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
antithesishq/bombadil#473 ·
Los mantenedores suelen responder en 2 días
-
bench/api.sh exec test fails with curl exit 52, and --ignore-failure still records the timingsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
libracoder/kiri#669 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 5 días
-
autofixer: follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
tursodatabase/turso#12217 ·
Los mantenedores suelen responder en 1 día
-
Declare the CMS schema library in the optional recipients extraPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea:python in-progress
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
yhay81/pyropdf#1005 · 2 comentarios ·
Los mantenedores suelen responder en 1 día