Fix out of offset errors when LTO is enabled (#71)

When Link Time Optimization (LTO) is enabled, some of the LDR
instructions result in out of range access. The reason is that the
default generated literal pool is too far and not within the permissible
range of 4K.

This commit adds LTORG assembly instructions at required places to
ensure that access to literals remain in the permissible range of 4K.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
Gaurav-Aggarwal-AWS 2020-06-10 10:03:11 -07:00 committed by GitHub
parent 6199b72fbf
commit c4b4156fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 3 deletions

View File

@ -247,6 +247,7 @@ static void prvPortStartFirstTask( void )
" isb \n" " isb \n"
" svc 0 \n" /* System call to start first task. */ " svc 0 \n" /* System call to start first task. */
" nop \n" " nop \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View File

@ -451,6 +451,7 @@ BaseType_t xPortStartScheduler( void )
" isb \n" " isb \n"
" svc %0 \n" /* System call to start first task. */ " svc %0 \n" /* System call to start first task. */
" nop \n" " nop \n"
" .ltorg \n"
:: "i" (portSVC_START_SCHEDULER) : "memory" ); :: "i" (portSVC_START_SCHEDULER) : "memory" );
/* Should not get here! */ /* Should not get here! */

View File

@ -277,6 +277,7 @@ static void prvPortStartFirstTask( void )
" isb \n" " isb \n"
" svc 0 \n" /* System call to start first task. */ " svc 0 \n" /* System call to start first task. */
" nop \n" " nop \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -707,7 +708,8 @@ static void vPortEnableVFP( void )
" \n" " \n"
" orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */ " orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */
" str r1, [r0] \n" " str r1, [r0] \n"
" bx r14 " " bx r14 \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View File

@ -480,6 +480,7 @@ BaseType_t xPortStartScheduler( void )
" isb \n" " isb \n"
" svc %0 \n" /* System call to start first task. */ " svc %0 \n" /* System call to start first task. */
" nop \n" " nop \n"
" .ltorg \n"
:: "i" (portSVC_START_SCHEDULER) : "memory" ); :: "i" (portSVC_START_SCHEDULER) : "memory" );
/* Should not get here! */ /* Should not get here! */
@ -630,7 +631,8 @@ static void vPortEnableVFP( void )
" \n" " \n"
" orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */ " orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */
" str r1, [r0] \n" " str r1, [r0] \n"
" bx r14 " " bx r14 \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View File

@ -271,6 +271,7 @@ static void prvPortStartFirstTask( void )
" isb \n" " isb \n"
" svc 0 \n" /* System call to start first task. */ " svc 0 \n" /* System call to start first task. */
" nop \n" " nop \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -697,7 +698,8 @@ static void vPortEnableVFP( void )
" \n" " \n"
" orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */ " orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */
" str r1, [r0] \n" " str r1, [r0] \n"
" bx r14 " " bx r14 \n"
" .ltorg \n"
); );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/