ARM9SAMG25 : Segmentation Fault with program Hello World

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

damien
Posts: 6
Joined: Fri Nov 30, 2012 12:05 pm

ARM9SAMG25 : Segmentation Fault with program Hello World

Mon Dec 17, 2012 3:28 pm

Hello,

I use cross compiler of emdebian.org and when I compile the program on the target, it's work but when I cross-compile for the ARM, the program don't work on the target and it say "Segmentation Fault".

Code: Select all

#include <stdio.h>
int main(void) {

	printf("hello\n");
	printf("world\n");

	return 0;
}
I search since 3 days and I don't find anythings.

Difference between these 2 assembly code :
Compile and work directly on the target :

Code: Select all

main:
	@ Function supports interworking.
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, uses_anonymous_args = 0
|	stmfd	sp!, {fp, lr}
|	add	fp, sp, #4
	ldr	r0, .L3
	bl	puts
	ldr	r0, .L3+4
	bl	puts
	mov	r3, #0
	mov	r0, r3
|	sub	sp, fp, #4
|	ldmfd	sp!, {fp, lr}
	bx	lr
and the assembly code that is to cross-complie and doesn't work :

Code: Select all

main:
	@ Function supports interworking.
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, uses_anonymous_args = 0
|	mov	ip, sp
|	stmfd	sp!, {fp, ip, lr, pc}
|	sub	fp, ip, #4
	ldr	r0, .L3
	bl	puts
	ldr	r0, .L3+4
	bl	puts
	mov	r3, #0
	mov	r0, r3
|	sub	sp, fp, #12
|	ldmfd	sp, {fp, sp, lr}
	bx	lr
'|' is the diffence between

Thanks

Damien
CptTitanic
Posts: 871
Joined: Sat Oct 30, 2010 6:04 pm

Re: ARM9SAMG25 : Segmentation Fault with program Hello World

Mon Dec 17, 2012 5:21 pm

So seems like you have an ABI issue.

Why wouldn't you use the cross compiler built as part of your kernel/fsimage build process, like the one buildroot generates?

~/buildroot-2011.05/output/host/usr/bin/arm-linux-gcc hello.c -ohello
damien
Posts: 6
Joined: Fri Nov 30, 2012 12:05 pm

Re: ARM9SAMG25 : Segmentation Fault with program Hello World

Mon Dec 17, 2012 6:21 pm

I haven't got buildroot generate. I use an SD card pre-installed with debian squeeze (Terra Board of ACME SYSTEM).

I have installed Xubuntu on a virtual machine, and i have added emdebian.org in my sources.list like on http://www.acmesystems.it/arm9_toolchain

But I'm compiling buildroot now on my system for testing.

What is an ABI issue ?
Do you know why cross compilation doesn't work?

Thank you for your answer.
CptTitanic
Posts: 871
Joined: Sat Oct 30, 2010 6:04 pm

Re: ARM9SAMG25 : Segmentation Fault with program Hello World

Mon Dec 17, 2012 8:45 pm

ABI Application Binary Interface, aka Calling Convention wrt Registers, Stack, etc.

http://stackoverflow.com/questions/5731 ... convention

A file built against a different calling convention from the rest of the system will fail. Most of the differences will be observable from the prologue and epilogue code for the functions.

As you're not building for a raw-metal system, you have to be conscious of the nuances of the specific system, calling conventions, external libraries, versions, architectures, etc. as well as the configuration options chosen when building the kernel. The most simple way to do this is to use a tool chain that is consistent/contemporaneous with the build of the specific system, and options thereof.

Return to “Development Tools”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests