web-dev-qa-db-ja.com

Ralink SoCのGCC(ツールチェーン)-ELFが見つからず、構文エラー

中国のP2Pカメラを購入しましたが、MJPEGストリームがなかったので、コンパイルしたかったのですmjpg-streamer それのための。これが私のCPUの情報です:

# cat /proc/cpuinfo 
system type             : Ralink SoC
processor               : 0
cpu model               : MIPS 24K V4.12
BogoMIPS                : 239.61
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes
ASEs implemented        : mips16 dsp
VCED exceptions         : not available
VCEI exceptions         : not available

# uname -a
Linux (none) 2.6.21 #878 Tue Oct 29 09:53:25 CST 2013 mips unknown

MIPS GNU/Linux用のソースコードベンチ (最新バージョン)を使用して、次のコマンドを使用して単純な「Helloworld」の例をコンパイルしようとしました。

$ mips-linux-gnu-gcc -Wall hello.c -o hello

実行後、次のメッセージが表示されました。

# ./hello 
./hello: line 1: ELF@04: not found
./hello: line 2: syntax error: "(" unexpected

次に、次のコマンドで再コンパイルしようとしました。

$ mips-linux-gnu-gcc -mips16 -Wall hello.c -o hello

しかし、結果は次のとおりです。

# ./hello 
./hello: line 1: syntax error: "(" unexpected
  • 間違ったコンパイラを使用していますか?使用している場合、どちらが正しいですか?
  • 私は欠落しているか、間違った引数を使用していますか?

編集:

$readelf -h HKIPC #Extracted file from the device
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:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x406420
  Start of program headers:          52 (bytes into file)
  Start of section headers:          643764 (bytes into file)
  Flags:                             0x10001007, noreorder, pic, cpic, o32, mips2
  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

$file HKIPC 
HKIPC: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), stripped

-

$readelf -h hello #Compiled with mips-linux-gnu-gcc -mips2 -EL -mabi=32 hello.c  -o hello
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 01 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:                       1
  Type:                              EXEC (Executable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x400430
  Start of program headers:          52 (bytes into file)
  Start of section headers:          2732 (bytes into file)
  Flags:                             0x70001005, noreorder, cpic, o32, mips32r2
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         34
  Section header string table index: 31

$file hello
hello: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped
5
botzko

カメラのlibcがツールチェーンに使用されているlibcと一致しません。この場合、プログラムは-staticスイッチを追加して静的にコンパイルする必要があります。この後、「Helloworld」がデバイス上で実行可能になります。別の解決策は、必要なすべての共有ライブラリを追加することです(私はこれをテストしていません)。

#mipslinuxircチャンネルの人々がこの問題を解決するのを手伝ってくれました-ありがとう。

2
botzko