| /* Copyright 2021 The Fuchsia Authors | |
| * | |
| * Use of this source code is governed by a MIT-style | |
| * license that can be found in the LICENSE file or at | |
| * https://opensource.org/licenses/MIT | |
| */ | |
| /* | |
| * This file is included as an input linker script to support the assembly code | |
| * in linuxboot-header.S when used in a phys_executable() target. It defines | |
| * the link-time base address needed by phys.ld and also defines values for | |
| * linuxboot-header.S to use that cannot be represented directly there. | |
| * | |
| * The default load address of the 32-bit (aka "protected mode") code is 1MiB, | |
| * but the image is position-independent and can be loaded anywhere. The | |
| * header defined in linuxboot-header.S tells the boot loader so, for so-called | |
| * "bzImage" protocol. The bzImage format starts with the "real-mode kernel | |
| * header" before that kernel image that contains both header details known as | |
| * a protocol by boot loaders and also 16-bit x86 code that boot loaders | |
| * optionally use as the entry point. | |
| * | |
| * Linux builds a separate 32-bit kernel image (which itself is a pre-kernel | |
| * that does decompression of an embedded kernel image in another format) and a | |
| * 16-bit header image and then uses a fixup tool to concatenate them and fix | |
| * up some fields. Instead, we do it all in one pass at link time and then | |
| * just do the usual objcopy extraction to raw binary. The linuxboot-header.S | |
| * file provides this header (including 16-bit x86 code) in the .boot.header | |
| * section that phys.ld will place first in the raw binary image laid out at | |
| * link time. That linker script requires PHYS_LOAD_ADDRESS to be defined as | |
| * the physical address corresponding to the start of that raw binary image. | |
| */ | |
| /* | |
| * So we define PHYS_LOAD_ADDRESS to be beneath the load address of the 32-bit | |
| * code such that the image directly after .boot.header (linuxboot-header.S) | |
| * corresponds to that address, which linuxboot-header.S defines as the | |
| * LINUXBOOT_LOAD_ADDRESS label. The runtime boot protocol may place that | |
| * header at an arbitrary address (so the 16-bit code has to be purely | |
| * position-independent.) It defines the LINUXBOOT_SETUP_SIZE symbol with the | |
| * total of its contents in bytes to allow this calculatation. | |
| */ | |
| HIDDEN(PHYS_LOAD_ADDRESS = LINUXBOOT_LOAD_ADDRESS - LINUXBOOT_SETUP_SIZE); | |
| /* | |
| * The protocol-specified part of the header layout includes the total size of | |
| * the 32-bit image, which is calculated at link time. However, it doesn't use | |
| * a size in bytes for this but a size in 16-byte units (called "paragraphs" in | |
| * ancient Intelspeak). There are no x86 relocation types to encode a uint32_t | |
| * value scaled down by 16 from a link-time symbol address, so assembly code in | |
| * linuxboot-header.S can't compute this value directly itself. Instead, it | |
| * relies on this symbol. Linker scripts can do the necessary arithmetic where | |
| * assembly cannot. | |
| */ | |
| HIDDEN(LINUXBOOT_SYSSIZE = (PHYS_LOAD_END - LINUXBOOT_LOAD_ADDRESS) / 16); | |
| /* | |
| * Size of the kernel in memory, including the bss after the image so that the | |
| * boot loader is sure to place the kernel where it has enough headroom after | |
| * the storage image is loaded. This symbol is used by the header assembly | |
| * code to embed this value, which cannot be calculated directly by a single | |
| * relocation record. | |
| */ | |
| HIDDEN(LINUXBOOT_INIT_SIZE = ABSOLUTE(_end - LINUXBOOT_LOAD_ADDRESS)); |