4

I'm trying to compile my program to armv6, but the ELF file is built for armv7, even when I use -march=armv6 option. All .o files has been compiled to armv6, only the ELF file is wrong.

Basically I'm compiling like this:

arm-linux-gnueabihf-g++ -static -march=armv6 -mfpu=vfp -mfloat-abi=hard -marm -Wa,-march=armv6 -o "Bridge"

Checking all .o files I get this:

$ readelf -a -W Bridge.o | grep Tag Tag_CPU_name: "6" Tag_CPU_arch: v6 Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-1 Tag_FP_arch: VFPv2 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_VFP_args: VFP registers Tag_ABI_optimization_goals: Aggressive Speed Tag_CPU_unaligned_access: v6

But checking the ELF file:

$ readelf -a -W Bridge | grep Tag Tag_CPU_name: "7-A" Tag_CPU_arch: v7 Tag_CPU_arch_profile: Application Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-2 Tag_FP_arch: VFPv3 Tag_Advanced_SIMD_arch: NEONv1 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_rounding: Needed 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_VFP_args: VFP registers Tag_CPU_unaligned_access: v6

I'm using Linaro GCC 7.2.1, and I've also tried with old versions, and different compilation flags combinations. Can someone tell me how to compile an armv6 ELF file?

  • the compiler calls the linker and perhaps you need to send explicit linker commands. and/or link separately using the linker not the compiler. you can also do some things to see what is being passed to the linker. I would try using the linker directly first and specifying the architecture, before trying to get the compiler to send the right flags to the linker. – old_timer Jul 16 '18 at 18:51
  • Im not seeing that though, yet. I have a self built from sources 8.x.x and it defaults to architecture 4T unless otherwise specified, and when I specify armv6 on the compiler and let it call the linker, I get armv6. On an arm based system using gcc directly not cross compiled it defaults to armv7 but when I specify armv6 on the command line and allow the compiler to call the linker I get armv6 in the final binary. – old_timer Jul 16 '18 at 20:08

1 Answers1

2

Problem identified. The Linaro toolchain binary was able to compile the object files for the armv6 platform, however, the linker actually did not interpret this flag.

Reason: the toolchain was compiled with the armv7 configuration.

Solution: I downloaded the source code for the Linaro toolchain, configured it to support armv6 and compiled it using the cross-ng-tool.