linker-tool-gcc: revise for MMU support
We need to do a few things differently if we are to support a virtual memory map, i.e. CONFIG_MMU where CONFIG_KERNEL_VM_BASE is not the same as CONFIG_SRAM_BASE_ADDRESS. - All sections must be specified with a VMA and LMA, where VMA is the virtual address and LMA is the physical memory location. - All sections must be specified with ALIGN_WITH_INPUT to keep VMAs and LMAs synchronized To do this, the existing linker macros need some adjustment: - GROUP_LINK_IN undefined when CONFIG_KERNEL_VM_BASE is not the same as CONFIG_SRAM_BASE_ADDRESS. - New macro GROUP_ROM_LINK_IN for text/rodata sections - New macro GROUP_NOLOAD_LINK_IN for bss/noinit sections - Implicit ALIGN_WITH_INPUT for all sections GROUP_FOLLOWS_AT is unused anywhere in the kernel for years now and has been removed. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com> Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
a120799b85
commit
acda9bf9ce
12 changed files with 151 additions and 71 deletions
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include <linker/linker-tool.h>
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
#if defined(CONFIG_XIP) || defined(Z_VM_KERNEL)
|
||||
#define ROMABLE_REGION ROM
|
||||
#define RAMABLE_REGION RAM
|
||||
#else
|
||||
|
@ -122,7 +122,7 @@ SECTIONS
|
|||
#include <linker/kobject-text.ld>
|
||||
|
||||
MMU_PAGE_ALIGN_PERM
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
_image_text_end = .;
|
||||
_image_text_size = _image_text_end - _image_text_start;
|
||||
|
@ -161,7 +161,7 @@ SECTIONS
|
|||
#include <snippets-rodata.ld>
|
||||
|
||||
#include <linker/kobject-rom.ld>
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#include <linker/cplusplus-rom.ld>
|
||||
|
||||
|
@ -234,7 +234,7 @@ SECTIONS
|
|||
*/
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
||||
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
__bss_num_words = (__bss_end - __bss_start) >> 2;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ SECTIONS
|
|||
* ... there is no 16-bit code yet, but there will be when we add SMP.
|
||||
*/
|
||||
|
||||
.locore : ALIGN(16)
|
||||
SECTION_PROLOGUE(.locore,,)
|
||||
{
|
||||
_locore_start = .;
|
||||
*(.locore)
|
||||
|
@ -85,8 +85,9 @@ SECTIONS
|
|||
* placed above 1MB to avoid the by memory hole at 0x90000-0xFFFFF).
|
||||
*/
|
||||
|
||||
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(16))
|
||||
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
|
||||
{
|
||||
. = ALIGN(16);
|
||||
_image_rom_start = .;
|
||||
_image_text_start = .;
|
||||
z_mapped_start = .;
|
||||
|
@ -96,7 +97,7 @@ SECTIONS
|
|||
#include <linker/kobject-text.ld>
|
||||
|
||||
MMU_PAGE_ALIGN_PERM
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
_image_text_end = .;
|
||||
_image_text_size = _image_text_end - _image_text_start;
|
||||
|
@ -105,8 +106,9 @@ SECTIONS
|
|||
#include <linker/common-rom.ld>
|
||||
#include <linker/thread-local-storage.ld>
|
||||
|
||||
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(16))
|
||||
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
|
||||
{
|
||||
. = ALIGN(16);
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
|
@ -121,7 +123,7 @@ SECTIONS
|
|||
#endif /* CONFIG_X86_MMU */
|
||||
|
||||
#include <linker/kobject-rom.ld>
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#include <linker/cplusplus-rom.ld>
|
||||
|
||||
|
@ -148,8 +150,9 @@ SECTIONS
|
|||
* be put in BSS section. That causes gcov not work properly */
|
||||
#include <snippets-ram-sections.ld>
|
||||
|
||||
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD), ALIGN(16))
|
||||
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD),)
|
||||
{
|
||||
. = ALIGN(16);
|
||||
MMU_PAGE_ALIGN_PERM
|
||||
#ifndef CONFIG_USERSPACE
|
||||
_image_ram_start = .;
|
||||
|
@ -161,7 +164,7 @@ SECTIONS
|
|||
*(COMMON)
|
||||
. = ALIGN(4); /* so __bss_num_dwords is exact */
|
||||
__bss_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
||||
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
__bss_num_dwords = (__bss_end - __bss_start) >> 2;
|
||||
|
||||
|
@ -169,8 +172,9 @@ SECTIONS
|
|||
|
||||
#include <snippets-sections.ld>
|
||||
|
||||
SECTION_PROLOGUE(_DATA_SECTION_NAME,,ALIGN(16))
|
||||
SECTION_PROLOGUE(_DATA_SECTION_NAME,,)
|
||||
{
|
||||
. = ALIGN(16);
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
#include <snippets-rwdata.ld>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue