x64: support PC-rel symbol references using the GOT when in PIC mode.

This commit is contained in:
Chris Fallin
2021-01-07 21:59:42 -08:00
parent 8319244059
commit 3ee898cb2c
3 changed files with 82 additions and 12 deletions

View File

@@ -396,7 +396,10 @@ pub enum Inst {
/// An instruction that will always trigger the illegal instruction exception.
Ud2 { trap_code: TrapCode },
/// Loads an external symbol in a register, with a relocation: movabsq $name, dst
/// Loads an external symbol in a register, with a relocation:
///
/// movq $name@GOTPCREL(%rip), dst if PIC is enabled, or
/// movabsq $name, dst otherwise.
LoadExtName {
dst: Writable<Reg>,
name: Box<ExternalName>,
@@ -1692,7 +1695,7 @@ impl PrettyPrint for Inst {
dst, name, offset, ..
} => format!(
"{} {}+{}, {}",
ljustify("movaps".into()),
ljustify("load_ext_name".into()),
name,
offset,
show_ireg_sized(dst.to_reg(), mb_rru, 8),