Ошибка сегментации ARM Cross Complie Linux Arm920t - PullRequest
0 голосов
/ 02 марта 2019

У меня есть плата с процессором arm920t (AT91RM9200).На целевой Linux:

root@test-device:/home/andy # uname -a
Linux test-device 2.6.21.201509.01 #13 Wed Jun 22 11:06:51 EEST 2016 armv4tl unknown

На моей хост-машине я использую виртуальную машину Ubuntu 18.04 в качестве системы для кросс-компиляции.В моем Ubuntu у меня есть 2 пакета для кросс-компиляции:

  1. arm-linux-gnueabi
  2. arm-none-eabi

Попробуйте собратьпросто привет, мир

включает

int main()
{
    printf("Hello world\n");
    return 0;
}

Я делаю это из каждого из пакетов

1. supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static
2. supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs

В обоих случаях я получил 2 исполняемых файла: двоичный файл readelf и утилиты для файла:

1. (arm-linux-gnueabi)
supersonic@ubuntu-vBox:~$ readelf -h hello_arm
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:               0x101a0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          501788 (bytes into file)
  Flags:                             0x5000200, Version5 EABI, soft-float ABI
  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: 29
supersonic@ubuntu-vBox:~$ 

supersonic@ubuntu-vBox:~$ file hello_arm
hello_arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=15d06e43de8c8d13d7e0110e311532a9187ca9e5, not stripped

2. (arm-none-eabi)

    supersonic@ubuntu-vBox:~$ readelf -h hello_arm_none-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:               0x8148
      Start of program headers:          52 (bytes into file)
      Start of section headers:          186056 (bytes into file)
      Flags:                             0x5000200, Version5 EABI, soft-float ABI
      Size of this header:               52 (bytes)
      Size of program headers:           32 (bytes)
      Number of program headers:         3
      Size of section headers:           40 (bytes)
      Number of section headers:         27
      Section header string table index: 24

    supersonic@ubuntu-vBox:~$ file hello_arm_none-eabi 
    hello_arm_none-eabi: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

Загрузил оба файла на целевую машину, установил разрешение на выполнение

root@test-device:/home/andy # chmod +x hello_arm
root@test-device:/home/andy # chmod +x hello_arm_none-eabi

Когда я пытаюсь запустить каждый из этих двоичных файлов, получил следующие результаты

  1. (arm-linux-gnueabi)

    root @ test-device: / home / andy # ./hello_arm Недопустимая инструкция

  2. (arm-none-eabi)

    root @ test-device: / home / andy # ./hello_arm_none-eabi Ошибка сегментации

На целевой машине находится старый работающий двоичный файл, но разработчик, которыйсделал это в настоящее время недоступно, и он потерял контакты

Это работает бинарный readelf и утилиты файла говорят об этом:

supersonic@ubuntu-vBox:~$ readelf -h /media/share_rw/MTXReader 
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:               0xab1c
  Start of program headers:          52 (bytes into file)
  Start of section headers:          681968 (bytes into file)
  Flags:                             0x2, GNU EABI, <unknown>
  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:         38
  Section header string table index: 35

supersonic@ubuntu-vBox:~$ file /media/share_rw/MTXReader 
/media/share_rw/MTXReader: ELF 32-bit LSB executable, ARM, version 1 (ARM), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.10, with debug_info, not stripped

Также попробуйте bпострой мой "привет мир" с опциями1. supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static -mcpu=arm920t -march=armv4t2. supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs -mcpu=arm920t -march=armv4tНо с такими же результатами

Есть идеи, почему это произошло и что делать?

...