如果工具链是未知的,则编译嵌入式系统的C程序

我有一个C程序,我想在(旧)定制嵌入式平台上进行基准测试。 问题是我只有硬件,但没有工具链来编译这个平台的程序。 该CPU是Atmel AT91SAM9260(ARM),并运行我可以完全访问的嵌入式Linux。 我已经从嵌入式系统下载了一个程序,并用'readelf -h ...'分析了它的格式:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            ARM
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8520
  Start of program headers:          52 (bytes into file)
  Start of section headers:          3772 (bytes into file)
  Flags:                             0x602, has entry point, GNU EABI, software FP, VFP
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         25
  Section header string table index: 24

然后我写了下面的测试程序:

#include <stdio.h>

int main() {
  printf("Hello World!n");
  return(0);
}

如果我在Ubuntu 12.04(arm-linux-gnueabi-gcc test.c -o test)中使用标准的ARM交叉编译器,则会选择错误的EABI(版本5 EABI而不是GNU EABI),并且它不会在嵌入系统(访问权限等是正确的)。

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8881
  Start of program headers:          52 (bytes into file)
  Start of section headers:          372148 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         7
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27

如果我使用像Sourcery CodeBench这样的裸机编译器,我会遇到类似“未定义的引用...”的错误。 这很明显,因为stdlib丢失了。 我试图通过将所有lib文件从嵌入平台复制到主机并使用“./arm-none-eabi-gcc test.c -o test -static -lc -L ./lib”进行编译来解决此问题。 我仍然(相同)未定义的参考错误。

如果工具链未知,为嵌入式系统编译C程序的最佳实践是什么?

链接地址: http://www.djcxy.com/p/15243.html

上一篇: Compile a C program for an embedded system if the toolchain is unknown

下一篇: Linaro compilation speed