Skip to content

Commit

Permalink
Chainloader: Fix runtime_init indirection symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-richter committed Oct 29, 2020
1 parent eb69b6f commit 19763f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
11 changes: 6 additions & 5 deletions 07_uart_chainloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

Expand All @@ -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*) }
}
Expand All @@ -323,7 +324,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs 07_uart_chainloader
extern "Rust" {
+ static __binary_start: UnsafeCell<u64>;
+ static __binary_end_inclusive: UnsafeCell<u64>;
+ static __runtime_init: UnsafeCell<u64>;
+ static __runtime_init_reloc: UnsafeCell<u64>;
static __bss_start: UnsafeCell<u64>;
static __bss_end_inclusive: UnsafeCell<u64>;
}
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion 07_uart_chainloader/src/bsp/raspberrypi/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ SECTIONS
.text :
{
*(.text._start)
__runtime_init = .;
KEEP(*(.text.runtime_init))
*(.text*);
}
Expand Down Expand Up @@ -45,5 +44,7 @@ SECTIONS
. = ALIGN(8);
__binary_end_inclusive = . - 8;

__runtime_init_reloc = runtime_init;

/DISCARD/ : { *(.comment*) }
}
4 changes: 2 additions & 2 deletions 07_uart_chainloader/src/bsp/raspberrypi/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::{cell::UnsafeCell, ops::RangeInclusive};
extern "Rust" {
static __binary_start: UnsafeCell<u64>;
static __binary_end_inclusive: UnsafeCell<u64>;
static __runtime_init: UnsafeCell<u64>;
static __runtime_init_reloc: UnsafeCell<u64>;
static __bss_start: UnsafeCell<u64>;
static __bss_end_inclusive: UnsafeCell<u64>;
}
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions 08_timestamps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

Expand All @@ -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*) }
}
Expand All @@ -315,7 +316,7 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/memory.rs 08_timestamps/src/bs
extern "Rust" {
- static __binary_start: UnsafeCell<u64>;
- static __binary_end_inclusive: UnsafeCell<u64>;
- static __runtime_init: UnsafeCell<u64>;
- static __runtime_init_reloc: UnsafeCell<u64>;
static __bss_start: UnsafeCell<u64>;
static __bss_end_inclusive: UnsafeCell<u64>;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 19763f8

Please sign in to comment.