Andrew Golovnia(deleted)
|
QNX Assembly (x86 and ARM)
|
Andrew Golovnia(deleted)
06/02/2008 6:44 AM
post8638
|
QNX Assembly (x86 and ARM)
I'm trying to make simple (hello world) pure assembler program in style of Linux assembly project (http://asm.
sourceforge.net/).
Using static builds, objdump and so on, I made working x86 code that loads as a static program (no /usr/lib/ldqnx.so.2
used) and prints simple message to stdout. But I have problems to make it working in ARM LE target machine. It prints me
a message:
# ./helloworldarm.bin
./helloworldarm.bin[1]: syntax error: `^A^P$D4^Aä^B4' unexpected
I guess it is something wrong in ".init" section of ELF-binary I have created.
Code fragment for x86:
.intel_syntax noprefix
.section .init, "x"
_init_proc: mov eax, offset _ctors
ret
.section .data, "w"
... data ...
.globl _start
.section .text, "x"
_start:
... code ...
.section .fini, "x"
_term_proc: mov eax, offset _dtors
ret
.section .ctors, "w"
_ctors: .long -1
.long 0
.section .dtors, "w"
_dtors: .long -1
.long 0
This code works fine but I cannot understand the meaning of sections .init, .fini, .ctors and .dtors, and how they
influence on application load process. When I remove this sections from the code, procnto is unable to load my ELF-
binary. So I assume this sections are important for loading procedure of ELF-binaries.
Code fragment for ARM:
.arm
.section .init, "x"
_init_proc: ldr r0, =_ctors
ldr r0, [r0]
mov pc, lr
.section .data, "w"
... data ...
.globl _start
.section .text, "x"
_start:
... code ...
.section .fini, "x"
_term_proc: ldr r0, =_dtors
ldr r0, [r0]
mov pc, lr
.section .ctors, "w"
_ctors: .long -1
.long 0
.section .dtors, "w"
_dtors: .long -1
.long 0
I simply ported x86 code to arm assembly instructions. May be it ported wrong, but I cannot check this code! My
resulting binary file doesn't want to be loaded by procnto of my ARM target. It show me the funny error message "syntax
error: `^A^P$D4^Aä^B4' unexpected" that explains no reason of failure to me.
Why it works on x86 and why it doesn't on ARM? What I'm doing wrong?
Here I attach my complete program code and resulting binaries in archive lowlevel.zip...
Thanks!
With best regards,
AG
|
|
|