This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/AM4376:当设置 vfpu 标志时、链接器根据 thumb 指令集进行链接

Guru**** 3036750 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/906368/ccs-am4376-linker-links-against-thumb-instruction-set-when-vfpu-flag-is-set

器件型号:AM4376

工具/软件:Code Composer Studio

CCS10、PDK PDK_AM437X_1_0_15。 使用 CCS (Helloworld)创建和应用。 设置 -marm -mfloat-abi=hard -mfpu=neon 并查看链接器映射文件。 它指向拇指指令集。 如果将该标志设置为仅 -marm -mfloat-abi=hard、则它使用 lib/hard、而不是 thumb。 不确定为什么在 FPU 标志置1时链接 thumb 静态库。  

当 -mfpu=neon 时

* STARTUP_ARMCA9.o (.text)
*(.text*)
.text 0x8000000 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/thumb/v7-ar/fpv3/hard/crti.o
.text 0x8000000 0x50 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/thumb/v7-ar/fpv3/hard/crtbegin.o
.text 0x80000050 0x74 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/crt0.o
0x80000050 _START
0x80000050 _mainCRT 启动
.text 0x800000c4 0x3c8 C:/Users/akcheria/T1/__syncError/out/obj/main_A.o
0x800000c4 getCRC (无符号字符)
0x800000f8 CRC32 (void const*、unsigned int、unsigned long)
0x800001e8 crc32y (void const*、unsigned int、unsigned long)
0x800002cc littlemain
0x80000480 MAIN
.text 0x8000048c 0x60 C:/Users/akcheria/T1/__syncError/out/obj/startup_ARMCA9_A.o
0x8000048c 条目
.text 0x800004ec 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard libg.a (lib_a-exit.o)
text.exit 0x800004ec 0x20 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard libg.a (lib_a-exit.o)
0x800004ec 退出

未 设置-mfpu=neon 时

.text 0x80000000 0xb4 C:/SCM/CORE/Project_Software_Eng/Code_PI/CoreACE/TargetLibs/TARG_Tx_CoreBoard/Tx_Port/out/libtx_coreboard_A.a (init.o)
0x80000000条目
.text 0x800000b4 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/hard libstdc++_nano。a (ios_init.o)
.text 0x800000b4 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/hard libstdc++_nano。a (locale_init.o)
.text 0x800000b4 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/hard libstdc++_nano。a (co-locale_init.o)
.text 0x800000b4 0x0 c:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/hard libg.a (lib_a-init.o)

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

      gcc-arm-none-eabi-7-2018-Q2-update 的 gcc -print-multi-lib 选项的输出为:

    $ bin/arm-none-eabi-gcc --print-multi-lib
    ;
    thumb;@mthumb
    hard;@mfloat-abi=hard
    thum/v6-m;@mthum=armv6s-msp/v7-m
    ;@mthumb@mv7msp/mthumb@
    @@
    @@
    @@
    @@
    @@@@
    @@@@msp/msp-msp=armv7msp/msp-msp/msp=msp/msp/msp-msp/msp/msp=msp/msp/msp=msp/msp/msp/msp/msp/msp=msp/msp/msp/msp/msp/msp/msp/msp=msp/msp/msp/msp/msp/msp/msp=msp/msp/msp/msp/msp/msp=msp/msp/msp/msp/msp=msp/msp/msp/msp/msp/msp/msp/msp/msp/m
    
    
    
    
    
    @@@@@@@@@@@@@@@@@@@@@@@@ 

    上面的内容控制 gcc 链接器如何选择要链接的库。 使用-mfpu 选项以及 -mfloat-abi=hard 后、上面显示将链接一个 thumb 静态库。

    我不知道为什么提供的库只是拇指、但由于 Cortex-A9支持 ARM/thumb 交互工作、因此不认为这会导致功能问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这是否意味着、如果我们设置了-mfpu 选项、则代码将始终链接为 thumb 模式? 这类似于将-mthumb 设置为对吗? 即使我们将其设置为-marm? 我不确定这是否不会导致任何功能问题、当我们明确链接-mam 时是否有经验法则?  https://developer.arm.com/docs/dui0471/k/interworking-arm-and-thumb/when-to-use-interworking 似乎意味着在这样做时需要进行权衡。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    [引用 user="Arun Cherian"]这是否意味着如果我们设置了-mfpu 选项,则代码将始终链接为 thumb 模式?

    这意味着自动选择的 RTS 库是为 thumb 模式构建的。

    [引用用户="Arun Cherian"]这类似于设置-mthumb 对吗?

    否  您的代码将继续根据您选择的构建选项进行构建。

    [引用 user="Arun Cherian"]即使我们将其设置为-marm?

    然后、您的代码是针对 ARM 模式构建的。

    [引用 user="Arun Cherian"]我不确定这是否会导致任何功能问题,当我们明确链接-mam 时是否有经验法则?

    可以了。  支持使用这些不同模式构建的混合函数。

    [引用 user="Arun Cherian"]https://developer.arm.com/docs/dui0471/k/interworking-arm-and-thumb/when-to-use-interworking 似乎意味着在这方面需要进行权衡。

    该文章建议您如何确定哪种模式最适合代码的不同部分。

    谢谢、此致、

    乔治

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您的回复 George。

    为什么为针对 ARM 模式构建的代码选择 Thumb 模式运行时库? 似乎只有在设置了-mfpu 时才会发生这种情况? 如果不是、它似乎使用常规库。 它可能起作用、但它的作用是什么? 设置-mfpu 标志决定是否链接了 ARM 或 thumb 运行时库似乎奇怪、似乎没有关联?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我怀疑-mfpu 与自动选择的 RTS 库通常以 Thumb 模式构建这一事实之间存在任何有意的关系。  这可能是因为编译器提供的大多数 RTS 库都是使用 Thumb 模式构建的。  这是因为、在大多数情况下、大多数用户都倾向于将 RTS 函数设置为 Thumb 模式。

    谢谢、此致、

    乔治