Skip to content

no_mangle static symbols have improper debug info #33172

Closed
@m4b

Description

@m4b

Repro

  1. cargo new --bin static

  2. cd static

  3. add the following code to main.rs:

    #[no_mangle]
    pub static TEST: u64 = 0xdeadbeef;
    
    pub fn main() {
    println!("TEST: {}", TEST);
    }
  4. cargo build

  5. gdb target/debug/static

  6. break static::main

  7. r

  8. whatis TEST

  9. output: type = <data variable, no debug info>

  10. frown

When TEST is a repr(C) struct, etc., this makes debugging extraordinarily difficult and laborious.

Actual Use Case

I'm implementing the gdb debugger interface specified in /usr/include/link.h, which requires a single symbol, _r_debug to be present in the _DYNAMIC array.

(The symbol is actually not exported either, roughly GLOBAL and in the _DYNAMIC array, which I get around by using a --dynamic-list flag to the linker.)

I don't get around the lack of debug symbols at all, which vexes me.

Metadata

Metadata

Assignees

Labels

A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler 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