I want to compile a program with gcc with link time optimization for an ARM processor. When I compile without LTO, the system gets compiled. When I enable LTO (with -flto), I get the following assembler-error:
Error: invalid literal constant: pool needs to be closer
Looking around the web I found out that this has something to do with the constants in my system, which are placed in a special section called .rodata, which is called a constant pool and is placed right after the .text section in my system. It seems that when compiling with LTO because of inlining and other optimizations this .rodata section gets too far away from the instructions, so that the addressing of the constants is not possible anymore. Is it possible to place the constants right after the function that uses them? Or is it possible to use another addressing mode so the .rodata section can still be addressed? Thanks.
.rodata. Usually, they are placed directly after a function. If you know where this is occurring (we need more context), I maybe able to give better help. For instance, if you have no inline assembler, then use__attribute__((noinline))on a specific problematic function. If it is in inline assembler, then other techniques can handle it.-fltois fairly new. It is possible for the compiler to locate branches (such asb 1fand place the literals). However, in the current form it probably only places them at the end of functions. - artless noise-flto, your function becomes larger than 4k and the end of the function is not within theldr rX,[pc, #immed_12]range. For resource constrained systems, this can also be bad as the inlining will increase stack use. Also, please give more information on the ARM target if possible (Thumb2?). - artless noise-finline-limit=2048,--param max-inline-insns-auto=200,--param max-inline-insns-single=200, etc. Basically, tell-fltoto limit the size of functions. - artless noise