i960 Processor Compiler User's Guide
9-2
9
For example, suppose object _x is in the .data or the .bss section.
Normally, the compiler generates an address of the object with an absolute
addressing mode:
lda _x, g0
When you compile your program with position-independent data, the
compiler generates this instruction to take the address of
_x:
lda _x(g12), g0
NOTE. If PID is specified, the value in g12 must be correctly computed
and stored by user-provided startup code.
Position-independent Code
When the position-independent code option is specified, the compiler
computes effective addresses by biasing them based upon the instruction
pointer (
ip).
Suppose object
_x is in the .text section. The compiler generates a code
bias address into a register at the beginning of any function that needs a
direct address in the
.text section. It does this via a code sequence
similar to this:
lda 0(ip), r3
lda . , r4
subo r4, r3, r3
which leaves the bias in r3. Then the compiler uses r3 to bias the
reference to
_x as:
lda _x (r3), r4