Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report an error if a #[no_mangle]/#[export_name = ...] function has the same symbol name as a built-in shim #1832

Merged
merged 11 commits into from Jun 15, 2021

Conversation

ghost
Copy link

@ghost ghost commented Jun 11, 2021

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.

src/shims/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/posix/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/posix/linux/foreign_items.rs Outdated Show resolved Hide resolved
src/shims/windows/foreign_items.rs Outdated Show resolved Hide resolved
…ng `let link_name = link_name_sym.as_str()`
@RalfJung
Copy link
Member

Looks great, thanks. :)
@bors r+

@bors
Copy link
Contributor

bors commented Jun 15, 2021

📌 Commit aaaa142 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Jun 15, 2021

⌛ Testing commit aaaa142 with merge 486b5df...

@bors
Copy link
Contributor

bors commented Jun 15, 2021

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 486b5df to master...

@bors bors merged commit 486b5df into rust-lang:master Jun 15, 2021
@ghost ghost deleted the 1776-follow-up branch June 15, 2021 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants