It's a floating world!

sorry. japanese only. CodeSourceryのツールチェインで,Floatオプション毎による生成されるオブジェクトの アーキテクチャフラグとリンクされるライブラリ(とそのアーキフラグ)について Floatオプション -mfloat-abi=soft の場合: (HardFaultにならない) $ readelf -A /tmp/work/template/obj/main.o Attribute Section: aeabi File Attributes Tag_CPU_name: "Cortex-M4" Tag_CPU_arch: v7E-M Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 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: small Tag_ABI_optimization_goals: Aggressive Size Tag_CPU_unaligned_access: v6 リンクされるライブラリ: ->c:/program files/codesourcery/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-memset.o) Floatオプション -mfloat-abi=softfp -mfpu=fpv4-sp-d16 の場合: (HardFaultにならない) $ readelf -A /tmp/work/template/obj/main.o Attribute Section: aeabi File Attributes Tag_CPU_name: "Cortex-M4" Tag_CPU_arch: v7E-M Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_FP_arch: VFPv4-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: small Tag_ABI_HardFP_use: SP and DP Tag_ABI_optimization_goals: Aggressive Size Tag_CPU_unaligned_access: v6 Tag_FP_HP_extension: Allowed リンクされるライブラリ: ->c:/program files/codesourcery/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-memset.o) Floatオプション -mfloat-abi=hard -mfpu=fpv4-sp-d16 の場合: (HardFaultになる) $ readelf -A /tmp/work/template/obj/main.o Attribute Section: aeabi File Attributes Tag_CPU_name: "Cortex-M4" Tag_CPU_arch: v7E-M Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_FP_arch: VFPv4-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: small Tag_ABI_HardFP_use: SP and DP Tag_ABI_VFP_args: VFP registers Tag_ABI_optimization_goals: Aggressive Size Tag_CPU_unaligned_access: v6 Tag_FP_HP_extension: Allowed リンクされるライブラリ: ->c:/program files/codesourcery/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-memset.o) ↑でリンクされるCodeSourceryのライブラリ: File: /cygdrive/c/Program Files/CodeSourcery/arm-none-eabi/lib/thumb2/libc.a(lib_a-memset.o) Attribute Section: aeabi File Attributes Tag_CPU_name: "7" Tag_CPU_arch: v7 Tag_THUMB_ISA_use: Thumb-2 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: small Tag_ABI_optimization_goals: Aggressive Speed Tag_CPU_unaligned_access: v6 Tag_DIV_use: Not allowed [オマケ] SAT(Summon Arm Toolchain)のmultilibパッチを適用してビルドしたツールチェインで (binutils-2.22,GCC-4.6.2,newlib-1.20.0)生成した場合のアーキテクチャフラグ Floatオプション -mfloat-abi=hard -mfpu=fpv4-sp-d16 の場合: (HardFaultにならない) $ readelf -A /tmp/work/template/obj/main.o Attribute Section: aeabi File Attributes Tag_CPU_name: "Cortex-M4" Tag_CPU_arch: v7E-M Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_FP_arch: VFPv4-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: small Tag_ABI_HardFP_use: SP and DP Tag_ABI_VFP_args: VFP registers Tag_ABI_optimization_goals: Aggressive Size Tag_FP_HP_extension: Allowed リンクされるライブラリ: ->/usr/local/lib/gcc/arm-hardfloat-eabi/4.6.2/../../../../arm-hardfloat-eabi/lib/thumb/cortex-m4/float-abi-hard/fpuv4-sp-d16/libc.a(lib_a-memset.o) ↑のライブラリ: File: /usr/local/arm-hardfloat-eabi/lib/thumb/cortex-m4/float-abi-hard/fpuv4-sp-d16/libc.a(lib_a-memset.o) Attribute Section: aeabi File Attributes Tag_CPU_name: "Cortex-M4" Tag_CPU_arch: v7E-M Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_FP_arch: VFPv4-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: small Tag_ABI_HardFP_use: SP and DP Tag_ABI_VFP_args: VFP registers Tag_ABI_optimization_goals: Aggressive Speed Tag_FP_HP_extension: Allowed ※リンクも実行も可能だけど,FP演算の結果が正しくない...オブジェクト自体は, vldrやvstr命令は生成されて,Dレジスタ群をビシバシ使っているけど,libgcc含む ライブラリがS,Dレジスタ群を使っていない...ツールチェインのコンフィグミスかな。 [参考] -mfloat-abi=hardで実行可能なコードを吐き出せるツールチェインを作ったときのメモ: required libraries 0. prepare somethings: fetched & extracted archives. for dir in gmp* mpfr* mpc*; do mkdir $dir/i686-pc-cygwin-build; done 1. gmp: cd gmp*/i686-pc-cygwin-build # change current work directory into build directory CPPFLAGS=-fexceptions \ ../configure \ --prefix=/usr/local \ --with-gnu-ld \ --disable-shared \ --enable-cxx time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s" CPPFLAGS="-fexceptions" -j 4 time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s" CPPFLAGS="-fexceptions" check make install 2. mpfr: cd ../../mpfr*/i686-pc-cygwin-build # change current work directory into build directory CFLAGS='-I/usr/local/include' \ LDFLAGS='-s -L/usr/local/lib' \ ../configure \ --prefix=/usr/local \ --with-gnu-ld \ --with-gmp=/usr/local time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s -L/usr/local/lib" -j 4 time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s -L/usr/local/lib" check make install 3. mpc: cd ../../mpc*/i686-pc-cygwin-build # change current work directory into build directory CFLAGS='-I/usr/local/include' \ LDFLAGS='-s -L/usr/local/lib' \ ../configure \ --prefix=/usr/local \ --with-gnu-ld \ --disable-shared \ --with-gmp=/usr/local \ --with-mpfr=/usr/local time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s -L/usr/local/lib" -j 4 time make CFLAGS="-O2 -fomit-frame-pointer" LDFLAGS="-s -L/usr/local/lib" check make install cd ../.. 4. prepare somethings for building cross-compiler toolchain: ln -s cygwin/process.h /usr/include/process.h ↑cygwinのdllを更新したらspawn関係の機能をbinutilsのビルドが要求するので... for dir in binutils* gcc* newlib*; do mkdir $dir/arm-hardfloat-eabi; done SAT's patches applied 5. binutils: cd binutils*/arm-hardloat-eabi-build CFLAGS="-O2 -fomit-frame-pointer -I/usr/local/include" LDFLAGS="-s -L/usr/local/lib" \ ../configure \ --prefix=/usr/local \ --target=arm-hardfloat-eabi \ --build=i686-pc-cygwin --host=i686-pc-cygwin \ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local \ --with-ppl=/usr/local --with-cloog=/usr/local \ --disable-nls time make CFLAGS="-O2 -fomit-frame-pointer -I/usr/local/include" LDFLAGS="-s -L/usr/local/lib" -j 4 time make CFLAGS="-O2 -fomit-frame-pointer -I/usr/local/include" LDFLAGS="-s -L/usr/local/lib" check make install hash -r which arm-hardfloat-eabi-ld `which arm-hardfloat-eabi-ld` --version 6. gcc: cd ../../gcc*/arm-hardloat-eabi-build CFLAGS="-O2 -fomit-frame-pointer -I/usr/local/include" LDFLAGS="-s -L/usr/local/lib" \ ../configure \ --prefix=/usr/local \ --target=arm-hardfloat-eabi \ --build=i686-pc-cygwin --host=i686-pc-cygwin \ --enable-languages=c,c++ \ --enable-lto \ --enable-multilib \ --with-gnu-as \ --with-gnu-ld \ --with-newlib --without-headers \ --disable-newlib-supplied-syscalls \ --with-libelf=/usr/local \ --with-gmp=/usr/local \ --with-mpfr=/usr/local \ --with-mpc=/usr/local \ --without-ppl \ --without-cloog \ --disable-shared \ --disable-threads \ --disable-decimal-float \ --without-gnattools \ --disable-boehm-gc \ --disable-libquadmath \ --disable-libffi \ --disable-libjava \ --disable-libada \ --disable-libstdc++-v3 \ --disable-libstdcxx-pch \ --disable-libgfortran \ --disable-libgo \ --disable-libobjc \ --disable-libgomp \ --disable-libmudflap \ --disable-libssp \ --disable-zlib \ --disable-nls time make LANGUAGES="c c++" CFLAGS="-O2 -fomit-frame-pointer -I/usr/local/include" LDFLAGS="-s -L/usr/local/lib" -j 4 time make install hash -r which arm-hardfloat-eabi-gcc `which arm-hardfloat-eabi-gcc` --version `which arm-hardfloat-eabi-gcc` -print-sysroot `which arm-hardfloat-eabi-gcc` -print-libgcc-file-name `which arm-hardfloat-eabi-gcc` -print-multi-lib `which arm-hardfloat-eabi-gcc` -dumpspecs `which arm-hardfloat-eabi-gcc` --target-help 7. newlib: cd ../../newlib*/arm-hardloat-eabi-build CFLAGS="-g -O2 -fno-unroll-loops -DREENTRANT_SYSCALLS_PROVIDED" \ ../configure \ --prefix=/usr/local \ --target=arm-hardfloat-eabi \ --build=i686-pc-cygwin --host=i686-pc-cygwin \ --enable-newlib-io-long-long \ --enable-newlib-register-fini \ --enable-newlib-reent-small \ --disable-newlib-supplied-syscalls \ --disable-libgloss \ --disable-nls time make CFLAGS="-g -O2 -fno-unroll-loops -DREENTRANT_SYSCALLS_PROVIDED" -j 4 time make CFLAGS="-g -O2 -fno-unroll-loops" check make install reference: where i got archives from https://github.com/MikeSmith/summon-arm-toolchain/tree/master/patches some patches ftp://gcc.gnu.org/pub/ binutils-2.22 gcc-4.6.2 gdb-7.4 gmp-5.0.4 mpfr-3.1.0 ftp://gcc.gnu.org/pub/gcc/infrastructure/ cloog-ppl-0.15.11 http://sourceware.org/newlib/ newlib-1.20.0 http://sourceware.org/insight/ insight-6.8-1a http://www.multiprecision.org mpc-0.8.2 http://bugseng.com/products/ppl ppl-0.11.2 http://www.mr511.de/software/ libelf-0.8.13 [ご注意] ・このページの記載事項については,一切無保証です。
inserted by FC2 system