Skip to content

Commit

Permalink
Import x86-64-ABI revision 234
Browse files Browse the repository at this point in the history
  • Loading branch information
hjl-tools committed Jan 16, 2015
1 parent b4e385f commit b3fda96
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 53 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2015-01-16 H.J. Lu <hongjiu.lu@intel.com>

Integrate x32 ABI. See ChangeLog.x32.

2015-01-07 H.J. Lu <hongjiu.lu@intel.com>

* libraries.tex: Add \begin{sloppypar} and \end{sloppypar},
Expand Down
48 changes: 48 additions & 0 deletions ChangeLog.x32
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* abi.tex (author): Add H.J. and Milind. List the authors in
alphabetical order by surname.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* abi.tex (title): Mention LP64 and ILP32 programming models.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* abi.tex: Include x32.tex.
* x32.tex: New file.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* dl.tex: Document ILP32 program interpreter.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* object-files.tex: Add ILP32 support. Don't allow ELFCLASS32
for LP64.
Allow Elf32_Rel relocations within x32 executable files or
shared objects.
Add wordclass and use it on R_X86_64_GLOB_DAT,
R_X86_64_JUMP_SLOT, R_X86_64_RELATIVE, R_X86_64_IRELATIVE.
Add R_X86_64_RELATIVE64 for x32.
Mark R_X86_64_64, R_X86_64_PC64, R_X86_64_GOTOFF64 and
R_X86_64_SIZE64 used only for LP64.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* low-level-sys-info.tex: Use \myfontsize instead of \small on
Scalar Types table. Update long, long long and pointer types
for ILP32 and LP64.
(Architectural Constraints): Add a lebel.
Mention small model for ILP32.
* macros.tex (myfontsize): New.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* development.tex: Document _LP64 and __LP64__. Add _ILP32 and
__ILP32__ for x32.

2014-12-02 H.J. Lu <hongjiu.lu@intel.com>

* introduction.tex: Add a label.
Introduce ILP32 and LP64.
7 changes: 6 additions & 1 deletion abi.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
\begin{document}

\author{Edited by\\
Milind Girkar\thanks{milind.girkar@intel.com},
Jan Hubi\v{c}ka\thanks{jh@suse.cz},\\
Andreas Jaeger\thanks{aj@suse.de},
H.J. Lu\thanks{hongjiu.lu@intel.com},
Michael Matz\thanks{matz@suse.de},
Jan Hubi\v{c}ka\thanks{jh@suse.cz}, Andreas Jaeger\thanks{aj@suse.de},
Mark Mitchell\thanks{mark@codesourcery.com}}

\title{System V Application Binary Interface\\
{\Large AMD64 Architecture Processor Supplement\\
(With LP64 and ILP32 Programming Models)\\
Draft Version \version}}
\maketitle
\tableofcontents
Expand Down Expand Up @@ -100,6 +104,7 @@ \chapter{Conventions}\editornote{This chapter is used to document some features
place or removed completely.}
\include{conventions}
\include{fortran}
\include{x32}

\appendix
\include{kernel}
Expand Down
20 changes: 13 additions & 7 deletions development.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
\chapter{Development Environment}

During compilation of C or C++ code at least the symbols in
table \ref{prepro_defines} are defined by the pre-processor.
table \ref{prepro_defines} are defined by the pre-processor
\footnote{\code{__LP64} and \code{__LP64__} were added to GCC 3.3 in
March, 2003.}.

\begin{table}[H]
\Hrule
\caption{Predefined Pre-Processor Symbols}
\label{prepro_defines}
\begin{center}\code{
\begin{tabular}[t]{l}
__amd64\\
__amd64__\\
__x86_64\\
__x86_64__\\
\begin{center}\small\code{
\begin{tabular}[t]{ll}
__amd64 & Defined for both LP64 and ILP32 programming models.\\
__amd64__ & Defined for both LP64 and ILP32 programming models.\\
__x86_64 & Defined for both LP64 and ILP32 programming models.\\
__x86_64__ & Defined for both LP64 and ILP32 programming models.\\
_LP64 & Defined for LP64 programming model.\\
__LP64__ & Defined for LP64 programming model.\\
_ILP32 & Defined for ILP32 programming model.\\
__ILP32__ & Defined for ILP32 programming model.\\
\end{tabular}
}\end{center}
\Hrule
Expand Down
27 changes: 17 additions & 10 deletions dl.tex
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,24 @@ \subsubsection{Large Models}

\subsection{Program Interpreter}

There is one valid \textindex{program interpreter} for
programs conforming to the \xARCH ABI:

\bigskip
\path{/lib/ld64.so.1}

However, Linux puts this in

\bigskip
\path{/lib64/ld-linux-x86-64.so.2}
The valid \textindex{program interpreter} for programs conforming to the
\xARCH ABI is listed in Table \ref{interp}, which also contains the
\textindex{program interpreter} used by Linux.

\begin{figure}
\caption{\xARCH Program Interpreter}
\label{interp}
\begin{center}
\begin{tabular}[t]{l|l|l}
\multicolumn{1}{c}{Data Model} & \multicolumn{1}{c}{Path} &
\multicolumn{1}{c}{Linux Path} \\
\hline
LP64 & \path{/lib/ld64.so.1} & \path{/lib64/ld-linux-x86-64.so.2} \\
\hline
ILP32 & \path{/lib/ldx32.so.1} & \path{/libx32/ld-linux-x32.so.2} \\
\end{tabular}
\end{center}
\end{figure}

\subsection{Initialization and Termination Functions}

Expand Down
9 changes: 8 additions & 1 deletion introduction.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\chapter{Introduction}
\chapter{Introduction\label{intro}}

The AMD64\footnote{AMD64 has been previously called x86-64. The
latter name is used in a number of places out of historical reasons
Expand All @@ -15,6 +15,13 @@ \chapter{Introduction}
this document applies only to programs running in the ``long'' mode
provided by the \xARCH architecture.

Binaries using the \xARCH instruction set may program to either a 32-bit
model, in which the C data types \code{int}, \code{long} and all
pointer types are 32-bit objects (ILP32); or to a 64-bit model,
in which the C \code{int} type is 32-bits but the C \code{long} type
and all pointer types are 64-bit objects (LP64). This specification
covers both LP64 and ILP32 programming models.

Except where otherwise noted, the \xARCH architecture ABI follows the
conventions described in the \intelabi. Rather than replicate the
entire contents of the \intelabi, the \xARCH ABI indicates only those
Expand Down
43 changes: 32 additions & 11 deletions low-level-sys-info.tex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ \subsubsection{Fundamental Types}
\caption{Scalar Types}\label{basic-types}
{ % Use small here - the table is still too large
% Has anybody an idea how to shrink the table so that it fits the page?
\small
\myfontsize
\begin{tabular}{l|l|c|c|l}
\hline\noalign{\smallskip}
& & & \multicolumn{1}{c|}{Alignment} & \multicolumn{1}{c|}{\xARCH} \\
Expand All @@ -58,21 +58,32 @@ \subsubsection{Fundamental Types}
\cline{2-5}
& \texttt{unsigned int} & 4 & 4 & unsigned \fourbyte \\
\cline{2-5}
& \texttt{long} & 8 & 8 & signed \eightbyte \\
& \texttt{signed long} & & \\
& \texttt{long long} & & \\
& \texttt{long (LP64)} & 8 & 8 & signed \eightbyte \\
& \texttt{signed long (LP64)} & & \\
\cline{2-5}
& \texttt{unsigned long (LP64)} & 8 & 8 & unsigned \eightbyte \\
\cline{2-5}
& \texttt{long (ILP32)} & 4 & 4 & signed \fourbyte \\
& \texttt{signed long (ILP32)} & & \\
\cline{2-5}
& \texttt{unsigned long (ILP32)} & 4 & 4 & unsigned \fourbyte \\
\cline{2-5}
& \texttt{long long} & 8 & 8 & signed \eightbyte \\
& \texttt{signed long long} & & \\
\cline{2-5}
& \texttt{unsigned long} & 8 & 8 & unsigned \eightbyte \\
& \texttt{unsigned long long} & 8 & 8 & unsigned \eightbyte \\
\cline{2-5}
& \texttt{__int128}$^{\dagger\dagger}$ & 16 & 16 & signed \sixteenbyte \\
& \texttt{signed __int128}$^{\dagger\dagger}$ & 16 & 16 & signed \sixteenbyte \\
\cline{2-5}
& \texttt{unsigned __int128}$^{\dagger\dagger}$ & 16 & 16 & unsigned \sixteenbyte \\
\hline
Pointer & \texttt{\textit{any-type} *} & 8 & 8 & unsigned \eightbyte \\
& \texttt{\textit{any-type} (*)()} & & \\
Pointer
& \texttt{\textit{any-type} * (LP64)} & 8 & 8 & unsigned \eightbyte \\
& \texttt{\textit{any-type} (*)() (LP64)} & & \\
\cline{2-5}
& \texttt{\textit{any-type} * (ILP32)} & 4 & 4 & unsigned \fourbyte \\
& \texttt{\textit{any-type} (*)() (ILP32)} & & \\
\hline
Floating-& \texttt{float} & 4 & 4 & single (IEEE-754) \\
\cline{2-5}
Expand Down Expand Up @@ -188,9 +199,16 @@ \subsubsection{Bit-Fields}
\texttt{int} & 1 to 32 & 0 to $2^{w}-1$ \\
\texttt{unsigned int} & & 0 to $2^{w}-1$ \\
\hline
\texttt{signed long} & & $-2^{w - 1}$ to $2^{w-1}-1$ \\
\texttt{long} & 1 to 64 & 0 to $2^{w}-1$ \\
\texttt{unsigned long} & & 0 to $2^{w}-1$ \\
\texttt{signed long (LP64)} & & $-2^{w - 1}$ to $2^{w-1}-1$ \\
\texttt{long (LP64)} & 1 to 64 & 0 to $2^{w}-1$ \\
\texttt{unsigned long (LP64)} & & 0 to $2^{w}-1$ \\
\hline
\texttt{long (ILP32)} & 1 to 32 & 0 to $2^{w}-1$ \\
\texttt{unsigned long (ILP32)} & & 0 to $2^{w}-1$ \\
\hline
\texttt{signed long long} & & $-2^{w - 1}$ to $2^{w-1}-1$ \\
\texttt{long long} & 1 to 64 & 0 to $2^{w}-1$ \\
\texttt{unsigned long long} & & 0 to $2^{w}-1$ \\
\end{tabular}
\end{center}
\Hrule
Expand Down Expand Up @@ -1103,7 +1121,7 @@ \section{Coding Examples}
transferring control from one part of a program to another. Unlike
previous material, this material is not normative.

\subsection{Architectural Constraints}
\subsection{Architectural Constraints\label{models}}

The \xARCH architecture usually does not allow an instruction to encode
arbitrary
Expand Down Expand Up @@ -1234,6 +1252,9 @@ \subsection{Architectural Constraints}

\end{description}

Only small code model and small position independent code model
(\textindex{PIC}) are used in ILP32 binaries.

\subsection{Conventions}

In this document some special assembler symbols are used in the coding
Expand Down
2 changes: 2 additions & 0 deletions macros.tex
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@

\newcommand*{\cbnew}{\marginpar{\textsf{New}}}

\newcommand{\myfontsize}{\fontsize{9}{11}\selectfont}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "abi"
Expand Down
65 changes: 42 additions & 23 deletions object-files.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ \section{ELF Header}

\subsection{Machine Information}

For file identification in \texttt{e_ident}, the \xARCH architecture
requires the following values.
\subsubsection{Programming Model}

\begin{table}[H]
\Hrule
\caption{\xARCH Identification}
\begin{center}
\begin{tabular}[t]{l|l}
\multicolumn{1}{c}{Position} & \multicolumn{1}{c}{Value} \\
\hline
\texttt{e_ident[EI_CLASS]} & \texttt{ELFCLASS64} \\
\texttt{e_ident[EI_DATA]} & \texttt{ELFDATA2LSB}
\end{tabular}
\end{center}
\Hrule
\end{table}
As described in Section \ref{intro}, binaries using the \xARCH instruction
set may program to either a 32-bit model, in which the C data
types \code{int}, \code{long} and all pointer types are 32-bit objects
(ILP32); or to a 64-bit model, in which the C code{int} type is 32-bits
but the C \code{long} type and all pointer types are 64-bit objects (LP64).
This specification describes both binaries that use the ILP32 and the LP64
model.

\subsubsection{File Class}

For \xARCH ILP32 objects, the file class value in e_ident[EI_CLASS] must
be ELFCLASS32. For \xARCH LP64 objects, the file class value must be
ELFCLASS64.

\subsubsection{Data Encoding}

For the data encoding in e_ident[EI_DATA], \xARCH objects use
ELFDATA2LSB.

\subsubsection{Processor identification}

Processor identification resides in the ELF headers
\texttt{e_machine} member and must have the value
Expand Down Expand Up @@ -397,6 +403,8 @@ \subsection{Relocation Types}
with arbitrary byte alignment. These values use
the same byte order as other word values in the
\xARCH architecture. \\
\textit{wordclass} & This specifies \textit{word64} for LP64 and
specifies \textit{word32} for ILP32. \\
\end{tabular*}

The following notations are used for specifying relocations in table
Expand All @@ -421,13 +429,19 @@ \subsection{Relocation Types}
relocation entry.
\end{description}

The \xARCH ABI architectures uses only \texttt{Elf64_Rela} relocation
The \xARCH LP64 ABI architecture uses only \texttt{Elf64_Rela} relocation
entries with explicit addends. The \code{r_addend} member serves as
the relocation addend.

The \xARCH ILP32 ABI architecture uses only \texttt{Elf32_Rela} relocation
entries in relocatable files. Relocations contained within executable
files or shared objects may use either \texttt{Elf32_Rela} relocation
or \texttt{Elf32_Rel} relocation.

\begin{table}[H]
\Hrule
\caption{Relocation Types}
\small
\label{tab-relocations}
\begin{center}
\begin{tabular}[t]{l|r|l|l}
Expand All @@ -442,9 +456,9 @@ \subsection{Relocation Types}
\texttt{R_X86_64_GOT32} & 3 & \textit{word32} & \texttt{G + A} \\
\texttt{R_X86_64_PLT32} & 4 & \textit{word32} & \texttt{L + A - P} \\
\texttt{R_X86_64_COPY} & 5 & none & none \\
\texttt{R_X86_64_GLOB_DAT} & 6 & \textit{word64} & \texttt{S} \\
\texttt{R_X86_64_JUMP_SLOT} & 7 & \textit{word64} & \texttt{S} \\
\texttt{R_X86_64_RELATIVE} & 8 & \textit{word64} & \texttt{B + A} \\
\texttt{R_X86_64_GLOB_DAT} & 6 & \textit{wordclass} & \texttt{S} \\
\texttt{R_X86_64_JUMP_SLOT} & 7 & \textit{wordclass} & \texttt{S} \\
\texttt{R_X86_64_RELATIVE} & 8 & \textit{wordclass} & \texttt{B + A} \\
\texttt{R_X86_64_GOTPCREL} & 9 & \textit{word32} & \texttt{G + GOT + A - P} \\
\texttt{R_X86_64_32} & 10 & \textit{word32} & \texttt{S + A} \\
\texttt{R_X86_64_32S} & 11 & \textit{word32} & \texttt{S + A} \\
Expand All @@ -460,17 +474,22 @@ \subsection{Relocation Types}
\texttt{R_X86_64_DTPOFF32} & 21 & \textit{word32} & \\
\texttt{R_X86_64_GOTTPOFF} & 22 & \textit{word32} & \\
\texttt{R_X86_64_TPOFF32} & 23 & \textit{word32} & \\
\texttt{R_X86_64_PC64} & 24 & \textit{word64} & \texttt{S + A - P} \\
\texttt{R_X86_64_GOTOFF64} & 25 & \textit{word64} & \texttt{S + A - GOT} \\
\texttt{R_X86_64_PC64} $^\dagger$ & 24 & \textit{word64} & \texttt{S + A - P} \\
\texttt{R_X86_64_GOTOFF64} $^\dagger$ & 25 & \textit{word64} & \texttt{S + A - GOT} \\
\texttt{R_X86_64_GOTPC32} & 26 & \textit{word32} & \texttt{GOT + A - P} \\
\texttt{R_X86_64_SIZE32} & 32 & \textit{word32} & \texttt{Z + A} \\
\texttt{R_X86_64_SIZE64} & 33 & \textit{word64} & \texttt{Z + A} \\
\texttt{R_X86_64_SIZE64} $^\dagger$ & 33 & \textit{word64} & \texttt{Z + A} \\
\texttt{R_X86_64_GOTPC32_TLSDESC} & 34 & \textit{word32} & \\
\texttt{R_X86_64_TLSDESC_CALL} & 35 & none & \\
\texttt{R_X86_64_TLSDESC} & 36 & \textit{word64}$\times 2$ & \\
\texttt{R_X86_64_IRELATIVE} & 37 & \textit{word64} & \texttt{indirect (B + A)}\\
\texttt{R_X86_64_IRELATIVE} & 37 & \textit{wordclass} & \texttt{indirect (B + A)}\\
\texttt{R_X86_64_RELATIVE64} $^{\dagger\dagger}$ & 38 & \textit{word64} & \texttt{B + A} \\
% \texttt{R_X86_64_GOT64} & 16 & \textit{word64} & \texttt{G + A} \\
% \texttt{R_X86_64_PLT64} & 17 & \textit{word64} & \texttt{L + A - P} \\
\cline{1-4}
\multicolumn{3}{l}{\small $^\dagger$ This relocation is used only for LP64.}\\
\multicolumn{3}{l}{\small $^{\dagger\dagger}$ This relocation only
appears in ILP32 executable files or shared objects.}\\
\end{tabular}
\end{center}
\Hrule
Expand Down
Loading

0 comments on commit b3fda96

Please sign in to comment.