Open
Description
If I build:
fn main() {}
with rustc -g --crate-type bin --emit obj -o t.o t.rs
, and look at the output of readelf -St t.o
I see:
[27] .debug_gdb_scripts
PROGBITS PROGBITS 0000000000000000 0000000000000270 0
0000000000000022 0000000000000001 0 1
[0000000000000032]: ALLOC, MERGE, STRINGS
According to #41627, this is not supposed to be an alloc section (ie, loaded into memory), but only present in the object file.
Having this section loaded isn't a huge problem in itself, but when combined with --link-arg -Wl,--strip-all
(or --strip-debug
) it triggers a crash in lld: https://bugs.llvm.org//show_bug.cgi?id=44878
There are lld fixes pending (https://reviews.llvm.org/D74510, https://reviews.llvm.org/D91291) (lld is already fixed), but it still seems like making .debug_gdb_scripts alloc is unintended.
Meta
rustc --version --verbose
:
rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
Metadata
Metadata
Assignees
Labels
Area: Debugging information in compiled programs (DWARF, PDB, etc.)Area: linking into static, shared libraries and binariesCategory: This is a bug.Issue: Problems and improvements with respect to binary size of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jsgf commentedon Jan 15, 2021
This is basically a regression of issue #41626
cc @whitequark
nagisa commentedon Jan 15, 2021
somewhat relevant is #77961
I wouldn't be surprised if somebody went ahead and marked it as allocatable so that the linker preserves it in the final binary at all...
bjorn3 commentedon Apr 15, 2021
A symbol in this section is directly referenced in the main shim using
read_volatile
to prevent the linker from gc'ing it.rust/compiler/rustc_codegen_ssa/src/base.rs
Line 408 in f1ca558
rust/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
Lines 14 to 28 in 673d0db
jsgf commentedon Apr 18, 2021
OK, so it is supposed to be alloc then.
eddyb commentedon Apr 30, 2021
That looks like an ancient way to emulate the
#[used]
attribute - could we maybe do that instead?bjorn3 commentedon Apr 30, 2021
Does not result in an executable with an
.abc
section ofFOO
symbol. Executables never export any symbols except formain
and certain symbols used by libc or created by the linker itself. Because of this--gc-sections
will simply gc the.abc
section.From the linked rfc: