diff --git a/cmake-tool/helpers/tls_rootserver.lds b/cmake-tool/helpers/tls_rootserver.lds index 998e9d8f..b65329b0 100644 --- a/cmake-tool/helpers/tls_rootserver.lds +++ b/cmake-tool/helpers/tls_rootserver.lds @@ -12,7 +12,7 @@ SECTIONS *(.tdata .tdata.* .gnu.linkonce.td.*) _tdata_end = . ; } - .tbss : + .tbss (NOLOAD): { _tbss_start = . ; *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) diff --git a/elfloader-tool/CMakeLists.txt b/elfloader-tool/CMakeLists.txt index 2a4d7884..9a49f10d 100644 --- a/elfloader-tool/CMakeLists.txt +++ b/elfloader-tool/CMakeLists.txt @@ -106,7 +106,7 @@ config_option( add_config_library(elfloader "${configure_string}") add_compile_options(-D_XOPEN_SOURCE=700 -ffreestanding -Wall -Werror -W -Wextra) -set(linkerScript "${CMAKE_CURRENT_LIST_DIR}/src/arch-${KernelArch}/linker.lds") +set(linkerScript "${CMAKE_CURRENT_LIST_DIR}/src/linker.lds") if(KernelArchRiscV) add_compile_options(-mcmodel=medany) endif() diff --git a/elfloader-tool/include/drivers/common.h b/elfloader-tool/include/drivers/common.h index 75a483bd..32fec686 100644 --- a/elfloader-tool/include/drivers/common.h +++ b/elfloader-tool/include/drivers/common.h @@ -41,6 +41,12 @@ struct elfloader_driver { extern struct elfloader_driver *__start__driver_list[]; extern struct elfloader_driver *__stop__driver_list[]; +#if defined(__has_attribute) && __has_attribute(retain) +#define ELFLOADER_DRIVER(_name) \ + const struct elfloader_driver *_driver_list_##_name \ + __attribute__((unused,retain,section("_driver_list"))) = &_name; +#else #define ELFLOADER_DRIVER(_name) \ const struct elfloader_driver *_driver_list_##_name \ __attribute__((unused,section("_driver_list"))) = &_name; +#endif diff --git a/elfloader-tool/src/arch-arm/linker.lds b/elfloader-tool/src/arch-arm/linker.lds deleted file mode 100644 index 268b8718..00000000 --- a/elfloader-tool/src/arch-arm/linker.lds +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) - * - * SPDX-License-Identifier: GPL-2.0-only - */ - -#include -#include - -#include "image_start_addr.h" - -SECTIONS -{ - .interp : { *(.interp) } -} -INSERT BEFORE .hash; - -SECTIONS -{ - . = IMAGE_START_ADDR; - _text = .; - .start : - { - *(.text.start) - } -} -INSERT BEFORE .text; - -SECTIONS -{ - .bss : { - . = ALIGN(0x1000); - core_stack_alloc = .; - . = . + CONFIG_MAX_NUM_NODES * 1 << 12; - core_stack_alloc_end = .; - _bss = .; - *(.bss) - _bss_end = .; - } -} - -SECTIONS -{ - . = ALIGN(8); - ._archive_cpio : { - _archive_start = .; - *(._archive_cpio) - _archive_end = .; - } -} -INSERT AFTER .eh_frame; diff --git a/elfloader-tool/src/arch-riscv/linker.lds b/elfloader-tool/src/linker.lds similarity index 89% rename from elfloader-tool/src/arch-riscv/linker.lds rename to elfloader-tool/src/linker.lds index 2076b71a..c6d9338e 100644 --- a/elfloader-tool/src/arch-riscv/linker.lds +++ b/elfloader-tool/src/linker.lds @@ -55,8 +55,14 @@ SECTIONS *(.data.*) } . = ALIGN(16); - .bss : + .bss (NOLOAD) : { +#ifdef CONFIG_ARCH_ARM + . = ALIGN(0x1000); + core_stack_alloc = .; + . += CONFIG_MAX_NUM_NODES * (1 << 12); + core_stack_alloc_end = .; +#endif _bss = .; *(.sbss*) *(.bss)