| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Linker script macros to generate Image header fields. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2014 ARM Ltd. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 6 | */ |
|---|
| 18 | | -#ifndef __ASM_IMAGE_H |
|---|
| 19 | | -#define __ASM_IMAGE_H |
|---|
| 7 | +#ifndef __ARM64_KERNEL_IMAGE_H |
|---|
| 8 | +#define __ARM64_KERNEL_IMAGE_H |
|---|
| 20 | 9 | |
|---|
| 21 | 10 | #ifndef LINKER_SCRIPT |
|---|
| 22 | 11 | #error This file should only be included in vmlinux.lds.S |
|---|
| 23 | 12 | #endif |
|---|
| 13 | + |
|---|
| 14 | +#include <asm/image.h> |
|---|
| 24 | 15 | |
|---|
| 25 | 16 | /* |
|---|
| 26 | 17 | * There aren't any ELF relocations we can use to endian-swap values known only |
|---|
| .. | .. |
|---|
| 47 | 38 | sym##_lo32 = DATA_LE32((data) & 0xffffffff); \ |
|---|
| 48 | 39 | sym##_hi32 = DATA_LE32((data) >> 32) |
|---|
| 49 | 40 | |
|---|
| 41 | +#define __HEAD_FLAG(field) (__HEAD_FLAG_##field << \ |
|---|
| 42 | + ARM64_IMAGE_FLAG_##field##_SHIFT) |
|---|
| 43 | + |
|---|
| 50 | 44 | #ifdef CONFIG_CPU_BIG_ENDIAN |
|---|
| 51 | | -#define __HEAD_FLAG_BE 1 |
|---|
| 45 | +#define __HEAD_FLAG_BE ARM64_IMAGE_FLAG_BE |
|---|
| 52 | 46 | #else |
|---|
| 53 | | -#define __HEAD_FLAG_BE 0 |
|---|
| 47 | +#define __HEAD_FLAG_BE ARM64_IMAGE_FLAG_LE |
|---|
| 54 | 48 | #endif |
|---|
| 55 | 49 | |
|---|
| 56 | 50 | #define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2) |
|---|
| 57 | 51 | |
|---|
| 58 | 52 | #define __HEAD_FLAG_PHYS_BASE 1 |
|---|
| 59 | 53 | |
|---|
| 60 | | -#define __HEAD_FLAGS ((__HEAD_FLAG_BE << 0) | \ |
|---|
| 61 | | - (__HEAD_FLAG_PAGE_SIZE << 1) | \ |
|---|
| 62 | | - (__HEAD_FLAG_PHYS_BASE << 3)) |
|---|
| 54 | +#define __HEAD_FLAGS (__HEAD_FLAG(BE) | \ |
|---|
| 55 | + __HEAD_FLAG(PAGE_SIZE) | \ |
|---|
| 56 | + __HEAD_FLAG(PHYS_BASE)) |
|---|
| 63 | 57 | |
|---|
| 64 | 58 | /* |
|---|
| 65 | 59 | * These will output as part of the Image header, which should be little-endian |
|---|
| .. | .. |
|---|
| 68 | 62 | */ |
|---|
| 69 | 63 | #define HEAD_SYMBOLS \ |
|---|
| 70 | 64 | DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text); \ |
|---|
| 71 | | - DEFINE_IMAGE_LE64(_kernel_offset_le, TEXT_OFFSET); \ |
|---|
| 72 | 65 | DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS); |
|---|
| 73 | 66 | |
|---|
| 74 | | -#ifdef CONFIG_EFI |
|---|
| 75 | | - |
|---|
| 76 | | -/* |
|---|
| 77 | | - * Use ABSOLUTE() to avoid ld.lld treating this as a relative symbol: |
|---|
| 78 | | - * https://github.com/ClangBuiltLinux/linux/issues/561 |
|---|
| 79 | | - */ |
|---|
| 80 | | -__efistub_stext_offset = ABSOLUTE(stext - _text); |
|---|
| 81 | | - |
|---|
| 82 | | -/* |
|---|
| 83 | | - * The EFI stub has its own symbol namespace prefixed by __efistub_, to |
|---|
| 84 | | - * isolate it from the kernel proper. The following symbols are legally |
|---|
| 85 | | - * accessed by the stub, so provide some aliases to make them accessible. |
|---|
| 86 | | - * Only include data symbols here, or text symbols of functions that are |
|---|
| 87 | | - * guaranteed to be safe when executed at another offset than they were |
|---|
| 88 | | - * linked at. The routines below are all implemented in assembler in a |
|---|
| 89 | | - * position independent manner |
|---|
| 90 | | - */ |
|---|
| 91 | | -__efistub_memcmp = __pi_memcmp; |
|---|
| 92 | | -__efistub_memchr = __pi_memchr; |
|---|
| 93 | | -__efistub_memcpy = __pi_memcpy; |
|---|
| 94 | | -__efistub_memmove = __pi_memmove; |
|---|
| 95 | | -__efistub_memset = __pi_memset; |
|---|
| 96 | | -__efistub_strlen = __pi_strlen; |
|---|
| 97 | | -__efistub_strnlen = __pi_strnlen; |
|---|
| 98 | | -__efistub_strcmp = __pi_strcmp; |
|---|
| 99 | | -__efistub_strncmp = __pi_strncmp; |
|---|
| 100 | | -__efistub_strrchr = __pi_strrchr; |
|---|
| 101 | | -__efistub___flush_dcache_area = __pi___flush_dcache_area; |
|---|
| 102 | | - |
|---|
| 103 | | -#ifdef CONFIG_KASAN |
|---|
| 104 | | -__efistub___memcpy = __pi_memcpy; |
|---|
| 105 | | -__efistub___memmove = __pi_memmove; |
|---|
| 106 | | -__efistub___memset = __pi_memset; |
|---|
| 107 | | -#endif |
|---|
| 108 | | - |
|---|
| 109 | | -__efistub__text = _text; |
|---|
| 110 | | -__efistub__end = _end; |
|---|
| 111 | | -__efistub__edata = _edata; |
|---|
| 112 | | -__efistub_screen_info = screen_info; |
|---|
| 113 | | - |
|---|
| 114 | | -#endif |
|---|
| 115 | | - |
|---|
| 116 | | -#endif /* __ASM_IMAGE_H */ |
|---|
| 67 | +#endif /* __ARM64_KERNEL_IMAGE_H */ |
|---|