Skip to content
Browse files

linker: move scripts generated code at the beginning of .text

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 #17038.

Fixes: #17038.

Signed-off-by: Wentong Wu <>
  • Loading branch information...
wentongwu authored and nashif committed Jul 1, 2019
1 parent 9d42858 commit e51c2095cdfcc521929da76d21ed54e2d84b143a
Showing with 4 additions and 3 deletions.
  1. +4 −3 include/arch/arm/cortex_m/scripts/linker.ld
@@ -191,6 +191,10 @@ SECTIONS
_image_text_start = .;

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

@@ -201,9 +205,6 @@ SECTIONS
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)

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


_image_text_end = .;

0 comments on commit e51c209

Please sign in to comment.
You can’t perform that action at this time.