ARM7交叉编译:elf文件中缺少符号

时间:2020-07-15 13:45:27

标签: c++ c arm cross-compiling

我对交叉编译没什么问题。 到目前为止,我在LPC2378 IC上使用ARM7裸机,并且从WinXP上的Eclipse内部构建器编译二进制文件。

现在我需要更改系统,所以我尝试在新计算机上编译它,这不起作用:在elf文件中编译后,缺少许多符号(工作有〜500kb,无法工作〜10kb,也检查了objdump),但没有错误。

例如,在elf中,我找不到对主函数的引用。

在两种情况下,我都使用arm-none-eabi工具链。在新机器上,我尝试使用最新版本的工具链(在Ubuntu 20.04 64b WindowsSubshel​​lLinux上交叉编译),并且与旧机器相同(在4.9,在Ubuntu32b上交叉编译,虚拟机)。

使用了编译命令:

编译源代码:

arm-none-eabi-g++ -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -Wabi -Wctor-dtor-privacy -Wnoexcept -Wnon-virtual-dtor -Wstrict-null-sentinel -Wsign-promo -Weffc++ <my_local_flags> -I<paths_to_includes> -c -o <path_to_o_file> <path_to_cpp_source>

arm-none-eabi-gcc -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -std=gnu11  -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -Wstrict-prototypes -Wbad-function-cast     <my_local_flags> -I<paths_to_includes> -c -o <path_to_o_file> <path_to_c_source>

链接:

arm-none-eabi-g++ -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -T<path_to_linker_script> -Xlinker --gc-sections -Wl,-Map,<path_to_map> -o <path_to_elf_file> <paths_to_o_files>

路径:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mnt/c/ProgramFiles/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2020.424.0_x64__79rhkp1fndgsc:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Users/user/AppData/Local/Microsoft/WindowsApps:/home/user/env/gcc-arm-none-eabi/9-2020-q2-update/bin

工具链已作为预编译的二进制文件从官方网站(https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads https://launchpad.net/gcc-arm-embedded/)下载

有人有类似的问题吗? 感谢您的帮助

更新:

我使用arm工具链中的readelf读取了两个elf文件,其中一个没有入口点:

工作精灵:

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:               0x3000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          538908 (bytes into file)
  Flags:                             0x5000202, has entry point, Version5 EABI, soft-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         14
  Section header string table index: 11

不起作用的小精灵:

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:               0x3000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          82820 (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:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         14
  Section header string table index: 13

使用g ++标志(-fdata-sections,-Xlinker --gc-sections,命令末尾的-T)进行操作无济于事。

0 个答案:

没有答案