From b836655d668959b8fdd39ca91ea04e3ee0803c0f Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Tue, 19 Apr 2022 22:54:42 +0200 Subject: [PATCH] More link.ld -> kernel.ld renaming --- 01_wait_forever/README.CN.md | 2 +- 01_wait_forever/README.ES.md | 28 +++++++++---------- 02_runtime_init/README.ES.md | 2 +- 06_uart_chainloader/README.md | 9 +++--- .../README.md | 4 +-- .../README.md | 6 ++-- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/01_wait_forever/README.CN.md b/01_wait_forever/README.CN.md index 281a9290..06b2178d 100644 --- a/01_wait_forever/README.CN.md +++ b/01_wait_forever/README.CN.md @@ -14,7 +14,7 @@ - `nm`: 检查符号。 - 代码按照 `kernel`, `arch` 和 `BSP` (板级支持包)的形式组织。 - 条件编译会根据用户提供的参数编译各自的 `arch` 和 `BSP` 的内容。 -- 自定义 `link.ld` 链接脚本. +- 自定义 `kernel.ld` 链接脚本. - 载入地址为 `0x80_000` - 目前仅有 `.text` 小节(section)。 - `main.rs`: 重要的 [inner attributes]: diff --git a/01_wait_forever/README.ES.md b/01_wait_forever/README.ES.md index 5244372a..0d86a4ea 100644 --- a/01_wait_forever/README.ES.md +++ b/01_wait_forever/README.ES.md @@ -9,37 +9,37 @@ ## Compilar * El archivo `Makefile` permite ejecutar: - + * `doc`: Genera la documentación. - + * `qemu`: Ejecutar el kernel en QEMU. - + * `clippy`: Analiza el código y sugiere mejoras. - + * `clean`: Elimina todos los archivos generados durante la compilación, etc. - + * `readelf`: Inspecciona el archivo `ELF` de salida. - - * `objdump`: Inspecciona el ensamblador. - + + * `objdump`: Inspecciona el ensamblador. + * `nm`: Inspecciona los símbolos. ## Código a revisar -* El script para enlazado específico para la `BSP` llamado `link.ld`. - +* El script para enlazado específico para la `BSP` llamado `kernel.ld`. + * Carga la dirección en `0x8_0000`. - + * Solo la sección `.text`. * `main.rs`: [Atributos internos](https://doc.rust-lang.org/reference/attributes.html) importantes: - + * `#![no_std]`, `#![no_main]`. -* `boot.s`: La función de ensamblador `_start()` que inicia `wfe` (Wait For Event / Esperar Hasta Un Evento), detiene todos los núcleos del procesador que están ejecutando `_start()`. +* `boot.s`: La función de ensamblador `_start()` que inicia `wfe` (Wait For Event / Esperar Hasta Un Evento), detiene todos los núcleos del procesador que están ejecutando `_start()`. * Tenemos que definir una función que funcione como `#[panic_handler]` (manejador de pánico) para que el compilador no nos cause problemas. - + * Hazla `unimplemented!()` porque se eliminará ya que no está siendo usada. ## Pruébalo diff --git a/02_runtime_init/README.ES.md b/02_runtime_init/README.ES.md index 79c4c2b4..e1210e9b 100644 --- a/02_runtime_init/README.ES.md +++ b/02_runtime_init/README.ES.md @@ -8,7 +8,7 @@ ## Adiciones importantes -* Adiciones importantes al script `link.ld`: +* Adiciones importantes al script `kernel.ld`: * Nuevas secciones: `.rodata`, `.got`, `.data`, `.bss`. diff --git a/06_uart_chainloader/README.md b/06_uart_chainloader/README.md index b3db670f..8c860316 100644 --- a/06_uart_chainloader/README.md +++ b/06_uart_chainloader/README.md @@ -17,8 +17,8 @@ at the source code changes. The gist of it is that in `boot.s`, we are writing a piece of [position independent code] which automatically determines where the firmware has loaded the binary (`0x8_0000`), and where it was -linked to (`0x200_0000`, see `link.ld`). The binary then copies itself from loaded to linked address -(aka "relocating" itself), and then jumps to the relocated version of `_start_rust()`. +linked to (`0x200_0000`, see `kernel.ld`). The binary then copies itself from loaded to linked +address (aka "relocating" itself), and then jumps to the relocated version of `_start_rust()`. Since the chainloader has put itself "out of the way" now, it can now receive another kernel binary from the `UART` and copy it to the standard load address of the RPi firmware at `0x8_0000`. Finally, @@ -27,8 +27,9 @@ from SD card all along. Please bear with me until I find the time to write it all down here elaborately. For the time being, please see this tutorial as an enabler for a convenience feature that allows booting the following -tutorials in a quick manner. _For those keen to get a deeper understanding, it could make sense to skip forward to [Chapter 15](../15_virtual_mem_part3_precomputed_tables) and read the first half of the README, -where `Load Address != Link Address` is discussed_. +tutorials in a quick manner. _For those keen to get a deeper understanding, it could make sense to +skip forward to [Chapter 15](../15_virtual_mem_part3_precomputed_tables) and read the first half of +the README, where `Load Address != Link Address` is discussed_. [position independent code]: https://en.wikipedia.org/wiki/Position-independent_code diff --git a/10_virtual_mem_part1_identity_mapping/README.md b/10_virtual_mem_part1_identity_mapping/README.md index 1a02666b..8c2de206 100644 --- a/10_virtual_mem_part1_identity_mapping/README.md +++ b/10_virtual_mem_part1_identity_mapping/README.md @@ -14,7 +14,7 @@ * [Generic Kernel code: `memory/mmu.rs`](#generic-kernel-code-memorymmurs) * [BSP: `bsp/raspberrypi/memory/mmu.rs`](#bsp-bspraspberrypimemorymmurs) * [AArch64: `_arch/aarch64/memory/*`](#aarch64-_archaarch64memory) - * [`link.ld`](#linkld) + * [`kernel.ld`](#kernelld) - [Address translation examples](#address-translation-examples) * [Address translation using a 64 KiB page descriptor](#address-translation-using-a-64-kib-page-descriptor) - [Zero-cost abstraction](#zero-cost-abstraction) @@ -222,7 +222,7 @@ enables caching for data and instructions. [Translation Control Register - EL1]: https://docs.rs/crate/cortex-a/5.1.2/source/src/regs/tcr_el1.rs [System Control Register - EL1]: https://docs.rs/crate/cortex-a/5.1.2/source/src/regs/sctlr_el1.rs -### `link.ld` +### `kernel.ld` We need to align the `code` segment to `64 KiB` so that it doesn't overlap with the next section that needs read/write attributes instead of read/execute attributes: diff --git a/15_virtual_mem_part3_precomputed_tables/README.md b/15_virtual_mem_part3_precomputed_tables/README.md index c3554f19..8cd644f4 100644 --- a/15_virtual_mem_part3_precomputed_tables/README.md +++ b/15_virtual_mem_part3_precomputed_tables/README.md @@ -118,7 +118,7 @@ Here are the compilation steps and the corresponding `objdump` for `AArch64`: ```console $ clang --target=aarch64-none-elf -Iinclude -Wall -c start.c -o start.o -$ ld.lld start.o -T link.ld -o example.elf +$ ld.lld start.o -T kernel.ld -o example.elf ``` ```c-objdump @@ -326,7 +326,7 @@ space: ```console $ clang --target=aarch64-none-elf -Iinclude -Wall -fpic -c start.c -o start.o -$ ld.lld start.o -T link.ld -o example.elf +$ ld.lld start.o -T kernel.ld -o example.elf ``` ```c-objdump @@ -473,7 +473,7 @@ the precompute use-case. The additional `#[no_mangle]` is added because we will symbol from the `translation table tool`, and this is easier with unmangled names. In the `BSP` code, there is also a new file called `kernel_virt_addr_space_size.ld`, which contains -the kernel's virtual address space size. This file gets included in both, the `link.ld` linker +the kernel's virtual address space size. This file gets included in both, the `kernel.ld` linker script and `mmu.rs`. We need this value both as a symbol in the kernel's ELF (for the `translation table tool` to parse it later) and as a constant in the `Rust` code. This inclusion approach is just a convenience hack that turned out working well.