mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
cb7d2dd561
Linux kernel Image can appear as an EFI application With appropriate PE/COFF header fields in the beginning of the Image header. An EFI application loader can directly load a Linux kernel Image and an EFI stub residing in kernel can boot Linux kernel directly. Add the necessary PE/COFF header. Signed-off-by: Atish Patra <atish.patra@wdc.com> Link: https://lore.kernel.org/r/20200421033336.9663-3-atish.patra@wdc.com [ardb: - use C prefix for c.li to ensure the expected opcode is emitted - align all image sections according to PE/COFF section alignment ] Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
122 lines
2.1 KiB
ArmAsm
122 lines
2.1 KiB
ArmAsm
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
* Copyright (C) 2017 SiFive
|
|
*/
|
|
|
|
#define LOAD_OFFSET PAGE_OFFSET
|
|
#include <asm/vmlinux.lds.h>
|
|
#include <asm/page.h>
|
|
#include <asm/cache.h>
|
|
#include <asm/thread_info.h>
|
|
#include <asm/set_memory.h>
|
|
#include "image-vars.h"
|
|
|
|
#include <linux/sizes.h>
|
|
OUTPUT_ARCH(riscv)
|
|
ENTRY(_start)
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
PECOFF_SECTION_ALIGNMENT = 0x1000;
|
|
PECOFF_FILE_ALIGNMENT = 0x200;
|
|
|
|
SECTIONS
|
|
{
|
|
/* Beginning of code and text segment */
|
|
. = LOAD_OFFSET;
|
|
_start = .;
|
|
_stext = .;
|
|
HEAD_TEXT_SECTION
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__init_begin = .;
|
|
INIT_TEXT_SECTION(PAGE_SIZE)
|
|
INIT_DATA_SECTION(16)
|
|
. = ALIGN(8);
|
|
__soc_early_init_table : {
|
|
__soc_early_init_table_start = .;
|
|
KEEP(*(__soc_early_init_table))
|
|
__soc_early_init_table_end = .;
|
|
}
|
|
__soc_builtin_dtb_table : {
|
|
__soc_builtin_dtb_table_start = .;
|
|
KEEP(*(__soc_builtin_dtb_table))
|
|
__soc_builtin_dtb_table_end = .;
|
|
}
|
|
/* we have to discard exit text and such at runtime, not link time */
|
|
.exit.text :
|
|
{
|
|
EXIT_TEXT
|
|
}
|
|
.exit.data :
|
|
{
|
|
EXIT_DATA
|
|
}
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
|
__init_end = .;
|
|
|
|
. = ALIGN(SECTION_ALIGN);
|
|
.text : {
|
|
_text = .;
|
|
TEXT_TEXT
|
|
SCHED_TEXT
|
|
CPUIDLE_TEXT
|
|
LOCK_TEXT
|
|
KPROBES_TEXT
|
|
ENTRY_TEXT
|
|
IRQENTRY_TEXT
|
|
SOFTIRQENTRY_TEXT
|
|
*(.fixup)
|
|
_etext = .;
|
|
}
|
|
|
|
#ifdef CONFIG_EFI
|
|
. = ALIGN(PECOFF_SECTION_ALIGNMENT);
|
|
__pecoff_text_end = .;
|
|
#endif
|
|
|
|
/* Start of data section */
|
|
_sdata = .;
|
|
RO_DATA(SECTION_ALIGN)
|
|
.srodata : {
|
|
*(.srodata*)
|
|
}
|
|
|
|
EXCEPTION_TABLE(0x10)
|
|
|
|
. = ALIGN(SECTION_ALIGN);
|
|
_data = .;
|
|
|
|
RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
|
|
.sdata : {
|
|
__global_pointer$ = . + 0x800;
|
|
*(.sdata*)
|
|
}
|
|
|
|
#ifdef CONFIG_EFI
|
|
.pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
|
|
__pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
|
|
#endif
|
|
|
|
/* End of data section */
|
|
_edata = .;
|
|
|
|
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
|
|
|
|
.rel.dyn : {
|
|
*(.rel.dyn*)
|
|
}
|
|
|
|
#ifdef CONFIG_EFI
|
|
. = ALIGN(PECOFF_SECTION_ALIGNMENT);
|
|
__pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
|
|
#endif
|
|
_end = .;
|
|
|
|
STABS_DEBUG
|
|
DWARF_DEBUG
|
|
|
|
DISCARDS
|
|
}
|