GCC 8.0 для соединения ARM не удалось, если задана опция -flto (оптимизация времени соединения) - PullRequest
1 голос
/ 13 марта 2019

Я только что обновил свой 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 - «Улучшения оптимизации времени соединения». Так что, скорее всего, это проблема оптимизации времени соединения.

Как я могу решить эту проблему?

1 Ответ

2 голосов
/ 15 марта 2019

После поиска в Google с разными ключевыми словами я нашел ответ в https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89183. Это известная ошибка, исправленная в gcc 8.3.

...