Add a test for issue 47384

This commit is contained in:
Gary Guo 2022-02-09 00:02:51 +00:00
parent fbc45b650a
commit 419e3ba97b
4 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,12 @@
-include ../../run-make-fulldeps/tools.mk
# only-linux
# ignore-cross-compile
all: main.rs
$(RUSTC) --crate-type lib lib.rs
$(RUSTC) --crate-type cdylib -Clink-args="-Tlinker.ld" main.rs
# Ensure `#[used]` and `KEEP`-ed section is there
objdump -s -j".static" $(TMPDIR)/libmain.so
# Ensure `#[no_mangle]` symbol is there
nm $(TMPDIR)/libmain.so | $(CGREP) bar

View File

@ -0,0 +1,12 @@
mod foo {
#[link_section = ".rodata.STATIC"]
#[used]
static STATIC: [u32; 10] = [1; 10];
}
mod bar {
#[no_mangle]
extern "C" fn bar() -> i32 {
0
}
}

View File

@ -0,0 +1,7 @@
SECTIONS
{
.static : ALIGN(4)
{
KEEP(*(.rodata.STATIC));
}
}

View File

@ -0,0 +1 @@
extern crate lib;