Intel Advanced Performance Extensions:
https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html
adds the REX2 prefix for the additional general-purpose registers, r16-r31,
in
mov name@GOTPCREL(%rip), %reg
test %reg, name@GOTPCREL(%rip)
binop name@GOTPCREL(%rip), %reg
where binop is one of adc, add, add, cmp, or, sbb, sub, xor instructions.
Add
# define R_X86_64_REX2_GOTPCRELX 43
if the REX2 prefix is present. It is similar to R_X86_64_GOTPCRELX.
Linker can treat R_X86_64_REX2_GOTPCRELX as R_X86_64_GOTPCREL or convert
the above instructions to
lea name(%rip), %reg
mov $name, %reg
test $name, %reg
binop $name, %reg
when possible.
---
x86-64-ABI/linker-optimization.tex | 5 +++--
x86-64-ABI/object-files.tex | 6 ++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/x86-64-ABI/linker-optimization.tex b/x86-64-ABI/linker-optimization.tex
index 246350c..d681829 100644
--- a/x86-64-ABI/linker-optimization.tex
+++ b/x86-64-ABI/linker-optimization.tex
@@ -66,8 +66,9 @@ into an infinite loop at run-time.
\label{opt_gotpcrelx}
The \xARCH instruction encoding supports converting certain instructions
-on memory operand with \texttt{R_X86_64_GOTPCRELX} or
-\texttt{R_X86_64_REX_GOTPCRELX} relocations against symbol, \texttt{foo},
+on memory operand with \texttt{R_X86_64_GOTPCRELX},
+\texttt{R_X86_64_REX_GOTPCRELX} or \texttt{R_X86_64_REX2_GOTPCRELX}
+relocations against symbol, \texttt{foo},
into a different form on immediate operand if \texttt{foo} is defined
locally and the relocation addend is -4.
diff --git a/x86-64-ABI/object-files.tex b/x86-64-ABI/object-files.tex
index 7f20c0c..5a5cad6 100644
--- a/x86-64-ABI/object-files.tex
+++ b/x86-64-ABI/object-files.tex
@@ -486,6 +486,7 @@ or \texttt{Elf32_Rel} relocation entries.
\texttt{Deprecated} & 40 & & \\
\texttt{R_X86_64_GOTPCRELX} & 41 & \textit{word32} & \texttt{G + GOT + A - P} \\
\texttt{R_X86_64_REX_GOTPCRELX} & 42 & \textit{word32} & \texttt{G + GOT + A - P} \\
+ \texttt{R_X86_64_REX2_GOTPCRELX} & 43 & \textit{word32} & \texttt{G + GOT + A - P} \\
\cline{1-4}
\multicolumn{4}{l}{\small $^\dagger$ This relocation is used only for LP64.}\\
\multicolumn{4}{l}{\small $^{\dagger\dagger}$ This relocation only
@@ -538,8 +539,9 @@ instructions:
where \code{binop} is one of \code{adc}, \code{add}, \code{and},
\code{cmp}, \code{or}, \code{sbb}, \code{sub}, \code{xor}
instructions, the \texttt{R_X86_64_GOTPCRELX} relocation,
-or the \texttt{R_X86_64_REX_GOTPCRELX} relocation if the
-\code{REX} prefix is present, should be generated,
+the \texttt{R_X86_64_REX_GOTPCRELX} relocation if the
+\code{REX} prefix is present, or the \texttt{R_X86_64_REX2_GOTPCRELX}
+relocation if the \code{REX2} prefix is present should be generated,
instead of the \texttt{R_X86_64_GOTPCREL} relocation. See also
section~\ref{opt_gotpcrelx}.
\end{sloppypar}
--
2.41.0