g++ link step fails because of vfp register use conflict

Asked by nrh

This issue is similar to Question #208418 (https://answers.launchpad.net/gcc-arm-embedded/+question/208418),
however, the proposed solution to that question doesn't work here.

I built the toolchain myself (not using the prebuilt binaries).

I'm compiling an application with g++ and I fail in the link step with the following errors:

/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: error: DMAManager.elf uses VFP register arguments, /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(unwind-arm.o) does not
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(unwind-arm.o)
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: error: DMAManager.elf uses VFP register arguments, /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(pr-support.o) does not
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(pr-support.o)
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: DISCARD has both ordered [`.ARM.exidx' in /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(unwind-arm.o)] and unordered [`.ARM.extab' in /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/libgcc.a(unwind-arm.o)] sections
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

I compile with the following flags:

CFLAGS="-g -O0 -D USE_STDPERIPH_DRIVER -DSTM32F40XX -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm -mcpu=cortex-m4 -mthumb -mhard-float -nostdlib -mfloat-abi=hard -mfpu=fpv4-sp-d16"

LINKER_FLAGS="-Xlinker -oDMAManager.elf -Xlinker -M -Xlinker -Map=DMAManager.map"

As I understand the issue, I'm not enabling hardware floating point exactly correct. Am I missing a flag,
or is the issue somewhere else?

Thank you very much for your time!

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
nrh
Solved:
Last query:
Last reply:
Revision history for this message
nrh (nrh) said :
#1

There seem to be two distinct problems.

If I change the CFLAGS to software floating point

" -g -O0 -D USE_STDPERIPH_DRIVER -DSTM32F40XX -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm -mthumb -mcpu=cortex-m4 -nostdlib -mfloat-abi=softfp -mfpu=fpv4-sp-d16"

Then I lose the vfp register errors but I still have the following error:

/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: DISCARD has both ordered [`.ARM.exidx' in /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/armv7e-m/softfp/libgcc.a(unwind-arm.o)] and unordered [`.ARM.extab' in /home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/armv7e-m/softfp/libgcc.a(unwind-arm.o)] sections
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

And I do need hardware floating point. So it seems to me that I'm somehow linking in libraries that don't support hardware floating point, even though I believe I'm passing the specified flags. I have no idea what is causing the second error.

Thanks again for your time

Revision history for this message
nrh (nrh) said :
#2

Just a little more information here:

I'm compiling a c++ application, the link and compile stages are separated. I'm on Ubuntu 12.04, I built the ARM toolchain myself as per the shipped instructions.

Revision history for this message
nrh (nrh) said :
#3

Okay, I've managed to solve both of these issues.

Turns out, the DISCARD both ordered and unordered error is simple.

In my linker script, I simply changed the "DISCARD" header to "/DISCARD/". Apparently
this is a bug that isn't yet fixed in some linker script templates (such as the one I was using
from ST).

The original issue with VFP registers was trickier, but it turns out that what I needed to do
was pass

"-fno-exceptions"

as a compiler flag. It seems exceptions were being compiled in and bringing in the systems calls
that conflicted with hardware floating point.

As it stands finally, I compile with the following:

CFLAGS="-g -O0 -D USE_STDPERIPH_DRIVER -DSTM32F40XX -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm -fno-exceptions -mthumb -mcpu=cortex-m4 -nostdlib -mfloat-abi=hard -mfpu=fpv4-sp-d16"

LINKER_FLAGS="-Xlinker -oDMAManager.elf -Xlinker -M -Xlinker -Map=DMAManager.map"