[Ninux-Wireless] MIPSEL: Differenze tra un ELF prodotto su Debian MIPSEL e uno su OpenWRT MIPSEL

Luca Dionisi luca.dionisi a gmail.com
Gio 5 Maggio 2011 20:35:06 CEST


Salve ragazzi, vorrei sottoporvi una questione confidando nella vostra
esperienza con OpenWRT e embedded.

Vorrei produrre un eseguibile per un router che monta openwrt backfire.
Tale router è un Omnima ADM5120.

Per compilare il mio programma ho usato una debian installata su un
sistema mipsel emulato con qemu-system-mipsel.
Ho seguito le informazioni segnalate qui:
http://www.aurel32.net/info/debian_mips_qemu.php

Il problema è che un eseguibile che funziona nella macchina emulata
debian non funziona nel router e viceversa.
Gli eseguibili nel sistema debian (sia quelli forniti dal sistema sia
quello che compilo io) sono diversi dagli eseguibili nel sistema
openwrt del mio router.
Più in basso riporto le informazioni che ho potuto reperire su queste
differenze usando "file" e "readelf".

In particolare mi salta all'occhio la differenza nel ELF header della
OS/ABI Version: UNIX - System V versione 0 e versione 1.
Cosa è questa cosa della versione 1 che vedo solo in OpenWRT?

Quello che vorrei fare è ottenere un ambiente di compilazione comodo
da usare (come una debian virtualizzata) per produrre eseguibili che
funzionino nel router.
E' possibile?

Un altro punto. L'eseguibile che vado a produrre ha bisogno di diverse
shared libraries.
Queste sono semplici da reperire nei pacchetti debian, mentre
difficili da trovare in pacchetti openwrt.
Ovviamente estrarre i files dai diversi formati (deb o ipk) è banale,
ma anche in questo caso un passaggio con readelf mi dice che il
contenuto è incompatibile.





Ho portato sulla mia macchina (ubuntu) un file prodotto nella debian
virtualizzata e uno di quelli nella distribuzione openwrt del router.
Li ho esaminati con "file" e "readelf".

Il comando "file" dice:
1)debian
$ file exe_a
exe_a: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.18, with
unknown capability 0xf41 = 0x756e6700, not stripped
2)openwrt
$ file opkg
opkg: ELF 32-bit LSB executable, MIPS, MIPS32 version 1, dynamically
linked (uses shared libs), corrupted section header size

Il comando "readelf" dice:
1)debian
$ readelf -h exe_a
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:               0x403680
  Start of program headers:          52 (bytes into file)
  Start of section headers:          338016 (bytes into file)
  Flags:                             0x1007, noreorder, pic, cpic, o32, mips1
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         33
  Section header string table index: 30
2)openwrt
$ readelf -h opkg
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:               0x4020b0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x50001005, noreorder, cpic, o32, mips32
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0



Maggiori informazioni sulla lista Wireless