如果给出-flto(链接时间优化)选项,则GCC 8.0 for ARM链接失败

问题描述 投票:0回答:1

我刚刚将我的gcc-arm-none-eabi从7.3.1(2018 q2)升级到8.2.1(2018 q4)。链接时发生错误。

编译命令是

arm-none-eabi-gcc -c -mcpu=cortex-m23 -mthumb   -Wall -Wextra -DARM_MATH_ARMV8MBL -D_DEBUG -Iinc1/ -Iinc2/ -Iinc3/ -fdata-sections -ffunction-sections -g3 -Os -flto -Wno-unused-parameter obj1.c -o obj1.o

链接命令是

arm-none-eabi-gcc  -mcpu=cortex-m23 -mthumb   --specs=nano.specs --specs=nosys.specs -Tlink_script.ld  -lc -lm -Wl,-Map=output.map,--cref -Wl,--gc-sections -g3 -Os -flto obj1.o obj2.o obj3.o -o output.elf

这些命令适用于7.3.1。但是使用8.2.1时,链接时会出现以下错误:

../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 131328 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 145152 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 145152 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 40173580 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 41287693 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: D:\cygwin64\tmp\cccsjco0debugobjtem: invalid string offset 41287680 >= 22975072851460752 for section `(null)'
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d90) larger than the file size
d:/gcc-arm-none-eabi-8.2.1/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: D:\cygwin64\tmp\ccfrv4PTdebugobjtem has a corrupt section with a size (a0d68) larger than the file size
D:\cygwin64\tmp\ccfrv4PTdebugobjtem: file not recognized: file format not recognized

我尝试删除“-flto”,它按预期工作。此外,在https://gcc.gnu.org/gcc-8/changes.html,我发现GCC 8的一个主要变化是“链接时优化改进”。因此很可能是链接时优化的问题。

我怎么解决这个问题?

gcc cortex-m
1个回答
2
投票

在使用不同的关键字进行Google搜索后,我在https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89183找到了答案。这是一个已知的错误,并已在gcc 8.3中修复。

© www.soinside.com 2019 - 2024. All rights reserved.