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 use slice::from_raw_parts;
14 const R_X86_64_RELATIVE: u32 = 8;
23 pub fn relocate_elf_rela() {
26 static RELACOUNT: usize;
29 if unsafe { RELACOUNT } == 0 { return } // unsafe ok: link-time constant
32 from_raw_parts::<Rela<u64>>(mem::rel_ptr(RELA), RELACOUNT) // unsafe ok: link-time constant
35 if rela.info != (/*0 << 32 |*/ R_X86_64_RELATIVE as u64) {
36 panic!("Invalid relocation");
38 unsafe { *mem::rel_ptr_mut::<*const ()>(rela.offset) = mem::rel_ptr(rela.addend) };