Skip to content

Commit

Permalink
Add a test for issue 47384
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Feb 9, 2022
1 parent af256f2 commit e760877
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/run-make/issue-47384/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-include ../../run-make-fulldeps/tools.mk

# ignore-windows
# 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
12 changes: 12 additions & 0 deletions src/test/run-make/issue-47384/lib.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
7 changes: 7 additions & 0 deletions src/test/run-make/issue-47384/linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SECTIONS
{
.static : ALIGN(4)
{
KEEP(*(.rodata.STATIC));
}
}
1 change: 1 addition & 0 deletions src/test/run-make/issue-47384/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extern crate lib;

0 comments on commit e760877

Please sign in to comment.