linker: align _image_text_start/end/size linker symbols name

Cleanup and preparation commit for linker script generator.

Zephyr linker scripts provides start and end symbols for each larger
areas in the linker script.

The symbols _image_text_start and _image_text_end sometimes includes
linker/kobject-text.ld. This mean there must be both the regular
__text_start and __text_end symbols for the pure text section, as well
as <group>_start and <group>_end symbols.

The symbols describing the text region which covers more than just the
text section itself will thus be changed to:
_image_text_start -> __text_region_start
_image_text_end   -> __text_region_end

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-08-09 21:24:02 +02:00 committed by Anas Nashif
commit 3d82c7c828
16 changed files with 39 additions and 39 deletions

View file

@ -645,8 +645,8 @@ static const struct arm_mmu_flat_range mmu_zephyr_ranges[] = {
/* Mark text segment cacheable,read only and executable */ /* Mark text segment cacheable,read only and executable */
{ .name = "zephyr_code", { .name = "zephyr_code",
.start = _image_text_start, .start = __text_region_start,
.end = _image_text_end, .end = __text_region_end,
.attrs = MT_NORMAL | MT_P_RX_U_RX | MT_DEFAULT_SECURE_STATE }, .attrs = MT_NORMAL | MT_P_RX_U_RX | MT_DEFAULT_SECURE_STATE },
/* Mark rodata segment cacheable, read only and execute-never */ /* Mark rodata segment cacheable, read only and execute-never */

View file

@ -22,7 +22,7 @@ If CONFIG_SRAM_REGION_PERMISSIONS is enabled, the access permissions
vary: vary:
- By default, the Present, Write, and Execute Disable bits are - By default, the Present, Write, and Execute Disable bits are
set. set.
- The _image_text region will have Present and User bits set - The __text_region region will have Present and User bits set
- The __rodata_region region will have Present, User, and Execute - The __rodata_region region will have Present, User, and Execute
Disable bits set Disable bits set
- On x86_64, the _locore region will have Present set and - On x86_64, the _locore region will have Present set and
@ -866,7 +866,7 @@ def main():
if is_generic_section_present: if is_generic_section_present:
flags = flags | FLAG_P flags = flags | FLAG_P
pt.set_region_perms("_image_text", flags) pt.set_region_perms("__text_region", flags)
if isdef("CONFIG_LINKER_USE_BOOT_SECTION"): if isdef("CONFIG_LINKER_USE_BOOT_SECTION"):
pt.set_region_perms("lnkr_boot_text", flags | FLAG_P) pt.set_region_perms("lnkr_boot_text", flags | FLAG_P)

View file

@ -556,7 +556,7 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{ {
_image_text_start = .; __text_region_start = .;
#if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \ #if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \
!defined(CONFIG_LINKER_USE_PINNED_SECTION) !defined(CONFIG_LINKER_USE_PINNED_SECTION)
@ -588,8 +588,8 @@ SECTIONS
MMU_PAGE_ALIGN_PERM MMU_PAGE_ALIGN_PERM
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
_image_text_size = _image_text_end - _image_text_start; __text_region_size = __text_region_end - __text_region_start;
__rodata_region_start = .; __rodata_region_start = .;
#ifndef CONFIG_LINKER_USE_PINNED_SECTION #ifndef CONFIG_LINKER_USE_PINNED_SECTION

View file

@ -75,7 +75,7 @@ SECTIONS {
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(1024)) { SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(1024)) {
__rom_region_start = .; __rom_region_start = .;
_image_text_start = .; __text_region_start = .;
/* Located in generated directory. This file is populated by the /* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. * zephyr_linker_sources() Cmake function.
@ -95,7 +95,7 @@ SECTIONS {
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
#endif /* CONFIG_CPLUSPLUS && !CONFIG_CPP_STATIC_INIT_GNU && __MWDT_LINKER_CMD__ */ #endif /* CONFIG_CPLUSPLUS && !CONFIG_CPP_STATIC_INIT_GNU && __MWDT_LINKER_CMD__ */
_image_text_end = .; __text_region_end = .;
__rodata_region_start = .; __rodata_region_start = .;
#include <linker/common-rom.ld> #include <linker/common-rom.ld>

View file

@ -127,7 +127,7 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{ {
_image_text_start = .; __text_region_start = .;
#include <linker/kobject-text.ld> #include <linker/kobject-text.ld>
@ -143,7 +143,7 @@ SECTIONS
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
#if defined (CONFIG_CPLUSPLUS) #if defined (CONFIG_CPLUSPLUS)
SECTION_PROLOGUE(.ARM.extab,,) SECTION_PROLOGUE(.ARM.extab,,)
@ -205,12 +205,12 @@ SECTIONS
* RODATA must be the last section so that the size of the entire read * RODATA must be the last section so that the size of the entire read
* only area will be filled to a power of 2. * only area will be filled to a power of 2.
*/ */
MPU_ALIGN(ABSOLUTE(.) - _image_rom_start); MPU_ALIGN(ABSOLUTE(.) - __rom_region_start);
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
__rodata_region_end = .; __rodata_region_end = .;
_image_rom_end = .; __rom_region_end = .;
_image_rom_end_order = (LOG2CEIL(_image_rom_end) - 1) << 1; _image_rom_end_order = (LOG2CEIL(__rom_region_end) - 1) << 1;
GROUP_END(ROMABLE_REGION) GROUP_END(ROMABLE_REGION)

View file

@ -145,7 +145,7 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{ {
_image_text_start = .; __text_region_start = .;
#include <linker/kobject-text.ld> #include <linker/kobject-text.ld>
@ -162,7 +162,7 @@ SECTIONS
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
#if defined (CONFIG_CPLUSPLUS) #if defined (CONFIG_CPLUSPLUS)
SECTION_PROLOGUE(.ARM.extab,,) SECTION_PROLOGUE(.ARM.extab,,)

View file

@ -93,7 +93,7 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{ {
_image_text_start = .; __text_region_start = .;
#ifndef CONFIG_XIP #ifndef CONFIG_XIP
z_mapped_start = .; z_mapped_start = .;
#endif #endif
@ -126,8 +126,8 @@ SECTIONS
MMU_ALIGN; MMU_ALIGN;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
_image_text_size = _image_text_end - _image_text_start; __text_region_size = __text_region_end - __text_region_start;
#if defined (CONFIG_CPLUSPLUS) #if defined (CONFIG_CPLUSPLUS)
SECTION_PROLOGUE(.ARM.extab,,) SECTION_PROLOGUE(.ARM.extab,,)

View file

@ -145,7 +145,7 @@ SECTIONS
KEEP(*(.openocd_debug)) KEEP(*(.openocd_debug))
KEEP(*(".openocd_debug.*")) KEEP(*(".openocd_debug.*"))
_image_text_start = .; __text_region_start = .;
*(.text) *(.text)
*(".text.*") *(".text.*")
@ -161,7 +161,7 @@ SECTIONS
#endif #endif
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
__rodata_region_start = .; __rodata_region_start = .;
#include <linker/common-rom.ld> #include <linker/common-rom.ld>

View file

@ -30,7 +30,7 @@ SECTIONS
{ {
/* Trap table alignment required by SPARC V8 specification. */ /* Trap table alignment required by SPARC V8 specification. */
. = ALIGN(0x1000); . = ALIGN(0x1000);
_image_text_start = .; __text_region_start = .;
*(.text.traptable) *(.text.traptable)
*(.text) *(.text)
@ -39,7 +39,7 @@ SECTIONS
*(.gnu.linkonce.t.*) *(.gnu.linkonce.t.*)
} GROUP_LINK_IN(REGION_TEXT) } GROUP_LINK_IN(REGION_TEXT)
_image_text_end = .; __text_region_end = .;
__rodata_region_start = .; __rodata_region_start = .;
#include <linker/common-rom.ld> #include <linker/common-rom.ld>

View file

@ -293,7 +293,7 @@ SECTIONS
#endif #endif
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{ {
_image_text_start = .; __text_region_start = .;
#if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \ #if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \
!defined(CONFIG_LINKER_USE_PINNED_SECTION) !defined(CONFIG_LINKER_USE_PINNED_SECTION)
@ -327,8 +327,8 @@ SECTIONS
MMU_PAGE_ALIGN_PERM MMU_PAGE_ALIGN_PERM
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
_image_text_size = _image_text_end - _image_text_start; __text_region_size = __text_region_end - __text_region_start;
__rodata_region_start = .; __rodata_region_start = .;
#ifndef CONFIG_LINKER_USE_PINNED_SECTION #ifndef CONFIG_LINKER_USE_PINNED_SECTION

View file

@ -89,7 +89,7 @@ SECTIONS
{ {
. = ALIGN(16); . = ALIGN(16);
__rom_region_start = .; __rom_region_start = .;
_image_text_start = .; __text_region_start = .;
z_mapped_start = .; z_mapped_start = .;
*(.text) *(.text)
*(.text.*) *(.text.*)
@ -99,8 +99,8 @@ SECTIONS
MMU_PAGE_ALIGN_PERM MMU_PAGE_ALIGN_PERM
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
_image_text_end = .; __text_region_end = .;
_image_text_size = _image_text_end - _image_text_start; __text_region_size = __text_region_end - __text_region_start;
__rodata_region_start = .; __rodata_region_start = .;
#include <linker/common-rom.ld> #include <linker/common-rom.ld>

View file

@ -247,9 +247,9 @@ extern char _flash_used[];
extern char _image_ram_start[]; extern char _image_ram_start[];
extern char _image_ram_end[]; extern char _image_ram_end[];
extern char _image_text_start[]; extern char __text_region_start[];
extern char _image_text_end[]; extern char __text_region_end[];
extern char _image_text_size[]; extern char __text_region_size[];
extern char __rodata_region_start[]; extern char __rodata_region_start[];
extern char __rodata_region_end[]; extern char __rodata_region_end[];

View file

@ -21,8 +21,8 @@ static const struct arm_mpu_region mpu_regions[] = {
/* Region 1 zephyr text */ /* Region 1 zephyr text */
MPU_REGION_ENTRY("SRAM_0", MPU_REGION_ENTRY("SRAM_0",
(uintptr_t)_image_text_start, (uintptr_t)__text_region_start,
(uintptr_t)_image_text_end, (uintptr_t)__text_region_end,
REGION_RAM_TEXT_ATTR), REGION_RAM_TEXT_ATTR),
/* Region 2 zephyr rodata */ /* Region 2 zephyr rodata */

View file

@ -110,14 +110,14 @@ SECTIONS
*/ */
#include <snippets-rom-start.ld> #include <snippets-rom-start.ld>
_image_text_start = .; __text_region_start = .;
*(.text .text.*) *(.text .text.*)
*(.gnu.linkonce.t.*) *(.gnu.linkonce.t.*)
*(.eh_frame) *(.eh_frame)
} GROUP_LINK_IN(ROM) } GROUP_LINK_IN(ROM)
_image_text_end = .; __text_region_end = .;
__rodata_region_start = .; __rodata_region_start = .;

View file

@ -484,7 +484,7 @@ SECTIONS
_sram_text_end = ABSOLUTE(.); _sram_text_end = ABSOLUTE(.);
} >sram0_seg :sram0_phdr } >sram0_seg :sram0_phdr
_image_text_start = ALIGN(4); __text_region_start = ALIGN(4);
.text : ALIGN(4) .text : ALIGN(4)
{ {
_stext = .; _stext = .;
@ -499,7 +499,7 @@ SECTIONS
_text_end = ABSOLUTE(.); _text_end = ABSOLUTE(.);
_etext = .; _etext = .;
} >sram0_seg :sram0_phdr } >sram0_seg :sram0_phdr
_image_text_end = .; __text_region_end = .;
.sram.data : ALIGN(4) .sram.data : ALIGN(4)
{ {

View file

@ -97,7 +97,7 @@ void test_ram_perms(void)
if (!IS_ENABLED(CONFIG_SRAM_REGION_PERMISSIONS)) { if (!IS_ENABLED(CONFIG_SRAM_REGION_PERMISSIONS)) {
expected = MMU_P | MMU_RW; expected = MMU_P | MMU_RW;
} else if (IN_REGION(_image_text, pos)) { } else if (IN_REGION(__text_region, pos)) {
expected = MMU_P | MMU_US; expected = MMU_P | MMU_US;
} else if (IN_REGION(__rodata_region, pos)) { } else if (IN_REGION(__rodata_region, pos)) {
expected = MMU_P | MMU_US | MMU_XD; expected = MMU_P | MMU_US | MMU_XD;