This code:
#![feature(libc, unicode)]
extern crate libc;
extern crate unicode;
#[cfg(target_family = "windows")]
#[allow(non_snake_case)]
#[link(name = "vccorlib")]
extern "C" {
#[link_name = "?GetCmdArguments@Details@Platform@@YAPEAPEA_WPEAH@Z"]
pub fn GetCmdArguments(argc : *mut libc::c_int) -> *const *const libc::wchar_t;
}
#[unstable]
pub fn get_command_arguments(argc : libc::c_int) -> (*const *const libc::wchar_t, libc::c_int) {
let mut argc = argc;
( unsafe { GetCmdArguments(&mut argc) }, argc)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_command_arguments() {
get_command_arguments(0);
}
}
rustc minimumrepro.rs --crate-name minimumrepro --crate-type lib -g --test --emit=dep-info,link -L "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/lib/store/amd64"
should produce the following code (provided as a disassembly snippet):
...
000000000052CF18 jmp qword ptr [6147d0h]
000000000052CF1E nop
000000000052CF1F nop
...
But it instead produces the following code
...
000000000052CF18 jmp qword ptr [0B416EEh]
000000000052CF1E nop
000000000052CF1F nop
...
The difference is in the first entry of the jump table, which is the entry for the function explicitly mentioned in the source code. The incorrect value is caused by an absolute offset being written into the binary instead of a relative one. 0x52cf1e + 0x6147d0 = 0xb416ee.
Meta
rustc --version --verbose:
rustc 1.0.0-nightly (2fc8b1e 2015-03-07) (built 2015-03-08)
binary: rustc
commit-hash: 2fc8b1e
commit-date: 2015-03-07
build-date: 2015-03-08
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly
Backtrace:
N/A
This code:
rustc minimumrepro.rs --crate-name minimumrepro --crate-type lib -g --test --emit=dep-info,link -L "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/lib/store/amd64"should produce the following code (provided as a disassembly snippet):
But it instead produces the following code
The difference is in the first entry of the jump table, which is the entry for the function explicitly mentioned in the source code. The incorrect value is caused by an absolute offset being written into the binary instead of a relative one. 0x52cf1e + 0x6147d0 = 0xb416ee.
Meta
rustc --version --verbose:rustc 1.0.0-nightly (2fc8b1e 2015-03-07) (built 2015-03-08)
binary: rustc
commit-hash: 2fc8b1e
commit-date: 2015-03-07
build-date: 2015-03-08
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly
Backtrace:
N/A