Я пытаюсь собрать модуль ядра для моего DNS-320L NAS.
Я собрал crosstool-ng в среде Debian lenny chroot, но после того, как я скомпилировал свой модуль ядра и попытался установить его, я получаю:
insmod: error inserting 'kernel/net/ip4/ipip.ko': -1 Invalid module format
Когда я проверяю работающий модуль ядра с помощью readelf, я получаю:
~/ct-ng-build$ readelf -h ~/ct-ng-build/kernel/orig/ipip.ko
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: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 6696 (bytes into file)
Flags: 0x5000000, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 51
Но мой модуль имеет несколько отличий:
~/ct-ng-build$ readelf -h ~/ct-ng-build/kernel/modules/lib/modules/2.6.31.8/kernel/net/ipv4/ipip.ko
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: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 6280 (bytes into file)
Flags: 0x600, GNU EABI, software FP, VFP
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 23
Section header string table index: 20
Моя среда cross_compile:
$ echo $CROSS_COMPILE
arm-none-eabi-
make CROSS_COMPILE=${CROSS_COMPILE} INSTALL_PATH=~/ct-ng-build/kernel/install INSTALL_MOD_PATH=~/ct-ng-build/kernel/modules INSTALL_FW_PATH=~/ct-ng-build/kernel/firmware
Мой gcc скомпилирован:
$ ${CROSS_COMPILE}gcc -v
Using built-in specs.
Target: arm-none-eabi
Configured with: ~/ct-ng-build/targets/src/gcc-4.3.2/configure --build=x86_64-build_unknown-linux-gnu --host=x86_64-build_unknown-linux-gnu --target=arm-none-eabi --prefix=~/x-tools/arm-none-eabi --with-local-prefix=~/x-tools/arm-none-eabi/arm-none-eabi//sys-root --disable-multilib --disable-libmudflap --with-sysroot=~/x-tools/arm-none-eabi/arm-none-eabi//sys-root --with-newlib --enable-threads=no --disable-shared --with-pkgversion=crosstool-NG-1.9.0 --with-arch=armv5te --with-tune=arm926ej-s --disable-__cxa_atexit --with-gmp=~/ct-ng-build/targets/arm-none-eabi/build/static --with-mpfr=~/ct-ng-build/targets/arm-none-eabi/build/static --enable-target-optspace --disable-nls --enable-symvers=gnu --enable-languages=c,c++
Thread model: single
gcc version 4.3.2 (crosstool-NG-1.9.0)
Любые идеи, как сделать OS/ABI «UNIX — System V», а флаги — «0x5000000, Version5 EABI» вместо «Arm» и «0x600, GNU EABI, software FP, VFP»?
Или есть другая проблема?
Спасибо!
--- РЕДАКТИРОВАТЬ ---- Я специально пытаюсь настроить свою существующую ОС NAS:
Kernel 2.6.31.8 #1 armv5tel
C library gcc-4.3-mt-1.44.0
# /lib/libc-2.8.so
GNU C Library stable release version 2.8, by Roland McGrath et al.
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.3.2.
До сих пор мне удалось создать среду crosstool-ng только с помощью crosstool-ng-1.9.0, но она создала двоичные файлы, указанные выше.
Я попытался установить -mabi=apcs-gnu
в соответствии с 3.17.2 Параметры ARM но библиотека C не будет компилироваться со странными ошибками "отсутствующие заголовки" (я могу попробовать еще раз - возможно, что-то с моей средой chroot).
readelf
для модуля ядра, и он дал практически идентичные результаты вашему рабочему модулю ядра. Моя цепочка инструментов, которая создала модуль, предназначена для EABI. IOW, мой ответ обратный, что, кажется, подтверждается заголовком stackoverflow.com/questions/10780648/ . Но ваш префикс набора инструментовarm-none-eabi-
противоречит идее, что это OABI. - person sawdust   schedule 20.09.2017