GCC 7.2.1 with LTO reports "Error: offset out of range"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Version: GNU Tools for Arm Embedded Processors 7-2017-q4-major
Original build, downloaded from developer.
Running on Ubuntu 16.04.4 LTS (xenial), x86_64
The test case is attached to the bug report.
To run the test case:
- $ tar xaf "the_test_
- $ cd test/
- $ ./build.sh
The output contains the error message like:
/tmp/ccXrBd4D.s:27: Error: offset out of range
The archive contains the full output as captured on my host, see test/out.txt
Also, the ccXrBd4D.s file is stored in the same directory for reference.
This problem does not show up when running GCC 6.3.1 (6-2017-q2-update).
Without -flto flag the original project compiles and runs fine (by GCC 7 or 6).
Adding the "-ffunction-
The offending line 27 of the assembler code is:
ldr.w r0, =0xE000ED88
The line comes from the FreeRTOS "naked" function vPortEnableVFP(), which contains an __asm() statement.
In the original project I also encountered the same error triggered at another line:
ldr r0, =0xE000ED08
this asm instruction is from the __asm() statement in function prvPortStartFir
My original project triggered error messages at both lines, but one of the errors was gone during source reduction.
The provided test code is radically reduced with creduce after pre-processing. So, the type definitions in different files are not aligned. Minor changes to the source code make the error disappear. When I tried to synchronize the type definitions in different files, the problem went away.
description: | updated |
The problem is not LTO specific in my opinion. I think the LTO factor here is that the function with this LDR gets too large and the assembler generates a pc-relative ldr to a literal pool entry which is too far from the ldr. It should be reproducible by setting a big enough value for the function being assembled.