4

I have an ARM machine that runs Linux (BusyBox).

# uname -a
# Linux XXXXXXXX 2.6.28 #1 PREEMPT Fri Sep 26 22:47:38 UTC 2014 armv5tel GNU/Linux

I've cross-compiled a simple program on my Ubuntu 32-bit desktop:

./configure --host=arm-linux-gnueabi LDFLAGS="-static"
make

But when I try to run it on the ARM machine, it gives me Segmentation Fault error.

Program is super simple:

#include <stdio.h>

int main()
{
    printf("Hello, World!");

    return 0;
}

Here are a few things I've already tried/checked:

  • I've checked md5 hashes on both machines to eliminate the possibility that something went wrong at the time of copying an executable over the network
  • Stripped the executable with arm-linux-gnueabi-strip. I was comparing my executable with another executable that was already in the target machine with file:

# file my_program

# my_program: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.31, BuildID[sha1]=0x4b1f2773e54b141d5157b86f0f10438a372625c9, stripped

# file their_program

# their_program: ELF 32-bit LSB executable, ARM, version 1 (GNU/Linux), statically linked, stripped

What am I doing wrong?

Darkhan
  • 1,258
  • 2
  • 13
  • 21
  • 1
    **busybox** and arm-linux-**gnueabi**. Is it possible that one is uClibc and another is eglibc. Now, you also have softfp type ABI issues. **armv5tel** will generally not have `fp` registers, so I would specify, `-mfloat-abi=soft` and select 'softfp' libraries. It maybe the Ubuntu tool chain you have doesn't support this. In [this question on thumb entry](http://stackoverflow.com/questions/20369440/can-start-be-the-thumb-function/), you can find some code that can be compiled with `-nostartfiles -static -nostdlib`, any tool chain can produce Linux binaries that run with these techniques. – artless noise Feb 19 '15 at 16:10
  • @artlessnoise Thanks for uClibc idea, that made me to research on it and finally figuring out the solution – Darkhan Feb 28 '15 at 20:13

1 Answers1

3

Apparently my cross-compile toolchain was not the right one. I ended up using crosstool-ng. Btw it's very simple to use and a great tool, all you have to do is to choose the right toolchain for your device.

I have built an arm-unknown-linux-uclibcgnueabi toolchain with crosstool-ng, which solved my problem.

Darkhan
  • 1,258
  • 2
  • 13
  • 21