For fun I'm trying to create an assembly program for Sun Solaris on SPARC. I'm emulating the system with QEMU.
My test assembles fine, yet linking fails with "relocation error: R_SPARC_13". Googling that error did not help at all.
.section ".text"
.global main
.type main,@function
.align 16
main:
mov 4,%g1 ! 4 is SYS_write
mov 1,%o0 ! 1 is stdout
mov test,%o1 ! pointer to buffer
mov 6,%o2 ! length
ta 8
mov 1,%g1 ! 1 is SYS_exit
clr %o0 ! return status is 0
ta 8
test: .asciz "hallo\n"
I assembled it with:
as test.s
ld a.out -o test
which gives:
ld: fatal: relocation error: R_SPARC_13:
ld: fatal: file a.out:
ld: fatal: symbol <unknown>:
ld: fatal: value 0x103b0 does not fit
Any ideas?
EDIT: found that "mov test,%o1" should be "set test,%o1". Because set handles the large pointer value. But I don't understand why then e.g.
JMP bla
nop
bla:
...
also still gives that R_SPARC_13 error.