'GCC Linker unexpectedly moves location counter backwards
I am developing new RTEMS BSP and I am modifying linker scripts
I modified this linker script file
.rwbarrier : ALIGN_WITH_INPUT {
. = ALIGN (bsp_section_rwbarrier_align);
} > REGION_DATA AT > REGION_DATA
.vector : ALIGN_WITH_INPUT {
bsp_section_vector_begin = .;
. = . + DEFINED (bsp_vector_table_in_start_section) ? 0 : bsp_vector_table_size;
bsp_section_vector_end = .;
} > REGION_VECTOR AT > REGION_VECTOR
Lets suppose that we need to put .vector section in the middle of some memory region thus we need symbol bsp_section_vector_begin to be aligned to 128, so I added this one line:
.vector : ALIGN_WITH_INPUT {
. = ALIGN(128);
bsp_section_vector_begin = .;
Now I get this error:
[build] linkcmds.base:xxx cannot move location counter backwards (from 0000000060022380 to 0000000060022370)
Which is pointing directly to this line
. = . + DEFINED (bsp_vector_table_in_start_section) ? 0 : bsp_vector_table_size;
But when changed this line to:
. = . + bsp_vector_table_size;
There is no error, linker is satisfied and system exceptions are working.
My question is: how can such an expression like this:
. = . + DEFINED (bsp_vector_table_in_start_section) ? 0 : bsp_vector_table_size;
evaluate in a such way it try to move location counter backward? I am sure bsp_vector_table_size is positive number, and my experiment confirmed it. . = . + 0 works as well. What is wrong with this espression?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
