Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - QNX Assembly (x86 and ARM): (4 Items)
   
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
Attachment: Compressed file lowlevel.zip 3.6 KB
Re: QNX Assembly (x86 and ARM)  
I got all answers by my self. Thanks to google! :)
--
AG!
Re: QNX Assembly (x86 and ARM)  
For those who interested in my results I attach here the fixed code for x86 and ARMle.
Attachment: Compressed file lowlevel.zip 3.64 KB
Re: QNX Assembly (x86 and ARM)  
cool!