Skip to content

Commit a867b8d

Browse files
committed
Add a test for issue 47384
1 parent fbc45b6 commit a867b8d

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-include ../../run-make-fulldeps/tools.mk
2+
3+
# ignore-windows
4+
# ignore-cross-compile
5+
6+
all: main.rs
7+
$(RUSTC) --crate-type lib lib.rs
8+
$(RUSTC) --crate-type cdylib -Clink-args="-Tlinker.ld" main.rs
9+
# Ensure `#[used]` and `KEEP`-ed section is there
10+
objdump -s -j".static" $(TMPDIR)/libmain.so
11+
# Ensure `#[no_mangle]` symbol is there
12+
nm $(TMPDIR)/libmain.so | $(CGREP) bar

src/test/run-make/issue-47384/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod foo {
2+
#[link_section = ".rodata.STATIC"]
3+
#[used]
4+
static STATIC: [u32; 10] = [1; 10];
5+
}
6+
7+
mod bar {
8+
#[no_mangle]
9+
extern "C" fn bar() -> i32 {
10+
0
11+
}
12+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SECTIONS
2+
{
3+
.static : ALIGN(4)
4+
{
5+
KEEP(*(.rodata.STATIC));
6+
}
7+
}

src/test/run-make/issue-47384/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern crate lib;

0 commit comments

Comments
 (0)