From 45139d13b5a65905be919dca528fa5a478545a4a Mon Sep 17 00:00:00 2001 From: Yann MAGNIN Date: Fri, 13 Dec 2024 13:38:59 +0100 Subject: [PATCH] kernel: simplify PIE support --- fx9860g.ld.c | 4 ++-- fxcg50.ld.c | 4 ++-- fxcp_hh2.ld.c | 4 ++-- src/kernel/kernel.c | 10 ++++++++-- src/kernel/vbr.h | 4 ---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fx9860g.ld.c b/fx9860g.ld.c index a4ac9dc..f06c72c 100644 --- a/fx9860g.ld.c +++ b/fx9860g.ld.c @@ -70,11 +70,11 @@ SECTIONS _gint_exch_start = . ; KEEP(*(.gint.exch)) - _gint_exch_size = ABSOLUTE(. - _gint_exch_start); + _gint_exch_end = . ; _gint_tlbh_start = . ; KEEP(*(.gint.tlbh)) - _gint_tlbh_size = ABSOLUTE(. - _gint_tlbh_start); + _gint_tlbh_end = . ; *(.text .text.*) *(C P) diff --git a/fxcg50.ld.c b/fxcg50.ld.c index 8ad5e3e..c4ba63b 100644 --- a/fxcg50.ld.c +++ b/fxcg50.ld.c @@ -59,11 +59,11 @@ SECTIONS _gint_exch_start = . ; KEEP(*(.gint.exch)) - _gint_exch_size = ABSOLUTE(. - _gint_exch_start); + _gint_exch_end = . ; _gint_tlbh_start = . ; KEEP(*(.gint.tlbh)) - _gint_tlbh_size = ABSOLUTE(. - _gint_tlbh_start); + _gint_tlbh_end = . ; *(.text .text.*) } > rom diff --git a/fxcp_hh2.ld.c b/fxcp_hh2.ld.c index 5036a1b..897d8da 100644 --- a/fxcp_hh2.ld.c +++ b/fxcp_hh2.ld.c @@ -68,12 +68,12 @@ SECTIONS . = ALIGN(0x10); _gint_exch_start = . ; *(.gint.exch) - _gint_exch_size = ABSOLUTE(. - _gint_exch_start); + _gint_exch_end = . ; . = ALIGN(0x10); _gint_tlbh_start = . ; *(.gint.tlbh) - _gint_tlbh_size = ABSOLUTE(. - _gint_tlbh_start); + _gint_tlbh_end = . ; *(.text .text.*) } > ram AT> bin diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 602a9db..5f45b2e 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -76,9 +76,15 @@ void kinit(void) #endif /* Event handler entry points */ + extern uint32_t gint_exch_start; + extern uint32_t gint_exch_end; + extern uint32_t gint_tlbh_start; + extern uint32_t gint_tlbh_end; void *inth_entry = isSH3() ? gint_inth_7705 : gint_inth_7305; - uint32_t exch_size = (uint32_t)&gint_exch_size; - uint32_t tlbh_size = (uint32_t)&gint_tlbh_size; + uint32_t exch_size = \ + (uint32_t)&gint_exch_end - (uint32_t)&gint_exch_start; + uint32_t tlbh_size = \ + (uint32_t)&gint_tlbh_end - (uint32_t)&gint_tlbh_start; /* Load the event handler entry points into memory */ memcpy((void *)VBR + 0x100, gint_exch, exch_size); diff --git a/src/kernel/vbr.h b/src/kernel/vbr.h index dc0c1a8..e549874 100644 --- a/src/kernel/vbr.h +++ b/src/kernel/vbr.h @@ -11,8 +11,4 @@ void gint_tlbh(void); void gint_inth_7705(void); void gint_inth_7305(void); -/* Size of exception and TLB handlers */ -extern char gint_exch_size; -extern char gint_tlbh_size; - #endif /* GINT_CORE_VBR */