1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Do not remove inline: will result in relocation failure
13 pub unsafe fn rel_ptr<T>(offset: u64) -> *const T {
14 (image_base()+offset) as *const T
17 // Do not remove inline: will result in relocation failure
19 pub unsafe fn rel_ptr_mut<T>(offset: u64) -> *mut T {
20 (image_base()+offset) as *mut T
23 // Do not remove inline: will result in relocation failure
24 // For the same reason we use inline ASM here instead of an extern static to
27 fn image_base() -> u64 {
29 unsafe{asm!("lea IMAGE_BASE(%rip),$0":"=r"(base))};