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_CODE_4_GOTPCRELX 43
if the instruction starts at 4 bytes before the relocation offset. It is
similar to R_X86_64_GOTPCRELX. Linker can treat R_X86_64_CODE_4_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
if the first byte of the instruction at the relocation offset - 4 is 0xd5
when possible.
---
x86-64-ABI/linker-optimization.tex | 10 ++++++----
x86-64-ABI/object-files.tex | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/x86-64-ABI/linker-optimization.tex b/x86-64-ABI/linker-optimization.tex
index 246350c..c03afe3 100644
--- a/x86-64-ABI/linker-optimization.tex
+++ b/x86-64-ABI/linker-optimization.tex
@@ -66,10 +66,12 @@ 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},
-into a different form on immediate operand if \texttt{foo} is defined
-locally and the relocation addend is -4.
+on memory operand with \texttt{R_X86_64_GOTPCRELX},
+\texttt{R_X86_64_REX_GOTPCRELX} or \texttt{R_X86_64_CODE_4_GOTPCRELX}
+if the first byte of the instruction at the relocation offset - 4 is 0xd5,
+relocations against symbol, \texttt{foo}, into a different form on
+immediate operand if
+\texttt{foo} is defined locally and the relocation addend is -4.
\begin{description}
\item[\textindex{Convert call and jmp}]
diff --git a/x86-64-ABI/object-files.tex b/x86-64-ABI/object-files.tex
index 7f20c0c..2a2e315 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_CODE_4_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,10 +539,11 @@ 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,
-instead of the \texttt{R_X86_64_GOTPCREL} relocation. See also
-section~\ref{opt_gotpcrelx}.
+the \texttt{R_X86_64_REX_GOTPCRELX} relocation if the
+\code{REX} prefix is present, or the \texttt{R_X86_64_CODE_4_GOTPCRELX}
+relocation if the instruction starts at 4 bytes before the relocation
+offset, should be generated, instead of the \texttt{R_X86_64_GOTPCREL}
+relocation. See also section~\ref{opt_gotpcrelx}.
\end{sloppypar}
\begin{sloppypar}
--
2.41.0