rust/library/std/src/sys/windows
Dylan DPC d5fa533ab0
Rollup merge of #84758 - ChrisDenton:dllimport, r=dtolnay
MSVC: Avoid using jmp stubs for dll function imports

Windows import libraries contain two symbols for every function: `__imp_FunctionName` and `FunctionName` (where `FunctionName` is the name of the function to be imported).

`__imp_FunctionName` contains the address of the imported function. This will be filled in by the Windows executable loader at runtime. `FunctionName` contains a jmp stub that simply jumps to the address given by `__imp_FunctionName`. E.g. it's a function that solely contains a single jmp instruction:

```asm
jmp __imp_FunctionName
```

When using an external DLL function in Rust, by default the linker will link to FunctionName, causing a bit of indirection at runtime. In Microsoft's C++ it's possible to instead tell it to insert calls to the address in `__imp_FunctionName` by using the  `__declspec(dllimport)` attribute. In Rust it's possible to get effectively the same behaviour using the `#[link]` attribute on `extern` blocks.

----

The second commit also merges multiple `extern` blocks into one block. This is because otherwise Rust will currently create duplicate linker arguments for each block. In this case having duplicates shouldn't matter much other than the noise when displaying the linker command.
2021-05-23 03:23:34 +02:00
..
alloc Rework std::sys::windows::alloc 2021-03-26 12:38:26 +01:00
args std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
os std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
path Refactor parse_prefix on Windows 2020-11-07 16:15:48 +01:00
process Expose force_quotes on Windows. 2021-02-17 17:54:04 +00:00
alloc.rs Move std::sys_common::alloc to std::sys::common 2021-04-14 13:24:10 +02:00
args.rs Auto merge of #84115 - CDirkx:rt, r=m-ou-se 2021-04-25 04:45:39 +00:00
c.rs Rollup merge of #84758 - ChrisDenton:dllimport, r=dtolnay 2021-05-23 03:23:34 +02:00
cmath.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
compat.rs Fix calling convention for CRT startup 2021-01-31 08:49:23 -08:00
condvar.rs No longer put windows condvars in a box. 2020-10-02 09:47:08 +02:00
env.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
fs.rs Windows implementation of fs::try_exists 2021-05-19 23:55:33 +01:00
handle.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
io.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
memchr.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
mod.rs Use the proper import library names 2021-05-06 04:04:19 +01:00
mutex.rs Remove outdated comment. 2021-02-08 22:27:34 +01:00
net.rs Apply suggestions from review 2021-04-22 18:00:17 +02:00
os.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
os_str.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
path.rs library: Normalize safety-for-unsafe-block comments 2021-02-24 06:13:42 +01:00
pipe.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
process.rs Provide ExitStatusError 2021-05-12 11:12:19 +01:00
rand.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
rwlock.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
stack_overflow.rs Rename rterr to rtprintpanic 2021-05-19 15:52:09 +02:00
stack_overflow_uwp.rs Move all cleanup to sys::cleanup 2021-04-22 10:44:44 +02:00
stdio.rs Use io::Error::new_const everywhere to avoid allocations. 2021-03-21 20:22:38 +01:00
stdio_uwp.rs Make raw standard stream constructors const 2020-08-21 13:17:20 +02:00
thread.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_local_dtor.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_local_key.rs Windows TLS: ManuallyDrop instead of mem::forget 2020-12-10 11:07:39 +01:00
thread_parker.rs Resolve DLL imports at CRT startup, not on demand 2021-01-29 10:41:49 -08:00
time.rs Implement the same optimization in windows/time 2020-10-08 17:04:32 -07:00