Specifications

Example 7-25: Initial PLT Entry
.PLTresolve:
nextpc r14
orhi r13, r0, %hiadj(_GLOBAL_OFFSET_TABLE_)
add r13, r13, r14
ldw r14, %lo(_GLOBAL_OFFSET_TABLE_+4)(r13)
ldw r13, %lo(_GLOBAL_OFFSET_TABLE_+8)(r13)
jmp r13
If the initial PLT entry is out of range, the resolver can be inline, because it is only one instruction longer
than a long branch, as shown below.
Example 7-26: Initial PLT Entry Out of Range
.PLTn:
orhi r15, r0, %hiadj(index * 4)
addi r15, r15, %lo(index * 4)
nextpc r14
orhi r13, r0, %hiadj(_GLOBAL_OFFSET_TABLE_)
add r13, r13, r14
ldw r14, %lo(_GLOBAL_OFFSET_TABLE_+4)(r13)
ldw r13, %lo(_GLOBAL_OFFSET_TABLE_+8)(r13)
jmp r13
Linux Program Interpreter
The program interpreter is /lib/ld.so.1.
Linux Initialization and Termination Functions
The implementation is responsible for calling DT_INIT(), DT_INIT_ARRAY(), DT_PREINIT_ARRAY(),
DT_FINI(), and DT_FINI_ARRAY().
Linux Conventions
System Calls
The Linux system call interface relies on the trap instruction with immediate argument zero. The system
call number is passed in register r2. The arguments are passed in r4, r5, r6, r7, r8, and r9 as necessary.
The return value is written in r2 on success, or a positive error number is written to r2 on failure. A flag
indicating successful completion, to distinguish error values from valid results, is written to r7; 0 indicates
syscall success and 1 indicates r2 contains a positive errno value.
Userspace Breakpoints
Userspace breakpoints are accomplished using the trap instruction with immediate operand 31 (all ones).
The OS must distinguish this instruction from a trap 0 system call and generate a trap signal.
Atomic Operations
The Nios II architecture does not have atomic operations (such as load linked and store conditional).
Atomic operations are emulated using a kernel system call via the trap instruction. The toolchain
7-22
Linux Program Interpreter
NII51016
2015.04.02
Altera Corporation
Application Binary Interface
Send Feedback