From 19763f88402d6940db42df759d61634d020b7d01 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Thu, 29 Oct 2020 17:28:33 +0100 Subject: [PATCH] Chainloader: Fix runtime_init indirection symbol --- 07_uart_chainloader/README.md | 11 ++++++----- 07_uart_chainloader/src/bsp/raspberrypi/link.ld | 3 ++- 07_uart_chainloader/src/bsp/raspberrypi/memory.rs | 4 ++-- 08_timestamps/README.md | 11 ++++++----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/07_uart_chainloader/README.md b/07_uart_chainloader/README.md index 4d27f4df..c23fb7e7 100644 --- a/07_uart_chainloader/README.md +++ b/07_uart_chainloader/README.md @@ -278,7 +278,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 0 diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld 07_uart_chainloader/src/bsp/raspberrypi/link.ld --- 06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld +++ 07_uart_chainloader/src/bsp/raspberrypi/link.ld -@@ -5,12 +5,16 @@ +@@ -5,12 +5,15 @@ SECTIONS { @@ -292,13 +292,12 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld 07_uart_chainloader/s { - *(.text._start) *(.text*) + *(.text._start) -+ __runtime_init = .; + KEEP(*(.text.runtime_init)) + *(.text*); } .rodata : -@@ -32,5 +36,14 @@ +@@ -32,5 +35,16 @@ __bss_end_inclusive = . - 8; } @@ -310,6 +309,8 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld 07_uart_chainloader/s + /* Fill up to 8 byte, b/c relocating the binary is done in u64 chunks */ + . = ALIGN(8); + __binary_end_inclusive = . - 8; ++ ++ __runtime_init_reloc = runtime_init; + /DISCARD/ : { *(.comment*) } } @@ -323,7 +324,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs 07_uart_chainloader extern "Rust" { + static __binary_start: UnsafeCell; + static __binary_end_inclusive: UnsafeCell; -+ static __runtime_init: UnsafeCell; ++ static __runtime_init_reloc: UnsafeCell; static __bss_start: UnsafeCell; static __bss_end_inclusive: UnsafeCell; } @@ -367,7 +368,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs 07_uart_chainloader +/// The relocated address of function `runtime_init()`. +#[inline(always)] +pub fn relocated_runtime_init_addr() -> *const u64 { -+ unsafe { __runtime_init.get() as _ } ++ unsafe { __runtime_init_reloc.get() as _ } +} + +/// Return the inclusive range spanning the relocated .bss section. diff --git a/07_uart_chainloader/src/bsp/raspberrypi/link.ld b/07_uart_chainloader/src/bsp/raspberrypi/link.ld index b98fc70f..1dd2403e 100644 --- a/07_uart_chainloader/src/bsp/raspberrypi/link.ld +++ b/07_uart_chainloader/src/bsp/raspberrypi/link.ld @@ -12,7 +12,6 @@ SECTIONS .text : { *(.text._start) - __runtime_init = .; KEEP(*(.text.runtime_init)) *(.text*); } @@ -45,5 +44,7 @@ SECTIONS . = ALIGN(8); __binary_end_inclusive = . - 8; + __runtime_init_reloc = runtime_init; + /DISCARD/ : { *(.comment*) } } diff --git a/07_uart_chainloader/src/bsp/raspberrypi/memory.rs b/07_uart_chainloader/src/bsp/raspberrypi/memory.rs index ee3bf5dc..989f51b0 100644 --- a/07_uart_chainloader/src/bsp/raspberrypi/memory.rs +++ b/07_uart_chainloader/src/bsp/raspberrypi/memory.rs @@ -14,7 +14,7 @@ use core::{cell::UnsafeCell, ops::RangeInclusive}; extern "Rust" { static __binary_start: UnsafeCell; static __binary_end_inclusive: UnsafeCell; - static __runtime_init: UnsafeCell; + static __runtime_init_reloc: UnsafeCell; static __bss_start: UnsafeCell; static __bss_end_inclusive: UnsafeCell; } @@ -83,7 +83,7 @@ pub fn relocated_binary_range_inclusive() -> RangeInclusive<*mut u64> { /// The relocated address of function `runtime_init()`. #[inline(always)] pub fn relocated_runtime_init_addr() -> *const u64 { - unsafe { __runtime_init.get() as _ } + unsafe { __runtime_init_reloc.get() as _ } } /// Return the inclusive range spanning the relocated .bss section. diff --git a/08_timestamps/README.md b/08_timestamps/README.md index ab7b28fb..d67f7cd1 100644 --- a/08_timestamps/README.md +++ b/08_timestamps/README.md @@ -270,7 +270,7 @@ diff -uNr 07_uart_chainloader/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 08 diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/link.ld 08_timestamps/src/bsp/raspberrypi/link.ld --- 07_uart_chainloader/src/bsp/raspberrypi/link.ld +++ 08_timestamps/src/bsp/raspberrypi/link.ld -@@ -5,16 +5,12 @@ +@@ -5,15 +5,12 @@ SECTIONS { @@ -283,14 +283,13 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/link.ld 08_timestamps/src/bsp/ .text : { - *(.text._start) -- __runtime_init = .; - KEEP(*(.text.runtime_init)) - *(.text*); + *(.text._start) *(.text*) } .rodata : -@@ -36,14 +32,5 @@ +@@ -35,16 +32,5 @@ __bss_end_inclusive = . - 8; } @@ -302,6 +301,8 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/link.ld 08_timestamps/src/bsp/ - /* Fill up to 8 byte, b/c relocating the binary is done in u64 chunks */ - . = ALIGN(8); - __binary_end_inclusive = . - 8; +- +- __runtime_init_reloc = runtime_init; - /DISCARD/ : { *(.comment*) } } @@ -315,7 +316,7 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/memory.rs 08_timestamps/src/bs extern "Rust" { - static __binary_start: UnsafeCell; - static __binary_end_inclusive: UnsafeCell; -- static __runtime_init: UnsafeCell; +- static __runtime_init_reloc: UnsafeCell; static __bss_start: UnsafeCell; static __bss_end_inclusive: UnsafeCell; } @@ -358,7 +359,7 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/memory.rs 08_timestamps/src/bs -/// The relocated address of function `runtime_init()`. -#[inline(always)] -pub fn relocated_runtime_init_addr() -> *const u64 { -- unsafe { __runtime_init.get() as _ } +- unsafe { __runtime_init_reloc.get() as _ } -} - -/// Return the inclusive range spanning the relocated .bss section.