Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc marks .debug_gdb_scripts as ALLOC, LOAD #41626

Closed
whitequark opened this issue Apr 29, 2017 · 3 comments
Closed

rustc marks .debug_gdb_scripts as ALLOC, LOAD #41626

whitequark opened this issue Apr 29, 2017 · 3 comments

Comments

@whitequark
Copy link
Member

whitequark commented Apr 29, 2017

To reproduce:

echo "fn main(){}" >t.rs
rustc -g t.rs
objdump -h t|grep -A1 debug_gdb_scripts
 16 .debug_gdb_scripts 00000022  000000000003ddc1  000000000003ddc1  0003ddc1  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

This is not a big deal on PCs, but somewhat more important on a microcontroller. On top of that, it produces extremely surprising messages when flashing the firmware via gdb (which is how I discovered it):

Loading section .text, size 0x1ae lma 0x0
Loading section .debug_gdb_scripts, size 0x22 lma 0x1ae

... and the debug script path potentially ends in the non-volatile storage, unnecessarily exposing information about the build environment.

@whitequark
Copy link
Member Author

cc @japaric

@whitequark
Copy link
Member Author

Compare this to the output of clang translating a GDB example:

/* Note: The "MS" section flags are to remove duplicates.  */
#define DEFINE_GDB_PY_SCRIPT(script_name) \
  asm("\
.pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
.byte 1 /* Python */\n\
.asciz \"" script_name "\"\n\
.popsection \n\
");

DEFINE_GDB_PY_SCRIPT("foo.py")
clang -c t.c
objdump -h t.o|grep -A1 debug_gdb_scripts
  1 .debug_gdb_scripts 00000008  0000000000000000  0000000000000000  00000040  2**0
                  CONTENTS, READONLY, DEBUGGING

@whitequark
Copy link
Member Author

Closing as per discussion in #41627 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant