Specifications

Linux Function Calls
Register r23 is reserved for the thread pointer on GNU Linux systems. It is initialized by the C library and
it may be used directly for TLS access, but not modified. On non-Linux systems r23 is a general-purpose,
callee-saved register.
The global pointer, r26 or gp, is globally fixed. It is initialized in startup code and always valid on entry to
a function. This method does not allow for multiple gp values, so gp-relative data references are only
possible in the main application (that is, from position dependent code). gp is only used for small data
access, not GOT access, because code compiled as PIC may be used from shared libraries. The linker may
take advantage of gp for shorter PLT sequences when the addresses are in range. The compiler needs an
option to disable use of gprel; the option is necessary for applications with excessive amounts of small
data. For comparison, XUL (Mozilla display engine, 16 MB code, 2 MB data) has only 27 KB of small data
and the limit is 64 KB. This option is separate from -G 0, because -G 0 creates ABI incompatibility. A file
compiled with -G 0 puts global int variables into .data but files compiled with -G 8 expect such int
variables to be in .sdata.
PIC code which needs a GOT pointer needs to initialize the pointer locally using nextpc; the GOT pointer
is not passed during function calls. This approach is compatible with both static relocatable binaries and
System V style shared objects. A separate ABI is needed for shared objects with independently relocatable
text and data.
Stack alignment is 32-bit. The frame pointer points at the top of the stack when it is in use, to simplify
backtracing. Insert alloca between the local variables and the outgoing arguments. The stack pointer
points to the bottom of the outgoing argument area.
A large struct return value is handled by passing a pointer in the first argument register (not the disjoint
return value register).
Linux Operating System Call Interface
Table 7-7: Signals for Unhandled Instruction-Related Exceptions
Exception Signal
Supervisor-only instruction address SIGSEGV
TLB permission violation (execute) SIGSEGV
Supervisor-only instruction SIGILL
Unimplemented instruction SIGILL
Illegal instruction SIGILL
Break instruction SIGTRAP
Supervisor-only data address SIGSEGV
Misaligned data address SIGBUS
Misaligned destination address SIGBUS
Division error SIGFPE
TLB Permission Violation (read) SIGSEGV
TLB Permission Violation (write) SIGSEGV
7-16
Linux Function Calls
NII51016
2015.04.02
Altera Corporation
Application Binary Interface
Send Feedback