We now allow use of -mgpopt=global and -mgpopt=data. The 'global' option is now the default instead of compiler-default local, expanding global pointer usage to all small data in the system. For systems where all RAM is less than 64K, the 'data' option may be appropriate. Some fixes had to be made to the system in order to get around some issues: * prep_c.c no longer uses fake linker variables to figure out the size of data or BSS, as these gave the linker fits as it tried to compute relative addresses to them. * _k_task_ptr_idle is create by sysgen and placed in a special section. Any small data in a special section needs to be declared extern with __attribute__((section)) else the compiler will assume it's in .sdata. * same situation with extern references to k_pipe_t (fixed pipe_priv test) For legacy applications being ported to Nios II which do things that freak out global pointer calculation, it can be disabled entirely. Change-Id: I5eb86ee8aefb8e2fac49c5cdd104ee19cea23f6f Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
156 lines
4.2 KiB
C
156 lines
4.2 KiB
C
/*
|
|
* Copyright (c) 2013-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.
|
|
*/
|
|
|
|
/*
|
|
* DESCRIPTION
|
|
* Platform independent, commonly used macros and defines related to linker
|
|
* script.
|
|
*
|
|
* This file may be included by:
|
|
* - Linker script files: for linker section declarations
|
|
* - C files: for external declaration of address or size of linker section
|
|
* - Assembly files: for external declaration of address or size of linker
|
|
* section
|
|
*/
|
|
|
|
#ifndef _LINKERDEFS_H
|
|
#define _LINKERDEFS_H
|
|
|
|
#include <toolchain.h>
|
|
#include <sections.h>
|
|
|
|
/* include platform dependent linker-defs */
|
|
#ifdef CONFIG_X86
|
|
#include <arch/x86/linker-defs-arch.h>
|
|
#elif defined(CONFIG_ARM)
|
|
/* Nothing yet to include */
|
|
#elif defined(CONFIG_ARC)
|
|
/* Nothing yet to include */
|
|
#elif defined(CONFIG_NIOS2)
|
|
/* Nothing yet to include */
|
|
#else
|
|
#error Arch not supported.
|
|
#endif
|
|
|
|
#ifdef _LINKER
|
|
|
|
|
|
/*
|
|
* Space for storing per device busy bitmap. Since we do not know beforehand
|
|
* the number of devices, we go through the below mechanism to allocate the
|
|
* required space.
|
|
*/
|
|
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
|
#define DEVICE_COUNT ((__device_init_end - __device_init_start) / __DEVICE_STR_SIZEOF)
|
|
#define DEV_BUSY_SZ (((DEVICE_COUNT + 31) / 32) * 4)
|
|
#define DEVICE_BUSY_BITFIELD() \
|
|
FILL(0x00) ; \
|
|
__device_busy_start = .; \
|
|
. = . + DEV_BUSY_SZ; \
|
|
__device_busy_end = .;
|
|
#else
|
|
#define DEVICE_BUSY_BITFIELD()
|
|
#endif
|
|
|
|
/*
|
|
* generate a symbol to mark the start of the device initialization objects for
|
|
* the specified level, then link all of those objects (sorted by priority);
|
|
* ensure the objects aren't discarded if there is no direct reference to them
|
|
*/
|
|
|
|
#define DEVICE_INIT_LEVEL(level) \
|
|
__device_##level##_start = .; \
|
|
KEEP(*(SORT(.init_##level[0-9]))); \
|
|
KEEP(*(SORT(.init_##level[1-9][0-9]))); \
|
|
|
|
/*
|
|
* link in device initialization objects for all devices that are automatically
|
|
* initialized by the kernel; the objects are sorted in the order they will be
|
|
* initialized (i.e. ordered by level, sorted by priority within a level)
|
|
*/
|
|
|
|
#define DEVICE_INIT_SECTIONS() \
|
|
__device_init_start = .; \
|
|
DEVICE_INIT_LEVEL(PRIMARY) \
|
|
DEVICE_INIT_LEVEL(SECONDARY) \
|
|
DEVICE_INIT_LEVEL(NANOKERNEL) \
|
|
DEVICE_INIT_LEVEL(MICROKERNEL) \
|
|
DEVICE_INIT_LEVEL(APPLICATION) \
|
|
__device_init_end = .; \
|
|
DEVICE_BUSY_BITFIELD() \
|
|
|
|
|
|
/* define a section for undefined device initialization levels */
|
|
#define DEVICE_INIT_UNDEFINED_SECTION() \
|
|
KEEP(*(SORT(.init_[_A-Z0-9]*))) \
|
|
|
|
#ifdef CONFIG_X86 /* LINKER FILES: defines used by linker script */
|
|
/* Should be moved to linker-common-defs.h */
|
|
#if defined(CONFIG_XIP)
|
|
#define ROMABLE_REGION ROM
|
|
#else
|
|
#define ROMABLE_REGION RAM
|
|
#endif
|
|
#endif
|
|
|
|
/*
|
|
* If image is loaded via kexec Linux system call, then program
|
|
* headers need to be page aligned.
|
|
* This can be done by section page aligning.
|
|
*/
|
|
#ifdef CONFIG_BOOTLOADER_KEXEC
|
|
#define KEXEC_PGALIGN_PAD(x) . = ALIGN(x);
|
|
#else
|
|
#define KEXEC_PGALIGN_PAD(x)
|
|
#endif
|
|
|
|
#elif defined(_ASMLANGUAGE)
|
|
|
|
/* Assembly FILES: declaration defined by the linker script */
|
|
GDATA(__bss_start)
|
|
GDATA(__bss_num_words)
|
|
#ifdef CONFIG_XIP
|
|
GDATA(__data_rom_start)
|
|
GDATA(__data_ram_start)
|
|
GDATA(__data_num_words)
|
|
#endif
|
|
|
|
#else /* ! _ASMLANGUAGE */
|
|
|
|
#include <stdint.h>
|
|
extern char __bss_start[];
|
|
extern char __bss_end[];
|
|
extern int __bss_num_words[];
|
|
#ifdef CONFIG_XIP
|
|
extern char __data_rom_start[];
|
|
extern char __data_ram_start[];
|
|
extern char __data_ram_end[];
|
|
extern int __data_num_words[];
|
|
#endif
|
|
|
|
extern char _image_rom_start[];
|
|
extern char _image_rom_end[];
|
|
extern char _image_ram_start[];
|
|
extern char _image_ram_end[];
|
|
extern char _image_text_start[];
|
|
extern char _image_text_end[];
|
|
|
|
/* end address of image. */
|
|
extern char _end[];
|
|
|
|
#endif /* ! _ASMLANGUAGE */
|
|
|
|
#endif /* _LINKERDEFS_H */
|