Skip to content

Commit

Permalink
Use VA start and end linker symbols instead of length (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfvak authored Jun 19, 2024
1 parent eee63dd commit 7b6b478
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions arm11/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SECTIONS
__text_va = ABSOLUTE(.);
*(.text*)
. = ALIGN(4K);
__text_len = . - __text_va;
__text_va_end = .;
} >AXIWRAM

.data : ALIGN(4K)
Expand All @@ -25,7 +25,7 @@ SECTIONS
__data_va = ABSOLUTE(.);
*(.data*)
. = ALIGN(4K);
__data_len = . - __data_va;
__data_va_end = .;
} >AXIWRAM

.rodata : ALIGN(4K)
Expand All @@ -34,7 +34,7 @@ SECTIONS
__rodata_va = ABSOLUTE(.);
*(.rodata*)
. = ALIGN(4K);
__rodata_len = . - __rodata_va;
__rodata_va_end = .;
} >AXIWRAM

.shared (NOLOAD) : ALIGN(4K)
Expand All @@ -43,7 +43,7 @@ SECTIONS
__shared_va = ABSOLUTE(.);
*(.shared*)
. = ALIGN(4K);
__shared_len = . - __shared_va;
__shared_va_end = .;
} >AXIWRAM

.bss (NOLOAD) : ALIGN(4K)
Expand All @@ -52,6 +52,6 @@ SECTIONS
__bss_va = ABSOLUTE(.);
*(.bss*)
. = ALIGN(4K);
__bss_len = . - __bss_va;
__bss_va_end = .;
} >AXIWRAM
}
8 changes: 5 additions & 3 deletions arm11/source/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ __boot:
b 1b

corezero_start:
@ assume __bss_len is 128 byte aligned
@ assumes the .bss section size is 128 byte aligned (or zero)
ldr r0, =__bss_pa
ldr r1, =__bss_len
add r1, r0, r1
ldr r1, =__bss_va_end @ calculate the length of .bss using the VA start and end
ldr r2, =__bss_va
sub r1, r1, r2
add r1, r0, r1 @ fixup to be PA start and end
mov r2, #0
mov r3, #0
mov r4, #0
Expand Down
4 changes: 2 additions & 2 deletions arm11/source/system/sections.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <types.h>

#define DEF_SECT_(n) extern u32 __##n##_pa, __##n##_va, __##n##_len;
#define DEF_SECT_(n) extern u32 __##n##_pa, __##n##_va, __##n##_va_end;
DEF_SECT_(text)
DEF_SECT_(data)
DEF_SECT_(rodata)
Expand All @@ -30,6 +30,6 @@ DEF_SECT_(shared)

#define SECTION_VA(n) ((u32)&__##n##_va)
#define SECTION_PA(n) ((u32)&__##n##_pa)
#define SECTION_LEN(n) ((u32)&__##n##_len)
#define SECTION_LEN(n) (((u32)(&__##n##_va_end) - (u32)(&__##n##_va)))

#define SECTION_TRI(n) SECTION_VA(n), SECTION_PA(n), SECTION_LEN(n)

0 comments on commit 7b6b478

Please sign in to comment.