Skip to content

Commit

Permalink
linker: move scripts generated code at the beginning of .text
Browse files Browse the repository at this point in the history
When code relocation enabled, there will be serval regions holding
text. And then there will be function call between these .text
regions, when distance between caller and callee is too far, linker
will automatically generate and insert veneer functions. And these
veneer functions will be located right after the last instruction
in the .text region by the linker. So these code will be put in the
memory reserved for priv_stacks text and kobject text if they don't
consume all the reserved memory. Or the veneer functions will be put
before the reserved memory if there isn't code in the reserved
memory. And then in the user mode building process, there will be
different memory layout and it will cause usr mode not working.
And moving the memory reserved for priv_stacks text and kobject text
at the beginning of .text will avoid above problem. The detailed
analysis for this issue can be found on Github issue zephyrproject-rtos#17038.

Fixes: zephyrproject-rtos#17038.

Signed-off-by: Wentong Wu <[email protected]>
  • Loading branch information
wentongwu committed Jul 1, 2019
1 parent b7d4b00 commit 4fd2136
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/arch/arm/cortex_m/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME_2,,)
{
_image_text_start = .;

#include <linker/priv_stacks-text.ld>
#include <linker/kobject-text.ld>

*(.text)
*(".text.*")
*(.gnu.linkonce.t.*)
Expand All @@ -201,9 +205,6 @@ SECTIONS
*/
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)

#include <linker/priv_stacks-text.ld>
#include <linker/kobject-text.ld>

} GROUP_LINK_IN(ROMABLE_REGION)

_image_text_end = .;
Expand Down

0 comments on commit 4fd2136

Please sign in to comment.