1/* 2 * Copyright (c) 2017,2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7#ifdef CONFIG_USERSPACE 8 9 /* During LINKER_KOBJECT_PREBUILT and LINKER_ZEPHYR_PREBUILT, 10 * space needs to be reserved for the rodata that will be 11 * produced by gperf during the final stages of linking. 12 * The alignment and size are produced by 13 * scripts/build/gen_kobject_placeholders.py. These are here 14 * so the addresses to kobjects would remain the same 15 * during the final stages of linking (LINKER_ZEPHYR_FINAL). 16 */ 17 18#if defined(LINKER_ZEPHYR_PREBUILT) 19#include <linker-kobject-prebuilt-rodata.h> 20#ifdef KOBJECT_RODATA_ALIGN 21 . = ALIGN(KOBJECT_RODATA_ALIGN); 22 23 _kobject_rodata_area_start = .; 24 25 . = . + KOBJECT_RODATA_SZ; 26 27 _kobject_rodata_area_end = .; 28#endif 29#endif /* LINKER_ZEPHYR_PREBUILT */ 30 31#if defined(LINKER_ZEPHYR_FINAL) 32#include <linker-kobject-prebuilt-rodata.h> 33#ifdef KOBJECT_RODATA_ALIGN 34 . = ALIGN(KOBJECT_RODATA_ALIGN); 35 36 _kobject_rodata_area_start = .; 37#endif 38 39 *(".kobject_data.rodata*") 40 41#ifdef KOBJECT_RODATA_ALIGN 42 _kobject_rodata_area_end = .; 43 _kobject_rodata_area_used = _kobject_rodata_area_end - _kobject_rodata_area_start; 44 45 ASSERT(_kobject_rodata_area_used <= KOBJECT_RODATA_SZ, 46"scripts/build/gen_kobject_placeholders.py did not reserve enough space \ 47for kobject rodata." 48 ); 49 50 /* Padding is needed to preserve kobject addresses 51 * if we have reserved more space than needed. 52 */ 53 . = MAX(., _kobject_rodata_area_start + KOBJECT_RODATA_SZ); 54#endif /* KOBJECT_RODATA_ALIGN */ 55#endif /* LINKER_ZEPHYR_FINAL */ 56 57#endif /* CONFIG_USERSPACE */ 58