Why does arm-linux-gnueabi-g++-4.4 always build a “7-A” binary?

无人久伴 提交于 2019-11-28 08:48:24

Your compiler supports armv4t, problem is your linker has to link your object file with other files like libc, crt.o to create an executable. However in your toolchain all those files have been compiled for 7-A, thus result executable ends up being one as well. This is a problem with ubuntu cross toolchains, they are armv7a by default.

If you just compile your source file, you'll see that compiler outputs right object file type.

$ arm-linux-gnueabi-g++-4.4 -mcpu=arm9tdmi -march=armv4t -O -c main.cpp -o CPPTest

$ readelf -A CPPTest
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM9TDMI"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_optimization_goals: Prefer Speed
  Tag_DIV_use: Not allowed

So a toolchain is more than a compiler and every component of it needs to play along.

The "Configured with" line for your arm-linux-gnueabi-g++-4.4 clearly states that the compiler was not built for arm9 but ARMv7, i.e. ARM Cortex Ax (although it's missing the interwork option for mixed ARM/Thumb aka Thumb2 code):

Configured with: ... --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb ...

You probably want a different compiler built as unspecified ARM.
Consider using BuildRoot to build a complete toolchain for your project.
Or download the gcc-4.0 or 4.1 toolchain from gnuarm.com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!