File tree Expand file tree Collapse file tree 3 files changed +34
-19
lines changed
src/test/run-make/extern-fn-reachable Expand file tree Collapse file tree 3 files changed +34
-19
lines changed Original file line number Diff line number Diff line change 1+ -include ../tools.mk
2+
3+ all :
4+ $(RUSTC ) dylib.rs -o $(TMPDIR ) /libdylib.so
5+ $(RUSTC ) main.rs
6+ $(call RUN,main)
Original file line number Diff line number Diff line change 1+ // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ crate_type = "dylib" ]
12+ #![ allow( dead_code) ]
13+
14+ #[ no_mangle] pub extern "C" fn fun1 ( ) { }
15+ #[ no_mangle] extern "C" fn fun2 ( ) { }
16+
17+ mod foo {
18+ #[ no_mangle] pub extern "C" fn fun3 ( ) { }
19+ }
20+ pub mod bar {
21+ #[ no_mangle] pub extern "C" fn fun4 ( ) { }
22+ }
23+
24+ #[ no_mangle] pub fn fun5 ( ) { }
Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- // ignore-win32 dynamic_lib can read dllexported symbols only
12- // ignore-linux apparently dlsym doesn't work on program symbols?
13- // ignore-android apparently dlsym doesn't work on program symbols?
14- // ignore-freebsd apparently dlsym doesn't work on program symbols?
15-
1611use std:: unstable:: dynamic_lib:: DynamicLibrary ;
17-
18- #[ no_mangle] pub extern "C" fn fun1 ( ) { }
19- #[ no_mangle] extern "C" fn fun2 ( ) { }
20-
21- mod foo {
22- #[ no_mangle] pub extern "C" fn fun3 ( ) { }
23- }
24- pub mod bar {
25- #[ no_mangle] pub extern "C" fn fun4 ( ) { }
26- }
27-
28- #[ no_mangle] pub fn fun5 ( ) { }
12+ use std:: os;
2913
3014pub fn main ( ) {
3115 unsafe {
32- let a = DynamicLibrary :: open ( None ) . unwrap ( ) ;
16+ let path = Path :: new ( "libdylib.so" ) ;
17+ let a = DynamicLibrary :: open ( Some ( & path) ) . unwrap ( ) ;
3318 assert ! ( a. symbol:: <int>( "fun1" ) . is_ok( ) ) ;
3419 assert ! ( a. symbol:: <int>( "fun2" ) . is_err( ) ) ;
3520 assert ! ( a. symbol:: <int>( "fun3" ) . is_err( ) ) ;
3621 assert ! ( a. symbol:: <int>( "fun4" ) . is_ok( ) ) ;
37- assert ! ( a. symbol:: <int>( "fun5" ) . is_err ( ) ) ;
22+ assert ! ( a. symbol:: <int>( "fun5" ) . is_ok ( ) ) ;
3823 }
3924}
You can’t perform that action at this time.
0 commit comments