3

Report an error if a `#[no_mangle]`/`#[export_name = ...]` function has the same...

 2 years ago
source link: https://github.com/rust-lang/miri/pull/1832
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

hyd-dev commented 20 days ago

edited

Implements #1776 (comment).

The error looks like this:

error: found `malloc` symbol definition that clashes with a built-in shim
  --> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9
   |
12 |         malloc(0);
   |         ^^^^^^^^^ found `malloc` symbol definition that clashes with a built-in shim
   |
help: the `malloc` symbol is defined here

  --> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:2:1
   |
2  | / extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
3  | |     //~^ HELP the `malloc` symbol is defined here
4  | |     unreachable!()
5  | | }
   | |_^
   = note: inside `main` at tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9

This does not implement "better error messages than we do currently for arg/ABI mismatches" in #1776 (comment) -- I failed to remove all check_arg_count() and check_abi() (they are still used in src/shims/intrinsics.rs and call_dlsym()) and they don't receive the name of the shim.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK