Skip to content

Commit

Permalink
linker: restructure linker script directory
Browse files Browse the repository at this point in the history
  • Loading branch information
HidenoriMatsubayashi committed May 6, 2023
1 parent 7890408 commit fb3268e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ target_include_directories(${TARGET} PRIVATE "src")
# Linker script
# ==========================================================================
if (${BOARD} STREQUAL "raspi4")
set(LINKER_SCRIPT "src/arch/arm64/boot/raspberry-pi4/linker.ld")
set(LINKER_SCRIPT "src/arch/arm64/scripts/rpi4/linker.ld")
else()
set(LINKER_SCRIPT "src/arch/arm64/boot/qemu/cortex-a72/linker.ld")
set(LINKER_SCRIPT "src/arch/arm64/scripts/qemu/cortex-a72/linker.ld")
endif()
set_target_properties(${TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})
target_link_options(${TARGET} PRIVATE "-T${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
/**
* Linker Script for QEMU coretex-a72/virt/4GB
* Linker Script for QEMU coretex-a72/virt/1GB
**/

OUTPUT_ARCH(aarch64)
ENTRY(_start)

MEMORY
{
/* 0x40280000 => uboot load address*/
/* 1GB memory */
/*
* U-BOOT loadd address: 0x40280000
* Physical memory size: 1GB
*/
RAM (xrw) : ORIGIN = 0x40280000, LENGTH = 1 * 1024 * 1024 * 1024
}

SECTIONS {
__start = .;

/* text region for Hypervisor */
.text : {
__text_start = .;
KEEP(*(.text.start))
Expand All @@ -23,6 +27,7 @@ SECTIONS {
} > RAM
__text_size = __text_end - __text_start;

/* rodata region for Hypervisor */
.rodata : {
__rodata_start = .;
*(.rodata*)
Expand All @@ -31,6 +36,7 @@ SECTIONS {
} > RAM
__rodata_size = __rodata_end - __rodata_start;

/* data region for Hypervisor */
.data : {
__data_start = . ;
*(.data*)
Expand All @@ -39,6 +45,7 @@ SECTIONS {
} > RAM
__data_size = __data_end - __data_start;

/* bss region for Hypervisor */
.bss : {
__bss_start = . ;
*(.bss*)
Expand All @@ -47,36 +54,36 @@ SECTIONS {
} > RAM
__bss_size = __bss_end - __bss_start;

/* 64MB heap region for Hypervisor */
.heap : {
__heap_start = .;
/* 64MiB heap */
. = . + 1024 * 1024 * 64;
. = ALIGN(0x1000);
__heap_end = .;
} > RAM
__heap_size = __heap_end - __heap_start;

/* 1MB uncached region for Hypervisor */
.uncached_space : {
__uncached_space_start = .;
/* 1MB uncached regin */
. = . + 1024 * 1024 * 1;
. = ALIGN(0x1000);
__uncached_space_end = .;
} > RAM
__uncached_space_size = __uncached_space_end - __uncached_space_start;

/* 512MB user memory region for guests */
.user_space : {
__user_space_start = .;
/* 512MiB user space */
. = . + 1024 * 1024 * 512;
. = ALIGN(0x1000);
__user_space_end = .;
}
__user_space_size = __user_space_end - __user_space_start;

/* 64MB stack region for Hypervisor */
.stack : {
__stack_start = .;
/* 64MiB space */
. = ALIGN(0x1000);
__stack_end = __stack_start + (1024 * 1024) * 64;
} > RAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ ENTRY(_start)

MEMORY
{
/**
* - Raspberry Pi 4 has 4GiB RAM
* - "0x00080000" is the Kernel load address for aarch64
**/
/*
* PRI boot loader loadds kernel.bin to 0x40280000
* Physical memory size: 4GB
*/
RESERVED (r) : ORIGIN = 0x00000000, LENGTH = 32K
RAM (xrw) : ORIGIN = 0x00080000, LENGTH = (0x100000000 - 0x00080000)
}

SECTIONS {
__start = .;

/* text region for Hypervisor */
.text : {
__text_start = .;
KEEP(*(.text.start))
Expand All @@ -26,6 +28,7 @@ SECTIONS {
} > RAM
__text_size = __text_end - __text_start;

/* rodata region for Hypervisor */
.rodata : {
__rodata_start = .;
*(.rodata*)
Expand All @@ -34,6 +37,7 @@ SECTIONS {
} > RAM
__rodata_size = __rodata_end - __rodata_start;

/* data region for Hypervisor */
.data : {
__data_start = . ;
*(.data*)
Expand All @@ -42,6 +46,7 @@ SECTIONS {
} > RAM
__data_size = __data_end - __data_start;

/* bss region for Hypervisor */
.bss : {
__bss_start = . ;
*(.bss*)
Expand All @@ -50,36 +55,36 @@ SECTIONS {
} > RAM
__bss_size = __bss_end - __bss_start;

/* 64MB heap region for Hypervisor */
.heap : {
__heap_start = .;
/* 64MiB heap */
. = . + 1024 * 1024 * 64;
. = ALIGN(0x1000);
__heap_end = .;
} > RAM
__heap_size = __heap_end - __heap_start;

/* 1MB uncached region for Hypervisor */
.uncached_space : {
__uncached_space_start = .;
/* 1MB uncached regin */
. = . + 1024 * 1024 * 1;
. = ALIGN(0x1000);
__uncached_space_end = .;
} > RAM
__uncached_space_size = __uncached_space_end - __uncached_space_start;

/* 2GB user memory region for guests */
.user_space : {
__user_space_start = .;
/* 2GiB user space */
. = . + 1024 * 1024 * 1024 * 2;
. = ALIGN(0x1000);
__user_space_end = .;
} > RAM
__user_space_size = __user_space_end - __user_space_start;

/* 64MB stack region for Hypervisor */
.stack : {
__stack_start = .;
/* 64MiB space */
. = ALIGN(0x1000);
__stack_end = __stack_start + (1024 * 1024) * 64;
} > RAM
Expand Down

0 comments on commit fb3268e

Please sign in to comment.