mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
riscv: provide a flat image loader
This allows just loading the kernel at a pre-set address without qemu going bonkers trying to map the ELF file. Contains a contribution from Aurabindo Jayamohanan to reuse the PAGE_OFFSET definition. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Anup Patel <anup@brainfault.org> [paul.walmsley@sifive.com: fixed checkpatch issue; minor commit message fix] Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
This commit is contained in:
parent
6bd33e1ece
commit
405fe7aa0d
@ -83,13 +83,18 @@ PHONY += vdso_install
|
|||||||
vdso_install:
|
vdso_install:
|
||||||
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
|
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
|
||||||
|
|
||||||
all: Image.gz
|
ifeq ($(CONFIG_RISCV_M_MODE),y)
|
||||||
|
KBUILD_IMAGE := $(boot)/loader
|
||||||
|
else
|
||||||
|
KBUILD_IMAGE := $(boot)/Image.gz
|
||||||
|
endif
|
||||||
|
BOOT_TARGETS := Image Image.gz loader
|
||||||
|
|
||||||
Image: vmlinux
|
all: $(notdir $(KBUILD_IMAGE))
|
||||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
|
||||||
|
|
||||||
Image.%: Image
|
$(BOOT_TARGETS): vmlinux
|
||||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||||
|
@$(kecho) ' Kernel: $(boot)/$@ is ready'
|
||||||
|
|
||||||
zinstall install:
|
zinstall install:
|
||||||
$(Q)$(MAKE) $(build)=$(boot) $@
|
$(Q)$(MAKE) $(build)=$(boot) $@
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
|
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
|
||||||
|
|
||||||
targets := Image
|
targets := Image loader
|
||||||
|
|
||||||
$(obj)/Image: vmlinux FORCE
|
$(obj)/Image: vmlinux FORCE
|
||||||
$(call if_changed,objcopy)
|
$(call if_changed,objcopy)
|
||||||
@ -24,6 +24,11 @@ $(obj)/Image: vmlinux FORCE
|
|||||||
$(obj)/Image.gz: $(obj)/Image FORCE
|
$(obj)/Image.gz: $(obj)/Image FORCE
|
||||||
$(call if_changed,gzip)
|
$(call if_changed,gzip)
|
||||||
|
|
||||||
|
loader.o: $(src)/loader.S $(obj)/Image
|
||||||
|
|
||||||
|
$(obj)/loader: $(obj)/loader.o $(obj)/Image $(obj)/loader.lds FORCE
|
||||||
|
$(Q)$(LD) -T $(obj)/loader.lds -o $@ $(obj)/loader.o
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
|
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
|
||||||
$(obj)/Image System.map "$(INSTALL_PATH)"
|
$(obj)/Image System.map "$(INSTALL_PATH)"
|
||||||
|
8
arch/riscv/boot/loader.S
Normal file
8
arch/riscv/boot/loader.S
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
|
||||||
|
.align 4
|
||||||
|
.section .payload, "ax", %progbits
|
||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
.incbin "arch/riscv/boot/Image"
|
||||||
|
|
16
arch/riscv/boot/loader.lds.S
Normal file
16
arch/riscv/boot/loader.lds.S
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
|
||||||
|
#include <asm/page.h>
|
||||||
|
|
||||||
|
OUTPUT_ARCH(riscv)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = PAGE_OFFSET;
|
||||||
|
|
||||||
|
.payload : {
|
||||||
|
*(.payload)
|
||||||
|
. = ALIGN(8);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user