Skip to content

Commit 61d9231

Browse files
committed
Auto merge of #69168 - brainlock:test-textrel-regression, r=Mark-Simulacrum,tmandry
add regression test for issue #68794 This is a minimal regression test for the issue #68794: "TEXTREL in i686", which was fixed with e86019c. The test links a minimal rust static library into a shared library, and checks that the linker didn't have to add the TEXTREL flag.
2 parents dbef353 + ea2ffda commit 61d9231

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Regression test for issue #68794
2+
#
3+
# Verify that no text relocations are accidentally introduced by linking a
4+
# minimal rust staticlib.
5+
#
6+
# The test links a rust static library into a shared library, and checks that
7+
# the linker doesn't have to flag the resulting file as containing TEXTRELs.
8+
9+
-include ../tools.mk
10+
11+
# only-linux
12+
13+
all:
14+
$(RUSTC) foo.rs
15+
$(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
16+
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
17+
readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void foo();
2+
3+
int main() {
4+
foo();
5+
return 0;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_type = "staticlib"]
2+
3+
#[no_mangle]
4+
pub extern "C" fn foo(x: u32) {
5+
// using the println! makes it so that enough code from the standard
6+
// library is included (see issue #68794)
7+
println!("foo: {}", x);
8+
}

0 commit comments

Comments
 (0)