build: consolidate some common parts of linker scripts

There are a number of data sections that are repeated across
all the linker scripts for various architecture. In practice these
don't always get updated and we have had problems with bit-rot.
Consolidate these to make maintenance easier.

x86 linker scripts now follow the same naming convention and we
get rid of a linker-epilog.h that wasn't necessary and whose purpose
has been lost to the mists of time. If applications want to define their
own sections they should be allowed to. Linker scripts for x86 do not
end with .h any more, they are not C header files even though we use
C's preprocessor.

Issue: ZEP-688
Change-Id: I893eb4619969695c1f980efd7c2ec9fa5dad136d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-10-20 08:09:32 -07:00
commit 4208976bfc
12 changed files with 139 additions and 512 deletions

View file

@ -51,9 +51,5 @@ MEMORY
IDT_LIST : ORIGIN = 2K, LENGTH = 2K IDT_LIST : ORIGIN = 2K, LENGTH = 2K
} }
#include <arch/x86/linker-common-sections.h> #include <arch/x86/linker.ld>
/* start adding platform specific linker sections here */
/* no sections should appear after linker-epilog.h */
#include <arch/x86/linker-epilog.h>

View file

@ -51,9 +51,5 @@ MEMORY
IDT_LIST : ORIGIN = 2K, LENGTH = 2K IDT_LIST : ORIGIN = 2K, LENGTH = 2K
} }
#include <arch/x86/linker-common-sections.h> #include <arch/x86/linker.ld>
/* start adding platform specific linker sections here */
/* no sections should appear after linker-epilog.h */
#include <arch/x86/linker-epilog.h>

View file

@ -51,9 +51,5 @@ MEMORY
IDT_LIST : ORIGIN = 512, LENGTH = 512 IDT_LIST : ORIGIN = 512, LENGTH = 512
} }
#include <arch/x86/linker-common-sections.h> #include <arch/x86/linker.ld>
/* start adding bsp specific linker sections here */
/* no sections should appear after linker-epilog.h */
#include <arch/x86/linker-epilog.h>

View file

@ -52,9 +52,5 @@ MEMORY
IDT_LIST : ORIGIN = 2K, LENGTH = 2K IDT_LIST : ORIGIN = 2K, LENGTH = 2K
} }
#include <arch/x86/linker-common-sections.h> #include <arch/x86/linker.ld>
/* start adding bsp specific linker sections here */
/* no sections should appear after linker-epilog.h */
#include <arch/x86/linker-epilog.h>

View file

@ -51,9 +51,5 @@ MEMORY
IDT_LIST : ORIGIN = 2K, LENGTH = 2K IDT_LIST : ORIGIN = 2K, LENGTH = 2K
} }
#include <arch/x86/linker-common-sections.h> #include <arch/x86/linker.ld>
/* start adding platform specific linker sections here */
/* no sections should appear after linker-epilog.h */
#include <arch/x86/linker-epilog.h>

View file

@ -111,39 +111,7 @@ SECTIONS {
_image_text_end = .; _image_text_end = .;
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE (devconfig, (OPTIONAL),) #include <linker/common-rom.ld>
{
__devconfig_start = .;
*(".devconfig.*")
KEEP(*(SORT_BY_NAME(".devconfig*")))
__devconfig_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#ifdef CONFIG_CPLUSPLUS
SECTION_PROLOGUE(_CTOR_SECTION_NAME,,) {
/*
* The compiler fills the constructor pointers table below, hence
* symbol __CTOR_LIST__ must be aligned on 4 byte boundary.
* To align with the C++ standard, the first element of the array
* contains the number of actual constructors. The last element is
* NULL.
*/
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(init_array, (OPTIONAL),)
{
. = ALIGN(4);
__init_array_start = .;
KEEP(*(SORT_BY_NAME(".init_array*")))
__init_array_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#endif
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) { SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) {
*(.rodata) *(.rodata)
@ -169,68 +137,7 @@ SECTIONS {
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(initlevel, (OPTIONAL),) #include <linker/common-ram.ld>
{
DEVICE_INIT_SECTIONS()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_task_list, (OPTIONAL),)
{
_k_task_list_start = .;
*(._k_task_list.public.*)
*(._k_task_list.private.*)
_k_task_list_idle_start = .;
*(._k_task_list.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_list*")))
_k_task_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_task_ptr, (OPTIONAL),)
{
_k_task_ptr_start = .;
*(._k_task_ptr.public.*)
*(._k_task_ptr.private.*)
*(._k_task_ptr.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_ptr*")))
_k_task_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_pipe_ptr, (OPTIONAL),)
{
_k_pipe_ptr_start = .;
*(._k_pipe_ptr.public.*)
*(._k_pipe_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_pipe_ptr*")))
_k_pipe_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_mem_map_ptr, (OPTIONAL),)
{
_k_mem_map_ptr_start = .;
*(._k_mem_map_ptr.public.*)
*(._k_mem_map_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_mem_map_ptr*")))
_k_mem_map_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_event_list, (OPTIONAL),)
{
_k_event_list_start = .;
*(._k_event_list.event.*)
KEEP(*(SORT_BY_NAME("._k_event_list*")))
_k_event_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(_k_memory_pool, (OPTIONAL),)
{
*(._k_memory_pool.struct*)
KEEP(*(SORT_BY_NAME("._k_memory_pool.struct*")))
_k_mem_pool_start = .;
*(._k_memory_pool.*)
KEEP(*(SORT_BY_NAME("._k_memory_pool*")))
_k_mem_pool_end = .;
} GROUP_LINK_IN(RAMABLE_REGION)
__data_ram_end = .; __data_ram_end = .;

View file

@ -117,14 +117,6 @@ SECTIONS
_image_text_end = .; _image_text_end = .;
SECTION_PROLOGUE (devconfig, (OPTIONAL),)
{
__devconfig_start = .;
*(".devconfig.*")
KEEP(*(SORT_BY_NAME(".devconfig*")))
__devconfig_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(.ARM.exidx,,) SECTION_PROLOGUE(.ARM.exidx,,)
{ {
/* /*
@ -140,32 +132,7 @@ SECTIONS
__exidx_end = .; __exidx_end = .;
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
#ifdef CONFIG_CPLUSPLUS #include <linker/common-rom.ld>
SECTION_PROLOGUE(_CTOR_SECTION_NAME,,)
{
/*
* The compiler fills the constructor pointers table below, hence symbol
* __CTOR_LIST__ must be aligned on 4 byte boundary.
* To align with the C++ standard, the first elment of the array
* contains the number of actual constructors. The last element is
* NULL.
*/
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(init_array, (OPTIONAL),)
{
. = ALIGN(4);
__init_array_start = .;
KEEP(*(SORT_BY_NAME(".init_array*")))
__init_array_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#endif
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
{ {
@ -202,69 +169,7 @@ SECTIONS
*(".data.*") *(".data.*")
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (initlevel, (OPTIONAL),) #include <linker/common-ram.ld>
{
DEVICE_INIT_SECTIONS()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_task_list, (OPTIONAL),)
{
_k_task_list_start = .;
*(._k_task_list.public.*)
*(._k_task_list.private.*)
_k_task_list_idle_start = .;
*(._k_task_list.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_list*")))
_k_task_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_task_ptr, (OPTIONAL),)
{
_k_task_ptr_start = .;
*(._k_task_ptr.public.*)
*(._k_task_ptr.private.*)
*(._k_task_ptr.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_ptr*")))
_k_task_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_pipe_ptr, (OPTIONAL),)
{
_k_pipe_ptr_start = .;
*(._k_pipe_ptr.public.*)
*(._k_pipe_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_pipe_ptr*")))
_k_pipe_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE (_k_mem_map_ptr, (OPTIONAL),)
{
_k_mem_map_ptr_start = .;
*(._k_mem_map_ptr.public.*)
*(._k_mem_map_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_mem_map_ptr*")))
_k_mem_map_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_event_list, (OPTIONAL),)
{
_k_event_list_start = .;
*(._k_event_list.event.*)
KEEP(*(SORT_BY_NAME("._k_event_list*")))
_k_event_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_memory_pool, (OPTIONAL),)
{
*(._k_memory_pool.struct*)
KEEP(*(SORT_BY_NAME("._k_memory_pool.struct*")))
_k_mem_pool_start = .;
*(._k_memory_pool.*)
KEEP(*(SORT_BY_NAME("._k_memory_pool*")))
_k_mem_pool_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
__data_ram_end = .; __data_ram_end = .;
@ -331,11 +236,4 @@ SECTIONS
} GROUP_LINK_IN(SYSTEM_CONTROL_SPACE) } GROUP_LINK_IN(SYSTEM_CONTROL_SPACE)
GROUP_END(SYSTEM_CONTROL_SPACE) GROUP_END(SYSTEM_CONTROL_SPACE)
/* verify we don't have rogue .init_<something> initlevel sections */
SECTION_PROLOGUE(initlevel_error, (OPTIONAL),)
{
DEVICE_INIT_UNDEFINED_SECTION()
}
ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
} }

View file

@ -120,40 +120,7 @@ SECTIONS
PROVIDE(gp = _gp); PROVIDE(gp = _gp);
#endif #endif
#ifdef CONFIG_CPLUSPLUS #include <linker/common-rom.ld>
SECTION_PROLOGUE(_CTOR_SECTION_NAME, ,)
{
/*
* The compiler fills the constructor pointers table below, hence symbol
* __CTOR_LIST__ must be aligned on 4 byte boundary.
* To align with the C++ standard, the first elment of the array
* contains the number of actual constructors. The last element is
* NULL.
*/
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(init_array, (OPTIONAL),)
{
. = ALIGN(4);
__init_array_start = .;
KEEP(*(SORT_BY_NAME(".init_array*")))
__init_array_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#endif
SECTION_PROLOGUE(devconfig, (OPTIONAL),)
{
__devconfig_start = .;
*(".devconfig.*")
KEEP(*(SORT_BY_NAME(".devconfig*")))
__devconfig_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
{ {
@ -187,71 +154,11 @@ SECTIONS
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif #endif
SECTION_DATA_PROLOGUE(initlevel, (OPTIONAL),)
{
#ifndef CONFIG_XIP #ifndef CONFIG_XIP
_image_ram_start = .; _image_ram_start = .;
#endif #endif
DEVICE_INIT_SECTIONS()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_task_list, (OPTIONAL),) #include <linker/common-ram.ld>
{
_k_task_list_start = .;
*(._k_task_list.public.*)
*(._k_task_list.private.*)
_k_task_list_idle_start = .;
*(._k_task_list.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_list*")))
_k_task_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_task_ptr, (OPTIONAL),)
{
_k_task_ptr_start = .;
*(._k_task_ptr.public.*)
*(._k_task_ptr.private.*)
*(._k_task_ptr.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_ptr*")))
_k_task_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_pipe_ptr, (OPTIONAL),)
{
_k_pipe_ptr_start = .;
*(._k_pipe_ptr.public.*)
*(._k_pipe_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_pipe_ptr*")))
_k_pipe_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_mem_map_ptr, (OPTIONAL),)
{
_k_mem_map_ptr_start = .;
*(._k_mem_map_ptr.public.*)
*(._k_mem_map_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_mem_map_ptr*")))
_k_mem_map_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_event_list, (OPTIONAL),)
{
_k_event_list_start = .;
*(._k_event_list.event.*)
KEEP(*(SORT_BY_NAME("._k_event_list*")))
_k_event_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_memory_pool, (OPTIONAL),)
{
*(._k_memory_pool.struct*)
KEEP(*(SORT_BY_NAME("._k_memory_pool.struct*")))
_k_mem_pool_start = .;
*(._k_memory_pool.*)
KEEP(*(SORT_BY_NAME("._k_memory_pool*")))
_k_mem_pool_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
{ {

View file

@ -1,75 +0,0 @@
/* linker-epilog.h - defines structures that conclude linker script */
/*
* Copyright (c) 2014 Wind River Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LINKER_EPILOG_H
#define _LINKER_EPILOG_H
#include <linker-defs.h>
#ifdef _LINKER
/*
* The following guard prevents usage of orphaned sections --
* the sections that are not explicitly mentioned in the linker script
*/
SECTIONS
{
/* list all debugging sections that needed in resulting ELF */
.shstrtab 0 (OPTIONAL): { *(.shstrtab) }
.symtab 0 (OPTIONAL): { *(.symtab) }
.strtab 0 (OPTIONAL): { *(.strtab) }
.iplt 0 (OPTIONAL): { *(.iplt) }
.igot.plt 0 (OPTIONAL): { *(.igot.plt) }
.rel.plt 0 (OPTIONAL): { *(.rel.plt) }
.rela.plt 0 (OPTIONAL): { *(.rela.plt) }
.rel.dyn 0 (OPTIONAL): { *(".rel.*") }
.rela.dyn 0 (OPTIONAL): { *(".rela.*") }
.comment 0 (OPTIONAL): { *(.comment) }
/* DWARF debugging sections */
/* DWARF 1 */
.debug 0 (OPTIONAL): { *(.debug) }
.line 0 (OPTIONAL): { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 (OPTIONAL): { *(.debug_aranges) }
.debug_pubnames 0 (OPTIONAL): { *(.debug_pubnames) }
.debug_pubtypes 0 (OPTIONAL): { *(.debug_pubtypes) }
/* DWARF 2 */
.debug_line 0 (OPTIONAL): { *(.debug_line) }
.debug_info 0 (OPTIONAL): { *(.debug_info) }
.debug_macinfo 0 (OPTIONAL): { *(.debug_macinfo) }
.debug_abbrev 0 (OPTIONAL): { *(.debug_abbrev) }
.debug_loc 0 (OPTIONAL): { *(.debug_loc) }
.debug_ranges 0 (OPTIONAL): { *(.debug_ranges) }
.debug_str 0 (OPTIONAL): { *(.debug_str) }
.debug_frame 0 (OPTIONAL): { *(.debug_frame) }
.debug_macro 0 (OPTIONAL): { *(.debug_macro) }
/* generate a linker error if orphan section is used */
.trashcan :
{
*(.*)
}
}
ASSERT(SIZEOF(.trashcan) == 0, "Section(s) undefined in the linker script used.")
#endif /* _LINKER */
#endif /* _LINKER_EPILOG_H */

View file

@ -25,19 +25,19 @@
* features are enabled by the kernel's configuration options. * features are enabled by the kernel's configuration options.
* *
* For a build that does not use the execute in place (XIP) feature, the script * For a build that does not use the execute in place (XIP) feature, the script
* generates an image suitable for loading into and executing from RAM by * generates an image suitable for loading into and executing from RAMABLE_REGION by
* placing all the sections adjacent to each other. There is also no separate * placing all the sections adjacent to each other. There is also no separate
* load address for the DATA section which means it doesn't have to be copied * load address for the DATA section which means it doesn't have to be copied
* into RAM. * into RAMABLE_REGION.
* *
* For builds using XIP, there is a different load memory address (LMA) and * For builds using XIP, there is a different load memory address (LMA) and
* virtual memory address (VMA) for the DATA section. In this case the DATA * virtual memory address (VMA) for the DATA section. In this case the DATA
* section is copied into RAM at runtime. * section is copied into RAMABLE_REGION at runtime.
* *
* When building an XIP image the data section is placed into ROM. In this * When building an XIP image the data section is placed into ROMABLE_REGION. In this
* case, the LMA is set to __data_rom_start so the data section is concatenated * case, the LMA is set to __data_rom_start so the data section is concatenated
* at the end of the RODATA section. At runtime, the DATA section is copied * at the end of the RODATA section. At runtime, the DATA section is copied
* into the RAM region so it can be accessed with read and write permission. * into the RAMABLE_REGION region so it can be accessed with read and write permission.
* *
* Most symbols defined in the sections below are subject to be referenced in * Most symbols defined in the sections below are subject to be referenced in
* the Zephyr Kernel image. If a symbol is used but not defined the linker will * the Zephyr Kernel image. If a symbol is used but not defined the linker will
@ -57,6 +57,14 @@
#include <linker-tool.h> #include <linker-tool.h>
#ifdef CONFIG_XIP
#define ROMABLE_REGION ROM
#define RAMABLE_REGION RAM
#else
#define ROMABLE_REGION RAM
#define RAMABLE_REGION RAM
#endif
/* SECTIONS definitions */ /* SECTIONS definitions */
SECTIONS SECTIONS
{ {
@ -83,40 +91,7 @@ SECTIONS
_image_text_end = .; _image_text_end = .;
#ifdef CONFIG_CPLUSPLUS #include <linker/common-rom.ld>
SECTION_PROLOGUE(_CTOR_SECTION_NAME, ,)
{
/*
* The compiler fills the constructor pointers table below, hence symbol
* __CTOR_LIST__ must be aligned on 4 byte boundary.
* To align with the C++ standard, the first elment of the array
* contains the number of actual constructors. The last element is
* NULL.
*/
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(init_array, (OPTIONAL),)
{
. = ALIGN(4);
__init_array_start = .;
KEEP(*(SORT_BY_NAME(".init_array*")))
__init_array_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#endif
SECTION_PROLOGUE(devconfig, (OPTIONAL),)
{
__devconfig_start = .;
*(".devconfig.*")
KEEP(*(SORT_BY_NAME(".devconfig*")))
__devconfig_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(_RODATA_SECTION_NAME, (OPTIONAL),) SECTION_PROLOGUE(_RODATA_SECTION_NAME, (OPTIONAL),)
{ {
@ -138,12 +113,12 @@ SECTIONS
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
_image_rom_end = .; _image_rom_end = .;
__data_rom_start = ALIGN(4); /* XIP imaged DATA ROM start addr */ __data_rom_start = ALIGN(4); /* XIP imaged DATA ROMABLE_REGION start addr */
GROUP_END(ROMABLE_REGION) GROUP_END(ROMABLE_REGION)
/* RAM */ /* RAMABLE_REGION */
GROUP_START(RAM) GROUP_START(RAMABLE_REGION)
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME, (OPTIONAL),) SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME, (OPTIONAL),)
{ {
@ -155,71 +130,9 @@ SECTIONS
*(.data) *(.data)
*(".data.*") *(".data.*")
. = ALIGN(4); . = ALIGN(4);
} GROUP_DATA_LINK_IN(RAM, ROM) } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(initlevel, (OPTIONAL),) #include <linker/common-ram.ld>
{
DEVICE_INIT_SECTIONS()
KEXEC_PGALIGN_PAD(MMU_PAGE_SIZE)
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_task_list, (OPTIONAL),)
{
_k_task_list_start = .;
*(._k_task_list.public.*)
*(._k_task_list.private.*)
_k_task_list_idle_start = .;
*(._k_task_list.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_list*")))
_k_task_list_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_task_ptr, (OPTIONAL),)
{
_k_task_ptr_start = .;
*(._k_task_ptr.public.*)
*(._k_task_ptr.private.*)
*(._k_task_ptr.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_ptr*")))
_k_task_ptr_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_pipe_ptr, (OPTIONAL),)
{
_k_pipe_ptr_start = .;
*(._k_pipe_ptr.public.*)
*(._k_pipe_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_pipe_ptr*")))
_k_pipe_ptr_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_mem_map_ptr, (OPTIONAL),)
{
_k_mem_map_ptr_start = .;
*(._k_mem_map_ptr.public.*)
*(._k_mem_map_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_mem_map_ptr*")))
_k_mem_map_ptr_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_event_list, (OPTIONAL),)
{
_k_event_list_start = .;
*(._k_event_list.event.*)
KEEP(*(SORT_BY_NAME("._k_event_list*")))
_k_event_list_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
SECTION_DATA_PROLOGUE(_k_memory_pool, (OPTIONAL),)
{
*(._k_memory_pool.struct*)
KEEP(*(SORT_BY_NAME("._k_memory_pool.struct*")))
_k_mem_pool_start = .;
*(._k_memory_pool.*)
KEEP(*(SORT_BY_NAME("._k_memory_pool*")))
_k_mem_pool_end = .;
} GROUP_DATA_LINK_IN(RAM, ROM)
__data_ram_end = .; __data_ram_end = .;
@ -244,14 +157,14 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
__bss_end = .; __bss_end = .;
KEXEC_PGALIGN_PAD(MMU_PAGE_SIZE) KEXEC_PGALIGN_PAD(MMU_PAGE_SIZE)
} GROUP_LINK_IN(RAM) } GROUP_LINK_IN(RAMABLE_REGION)
#ifdef CONFIG_XIP #ifdef CONFIG_XIP
/* /*
* Ensure linker keeps sections in correct order, despite the fact * Ensure linker keeps sections in correct order, despite the fact
* the previous section specified a load address and this no-load * the previous section specified a load address and this no-load
* section doesn't. * section doesn't.
*/ */
GROUP_FOLLOWS_AT(RAM) GROUP_FOLLOWS_AT(RAMABLE_REGION)
#endif #endif
SECTION_PROLOGUE(_NOINIT_SECTION_NAME, (NOLOAD OPTIONAL),) SECTION_PROLOGUE(_NOINIT_SECTION_NAME, (NOLOAD OPTIONAL),)
@ -265,7 +178,7 @@ SECTIONS
*(.bottom_of_image_ram) *(.bottom_of_image_ram)
*(.bottom_of_image_ram.*) *(.bottom_of_image_ram.*)
} GROUP_LINK_IN(RAM) } GROUP_LINK_IN(RAMABLE_REGION)
/* Define linker symbols */ /* Define linker symbols */
_image_ram_end = .; _image_ram_end = .;
@ -275,7 +188,7 @@ SECTIONS
__bss_num_words = (__bss_end - __bss_start) >> 2; __bss_num_words = (__bss_end - __bss_start) >> 2;
GROUP_END(RAM) GROUP_END(RAMABLE_REGION)
/* static interrupts */ /* static interrupts */
SECTION_PROLOGUE(intList, (OPTIONAL),) SECTION_PROLOGUE(intList, (OPTIONAL),)
@ -288,14 +201,6 @@ SECTIONS
KEEP(*(.gnu.linkonce.intList.*)) KEEP(*(.gnu.linkonce.intList.*))
__INT_LIST_END__ = .; __INT_LIST_END__ = .;
} > IDT_LIST } > IDT_LIST
/* verify we don't have rogue .init_<something> initlevel sections */
SECTION_PROLOGUE(initlevel_error, (OPTIONAL), )
{
DEVICE_INIT_UNDEFINED_SECTION()
}
ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
} }
#ifdef CONFIG_XIP #ifdef CONFIG_XIP

View file

@ -0,0 +1,70 @@
SECTION_DATA_PROLOGUE(initlevel, (OPTIONAL),)
{
DEVICE_INIT_SECTIONS()
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
/* verify we don't have rogue .init_<something> initlevel sections */
SECTION_DATA_PROLOGUE(initlevel_error, (OPTIONAL), )
{
DEVICE_INIT_UNDEFINED_SECTION()
}
ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
SECTION_DATA_PROLOGUE(_k_task_list, (OPTIONAL),)
{
_k_task_list_start = .;
*(._k_task_list.public.*)
*(._k_task_list.private.*)
_k_task_list_idle_start = .;
*(._k_task_list.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_list*")))
_k_task_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_task_ptr, (OPTIONAL),)
{
_k_task_ptr_start = .;
*(._k_task_ptr.public.*)
*(._k_task_ptr.private.*)
*(._k_task_ptr.idle.*)
KEEP(*(SORT_BY_NAME("._k_task_ptr*")))
_k_task_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_pipe_ptr, (OPTIONAL),)
{
_k_pipe_ptr_start = .;
*(._k_pipe_ptr.public.*)
*(._k_pipe_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_pipe_ptr*")))
_k_pipe_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_mem_map_ptr, (OPTIONAL),)
{
_k_mem_map_ptr_start = .;
*(._k_mem_map_ptr.public.*)
*(._k_mem_map_ptr.private.*)
KEEP(*(SORT_BY_NAME("._k_mem_map_ptr*")))
_k_mem_map_ptr_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_event_list, (OPTIONAL),)
{
_k_event_list_start = .;
*(._k_event_list.event.*)
KEEP(*(SORT_BY_NAME("._k_event_list*")))
_k_event_list_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_k_memory_pool, (OPTIONAL),)
{
*(._k_memory_pool.struct*)
KEEP(*(SORT_BY_NAME("._k_memory_pool.struct*")))
_k_mem_pool_start = .;
*(._k_memory_pool.*)
KEEP(*(SORT_BY_NAME("._k_memory_pool*")))
_k_mem_pool_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

View file

@ -0,0 +1,35 @@
#ifdef CONFIG_CPLUSPLUS
SECTION_PROLOGUE(_CTOR_SECTION_NAME,,)
{
/*
* The compiler fills the constructor pointers table below,
* hence symbol __CTOR_LIST__ must be aligned on 4 byte
* boundary. To align with the C++ standard, the first elment
* of the array contains the number of actual constructors. The
* last element is NULL.
*/
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_PROLOGUE(init_array, (OPTIONAL),)
{
. = ALIGN(4);
__init_array_start = .;
KEEP(*(SORT_BY_NAME(".init_array*")))
__init_array_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#endif
SECTION_PROLOGUE (devconfig, (OPTIONAL),)
{
__devconfig_start = .;
*(".devconfig.*")
KEEP(*(SORT_BY_NAME(".devconfig*")))
__devconfig_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)