Align IntelGOTPCRel4 with R_X86_64_GOTPCREL.
Add an addend field to reloc_external, and use it to move the responsibility for accounting for the difference between the end of an instruction (where the PC is considered to be in PC-relative on intel) and the beginning of the immediate field into the encoding code. Specifically, this makes IntelGOTPCRel4 directly correspond to R_X86_64_GOTPCREL, instead of also carrying an implicit `- 4`.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
//! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe.
|
||||
|
||||
use ir::{ExternalName, JumpTable};
|
||||
use super::{CodeSink, CodeOffset, Reloc};
|
||||
use super::{CodeSink, CodeOffset, Reloc, Addend};
|
||||
use std::ptr::write_unaligned;
|
||||
|
||||
/// A `CodeSink` that writes binary machine code directly into memory.
|
||||
@@ -52,7 +52,7 @@ pub trait RelocSink {
|
||||
fn reloc_ebb(&mut self, CodeOffset, Reloc, CodeOffset);
|
||||
|
||||
/// Add a relocation referencing an external symbol at the current offset.
|
||||
fn reloc_external(&mut self, CodeOffset, Reloc, &ExternalName);
|
||||
fn reloc_external(&mut self, CodeOffset, Reloc, &ExternalName, Addend);
|
||||
|
||||
/// Add a relocation referencing a jump table.
|
||||
fn reloc_jt(&mut self, CodeOffset, Reloc, JumpTable);
|
||||
@@ -96,9 +96,9 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
||||
self.relocs.reloc_ebb(ofs, rel, ebb_offset);
|
||||
}
|
||||
|
||||
fn reloc_external(&mut self, rel: Reloc, name: &ExternalName) {
|
||||
fn reloc_external(&mut self, rel: Reloc, name: &ExternalName, addend: Addend) {
|
||||
let ofs = self.offset();
|
||||
self.relocs.reloc_external(ofs, rel, name);
|
||||
self.relocs.reloc_external(ofs, rel, name, addend);
|
||||
}
|
||||
|
||||
fn reloc_jt(&mut self, rel: Reloc, jt: JumpTable) {
|
||||
|
||||
@@ -19,6 +19,9 @@ use std::fmt;
|
||||
/// depends on the *host* platform, not the *target* platform.
|
||||
pub type CodeOffset = u32;
|
||||
|
||||
/// Addend to add to the symbol value.
|
||||
pub type Addend = i64;
|
||||
|
||||
/// Relocation kinds for every ISA
|
||||
#[derive(Debug)]
|
||||
pub enum Reloc {
|
||||
@@ -78,8 +81,8 @@ pub trait CodeSink {
|
||||
/// Add a relocation referencing an EBB at the current offset.
|
||||
fn reloc_ebb(&mut self, Reloc, CodeOffset);
|
||||
|
||||
/// Add a relocation referencing an external symbol at the current offset.
|
||||
fn reloc_external(&mut self, Reloc, &ExternalName);
|
||||
/// Add a relocation referencing an external symbol plus the addend at the current offset.
|
||||
fn reloc_external(&mut self, Reloc, &ExternalName, Addend);
|
||||
|
||||
/// Add a relocation referencing a jump table.
|
||||
fn reloc_jt(&mut self, Reloc, JumpTable);
|
||||
|
||||
Reference in New Issue
Block a user