1

(古い) カスタム組み込みプラットフォームでベンチマークしたい 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 クロスコンパイラ (arm-linux-gnueabi-gcc test.c -o test) を使用すると、間違った EABI (GNU EABI ではなくバージョン 5 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 プログラムをコンパイルするためのベスト プラクティスは何ですか?

4

0 に答える 0