Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 1 | /* |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <ivy_def.h> |
| 8 | #include <platform_def.h> |
| 9 | #include <xlat_tables_defs.h> |
| 10 | |
| 11 | OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) |
| 12 | OUTPUT_ARCH(PLATFORM_LINKER_ARCH) |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 13 | |
| 14 | #if IVY_SHIM == 1 |
Ruari Phipps | 1925b2a | 2020-09-10 14:05:55 +0100 | [diff] [blame] | 15 | ENTRY(shim_entrypoint) |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 16 | #else |
| 17 | ENTRY(ivy_entrypoint) |
| 18 | #endif |
| 19 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 20 | |
| 21 | SECTIONS |
| 22 | { |
| 23 | . = IVY_IMAGE_BASE; |
| 24 | |
| 25 | ASSERT(. == ALIGN(PAGE_SIZE), |
| 26 | "TEXT_START address is not aligned to PAGE_SIZE.") |
| 27 | |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 28 | #if IVY_SHIM == 1 |
Ruari Phipps | 1925b2a | 2020-09-10 14:05:55 +0100 | [diff] [blame] | 29 | |
| 30 | .shim_text : { |
| 31 | __SHIM_TEXT_START__ = .; |
| 32 | *spm_shim_entrypoint.o(.text*) |
| 33 | *(.vectors) |
| 34 | . = NEXT(PAGE_SIZE); |
| 35 | __SHIM_TEXT_END__ = .; |
| 36 | } |
| 37 | |
| 38 | .shim_rodata : { |
| 39 | . = ALIGN(PAGE_SIZE); |
| 40 | __SHIM_RODATA_START__ = .; |
| 41 | |
| 42 | . = NEXT(PAGE_SIZE); |
| 43 | __SHIM_RODATA_END__ = .; |
| 44 | } |
| 45 | |
| 46 | .shim_data : { |
| 47 | . = ALIGN(PAGE_SIZE); |
| 48 | __SHIM_DATA_START__ = .; |
| 49 | |
| 50 | . = NEXT(PAGE_SIZE); |
| 51 | __SHIM_DATA_END__ = .; |
| 52 | } |
| 53 | |
| 54 | .shim_bss (NOLOAD) : { |
| 55 | . = ALIGN(PAGE_SIZE); |
| 56 | __SHIM_BSS_START__ = .; |
| 57 | |
| 58 | *(.bss.shim_stacks) |
| 59 | *(.bss.tf_base_xlat_table) |
| 60 | *(.bss.tf_mmap) |
| 61 | *xlat_tables_context.o(COMMON) |
| 62 | *xlat_tables_context.o(xlat_table) |
| 63 | |
| 64 | . = NEXT(PAGE_SIZE); |
| 65 | __SHIM_BSS_END__ = .; |
| 66 | } |
| 67 | |
Olivier Deprez | 6baf5b8 | 2021-05-14 19:04:40 +0200 | [diff] [blame] | 68 | #endif |
Ruari Phipps | 1925b2a | 2020-09-10 14:05:55 +0100 | [diff] [blame] | 69 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 70 | .text : { |
| 71 | __TEXT_START__ = .; |
| 72 | *ivy_entrypoint.o(.text*) |
| 73 | *(.text*) |
| 74 | *(.vectors) |
| 75 | . = NEXT(PAGE_SIZE); |
| 76 | __TEXT_END__ = .; |
| 77 | } |
| 78 | |
| 79 | .rodata : { |
| 80 | . = ALIGN(PAGE_SIZE); |
| 81 | __RODATA_START__ = .; |
| 82 | *(.rodata*) |
Ruari Phipps | 1925b2a | 2020-09-10 14:05:55 +0100 | [diff] [blame] | 83 | |
Ruari Phipps | 9f1952c | 2020-08-24 11:32:32 +0100 | [diff] [blame] | 84 | /* |
| 85 | * Keep the .got section in the RO section as it is patched |
| 86 | * prior to enabling the MMU, so having it in RO is better for |
| 87 | * security. GOT is a table of addresses so ensure 8-byte alignment. |
| 88 | */ |
| 89 | . = ALIGN(8); |
| 90 | __GOT_START__ = .; |
| 91 | *(.got) |
| 92 | __GOT_END__ = .; |
| 93 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 94 | . = NEXT(PAGE_SIZE); |
| 95 | __RODATA_END__ = .; |
| 96 | } |
| 97 | |
| 98 | .data : { |
| 99 | . = ALIGN(PAGE_SIZE); |
| 100 | __DATA_START__ = .; |
| 101 | *(.data*) |
| 102 | . = NEXT(PAGE_SIZE); |
| 103 | __DATA_END__ = .; |
| 104 | } |
| 105 | |
Ruari Phipps | 9f1952c | 2020-08-24 11:32:32 +0100 | [diff] [blame] | 106 | /* |
| 107 | * .rela.dyn needs to come after .data for the read-elf utility |
| 108 | * to parse this section correctly. Ensure 8-byte alignment so |
| 109 | * that the fields of RELA data structure are aligned. |
| 110 | */ |
| 111 | . = ALIGN(8); |
| 112 | __RELA_START__ = .; |
| 113 | .rela.dyn . : { |
| 114 | } |
| 115 | __RELA_END__ = .; |
| 116 | |
| 117 | |
Antonio Nino Diaz | 0b1ab40 | 2018-12-05 15:38:39 +0000 | [diff] [blame] | 118 | .bss (NOLOAD) : { |
| 119 | . = ALIGN(PAGE_SIZE); |
| 120 | __BSS_START__ = .; |
| 121 | *(SORT_BY_ALIGNMENT(.bss*)) |
| 122 | *(COMMON) |
| 123 | . = NEXT(PAGE_SIZE); |
| 124 | __BSS_END__ = .; |
| 125 | } |
| 126 | } |