diff options
| author | bors <bors@rust-lang.org> | 2025-07-10 19:56:08 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-10 19:56:08 +0000 | 
| commit | 2a023bf80a6fbd6a06d5460a34eb247b986286ed (patch) | |
| tree | d5ca6e0ecb9a1b89ddd3fc5cb328f67a51a181fe /tests/ui/linking/export-executable-symbols.rs | |
| parent | a9f2aad0454ef1a06de6588d012517b534540765 (diff) | |
| parent | b5d1b92a8c7241cc6989e3b5d0246654c4065679 (diff) | |
| download | rust-2a023bf80a6fbd6a06d5460a34eb247b986286ed.tar.gz rust-2a023bf80a6fbd6a06d5460a34eb247b986286ed.zip | |
Auto merge of #143746 - matthiaskrgr:rollup-yaojj7t, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang/rust#143446 (use `--dynamic-list` for exporting executable symbols) - rust-lang/rust#143590 (Fix weird rustdoc output when single and glob reexport conflict on a name) - rust-lang/rust#143599 (emit `.att_syntax` when global/naked asm use that option) - rust-lang/rust#143615 (Fix handling of no_std targets in `doc::Std` step) - rust-lang/rust#143632 (fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuildMaxNum FFI declarations) - rust-lang/rust#143640 (Constify `Fn*` traits) - rust-lang/rust#143651 (Win: Use exceptions with empty data for SEH panic exception copies instead of a new panic) - rust-lang/rust#143660 (Disable docs for `compiler-builtins` and `sysroot`) - rust-lang/rust#143665 ([rustdoc-json] Add tests for `#[doc(hidden)]` handling of items.) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/ui/linking/export-executable-symbols.rs')
| -rw-r--r-- | tests/ui/linking/export-executable-symbols.rs | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/tests/ui/linking/export-executable-symbols.rs b/tests/ui/linking/export-executable-symbols.rs new file mode 100644 index 00000000000..aea5527b6a1 --- /dev/null +++ b/tests/ui/linking/export-executable-symbols.rs @@ -0,0 +1,30 @@ +//@ run-pass +//@ only-linux +//@ only-gnu +//@ compile-flags: -Zexport-executable-symbols +//@ edition: 2024 + +// Regression test for <https://github.com/rust-lang/rust/issues/101610>. + +#![feature(rustc_private)] + +extern crate libc; + +#[unsafe(no_mangle)] +fn hack() -> u64 { + 998244353 +} + +fn main() { + unsafe { + let handle = libc::dlopen(std::ptr::null(), libc::RTLD_NOW); + let ptr = libc::dlsym(handle, c"hack".as_ptr()); + let ptr: Option<unsafe fn() -> u64> = std::mem::transmute(ptr); + if let Some(f) = ptr { + assert!(f() == 998244353); + println!("symbol `hack` is found successfully"); + } else { + panic!("symbol `hack` is not found"); + } + } +} | 
