aboutsummaryrefslogtreecommitdiff
path: root/src/arch/i386/scripts
AgeCommit message (Collapse)AuthorFilesLines
2023-01-22[linux] Centralise the linker script for Linux binariesMichael Brown1-106/+0
Reduce duplication between i386 and x86_64 by providing a single shared linker script that both architectures can include. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-01-13[efi] Include Secure Boot Advanced Targeting (SBAT) metadatasbatMichael Brown2-0/+4
SBAT defines an encoding for security generation numbers stored as a CSV file within a special ".sbat" section in the signed binary. If a Secure Boot exploit is discovered then the generation number will be incremented alongside the corresponding fix. Platforms may then record the minimum generation number required for any given product. This allows for an efficient revocation mechanism that consumes minimal flash storage space (in contrast to the DBX mechanism, which allows for only a single-digit number of revocation events to ever take place across all possible signed binaries). Add SBAT metadata to iPXE EFI binaries to support this mechanism. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Add bin-x86_64-pcbios build platformMichael Brown1-254/+0
Move most arch/i386 files to arch/x86, and adjust the contents of the Makefiles and the include/bits/*.h headers to reflect the new locations. This patch makes no substantive code changes, as can be seen using a rename-aware diff (e.g. "git show -M5"). This patch does not make the pcbios platform functional for x86_64; it merely allows it to compile without errors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-12[prefix] Pad .text16 and .data16 segment sizes at build timeMichael Brown1-2/+2
Commit c64747d ("[librm] Speed up real-to-protected mode transition under KVM") rounded down the .text16 segment address calculated in alloc_basemem() to a multiple of 64 bytes in order to speed up mode transitions under KVM. This creates a potential discrepancy between alloc_basemem() and free_basemem(), meaning that free_basemem() may free less memory than was allocated by alloc_basemem(). Fix by padding the calculated sizes of both .text16 and .data16 to a multiple of 64 bytes at build time. Debugged-by: Yossef Efraim <yossefe@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-15[build] Allow building PCI ROMs with device ID listsMichael Brown1-0/+1
PCI v3.0 supports a "device list" which allows the ROM to claim support for multiple PCI device IDs (but only a single vendor ID). Add support for building such ROMs by scanning the build target element list and incorporating any device IDs into the ROM's device list header. For example: make bin/8086153a--8086153b.mrom would build a ROM claiming support for both 8086:153a and 8086:153b. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-24[prefix] Use .bss16 as temporary stack space for calls to install_blockMichael Brown1-0/+8
Some decompression algorithms (e.g. LZMA) require large amounts of temporary stack space, which may not be made available by all prefixes. Use .bss16 as a temporary stack for the duration of the calls to install_block (switching back to the external stack before we start making calls into code which might access variables in .bss16), and allow the decompressor to define a global symbol to force a minimum value on the size of .bss16. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-16[build] Fix %.licence build targetMichael Brown3-0/+6
Our use of --gc-sections causes the linker to discard the symbols defined by FILE_LICENCE(), meaning that the resulting licence determination is incomplete. We must use the KEEP() directive in the linker script to force the linker to not discard the licence symbols. Using KEEP(*(COMMON)) would be undesirable, since there are some symbols in COMMON which we may wish to discard. Fix by placing symbols defined by PROVIDE_SYMBOL() (which is used by FILE_LICENCE()) into a special ".provided" section, which we then mark with KEEP(). All such symbols are zero-length, so there is no cost in terms of the final binary size. Since the symbols are no longer in COMMON, the linker will reject symbols with the same name coming from multiple objects. We therefore append the object name to the licence symbol, to ensure that it is unique. Reported-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12[romprefix] Add a dummy ROM header to cover the .mrom payloadMichael Brown1-1/+24
The header of a .mrom image declares its length to be only a few kilobytes; the remainder is accessed via a sideband mechanism. This makes it difficult to append an additional ROM image, such as an EFI ROM. Add a second, dummy ROM header covering the payload portion of the .mrom image, allowing consumers to locate any appended ROM images in the usual way. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-29[build] Fix building on mildly deranged versions of binutilsMichael Brown1-13/+13
Some versions of binutils have curious concepts of what constitutes subtraction. For example: 0x00000000000000f0 _text16_late = . 0x0000000000000898 _mtext16 = . 0x0000000000000898 _etext16 = . 0x0000000000000898 _text16_late_filesz = ABSOLUTE ((_mtext16 - _text16_late)) 0x00000000000007a8 _text16_late_memsz = ABSOLUTE ((_etext16 - _text16_late)) This has interesting side-effects such as producing sizes for .bss segments that are negative, causing the majority of addressable memory to be zeroed out. Fix by using the form ABSOLUTE ( x ) - ABSOLUTE ( y ) rather than ABSOLUTE ( x - y ) Reported-by: H. Peter Anvin <hpa@zytor.com> Suggested-by: H. Peter Anvin <hpa@zytor.com> Tested-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27[linux] Make malloc and linux_umalloc valgrindablePiotr Jaroszyński1-3/+4
Make the allocators used by malloc and linux_umalloc valgrindable. Include valgrind headers in the codebase to avoid a build dependency on valgrind. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-02-23[build] Use unique entry symbols for each prefixMichael Brown3-5/+0
Some binutils versions will drag in an object to satisfy the entry symbol; some won't. Try to cope with this exciting variety of behaviour by ensuring that all entry symbols are unique. Remove the explicit inclusion of the prefix object on the linker command line, since the entry symbol now provides all the information needed to identify the prefix. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-02-23[build] Ensure an entry point symbol exists in all buildsMichael Brown1-0/+2
Commit 623469d ("[build] Eliminate unused sections at link-time") introduced a regression in several build formats, in which the prefix would end up being garbage-collected out of existence. Fix by ensuring that an entry symbol exists in each possible prefix, and is required by the linker script. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-02-22[build] Eliminate unused sections at link-timeMichael Brown3-8/+18
Use -ffunction-sections, -fdata-sections, and --gc-sections to automatically prune out any unreferenced sections. This saves around 744 bytes (uncompressed) from the rtl8139.rom build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-19[linux] Add linux platform skeletonPiotr Jaroszyński1-0/+101
Add makefiles, ld scripts and default config for linux platform for both i386 and x86_64. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-31[libc] Enable automated extraction of error usage reportsMichael Brown1-0/+2
Add preprocessor magic to the error definitions to enable every error usage to be tracked. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-27[build] Fix building with binutils 2.16Michael Brown1-1/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-25[prefix] Use area at top of INT 15,88 memory map for temporary decompressionMichael Brown1-0/+2
Use INT 15,88 to find a suitable temporary decompression area, rather than a fixed address. This hopefully gives us a better chance of not treading on any PMM-allocated areas, in BIOSes where PMM support exists but tends not to give us the large blocks that we ask for. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-20[prefix] Add .text16.early sectionMichael Brown1-6/+16
Add a section .text16.early which is always kept inline with the prefix. This will allow for some code sharing between the .prefix and .text16 sections. Note that the simple solution of just prepending the .prefix section to the .text16 section will not work, because a bug in Wyse Streaming Manager server (WLDRM13.BIN) requires us to place a dummy PXENV+ entry point at the start of .text16. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19[romprefix] Remove .xrom prefixMichael Brown1-1/+0
The .xrom prefix provides an experimental mechanism for loading ROM images greater than 64kB in size by mapping the expansion ROM BAR in at a hopefully-unused address. This is unreliable, and potentially dangerous. In particular, there is no guarantee that any PCI bridges between the CPU and the device will respond to accesses for the "unused" memory region that is chosen, and it is possible that the process of scanning for the "unused" memory region may end up issuing reads to other PCI devices. If this ends up trampling on a register with read side-effects belonging to an unrelated PCI device, this may cause undefined behaviour. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-01-20[prefix] Add .xrom prefix for a ROM that loads itself by PCI accessesJoshua Oreman1-0/+1
The standard option ROM format provides a header indicating the size of the entire ROM, which the BIOS will reserve space for, load, and call as necessary. However, this space is strictly limited to 128k for all ROMs. gPXE ameliorates this somewhat by reserving space for itself in high memory and relocating the majority of its code there, but on systems prior to PCI3 enough space must still be present to load the ROM in the first place. Even on PCI3 systems, the BIOS often limits the size of ROM it will load to a bit over 64kB. These space problems can be solved by providing an artificially small size in the ROM header: just enough to let the prefix code (at the beginning of the ROM image) be loaded by the BIOS. To the BIOS, the gPXE ROM will appear to be only a few kilobytes; it can then load the rest of itself by accessing the ROM directly using the PCI interface reserved for that task. There are a few problems with this approach. First, gPXE needs to find an unmapped region in memory to map the ROM so it can read from it; this is done using the crude but effective approach of scanning high memory (over 0xF0000000) for a sufficiently large region of all-ones (0xFF) reads. (In x86 architecture, all-ones is returned for accesses to memory regions that no mapped device can satisfy.) This is not provably valid in all situations, but has worked well in practice. More importantly, this type of ROM access can only work if the PCI ROM BAR exists at all. NICs on physical add-in PCI cards generally must have the BAR in order for the BIOS to be able to load their ROM, but ISA cards and LAN-on-Motherboard cards will both fail to load gPXE using this scheme. Due to these uncertainties, it is recommended that .xrom only be used when a regular .rom image is infeasible due to crowded option ROM space. However, when it works it could allow loading gPXE images as large as a flash chip one could find - 128kB or even higher. Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-11-20[linker] Expand and correct symbol requirement macrosJoshua Oreman2-0/+2
REQUIRE_SYMBOL() formerly used a formulation of symbol requirement that would allow a link to succeed despite lacking a required symbol, because it did not introduce any relocations. Fix by renaming it to REQUEST_SYMBOL() (since the soft-requirement behavior can be useful) and add a REQUIRE_SYMBOL() that truly requires. Add EXPORT_SYMBOL() and IMPORT_SYMBOL() for REQUEST_SYMBOL()-like behavior that allows one to make use of the symbol, by combining a weak external on the symbol itself with a REQUEST_SYMBOL() of a second symbol. Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-08-11[zbin] Change fixup semantics to support ROMs over 128k uncompressedJoshua Oreman1-9/+0
The option ROM header contains a one-byte field indicating the number of 512-byte sectors in the ROM image. Currently it is linked to contain the number of uncompressed sectors, with an instruction to the compressor to correct it. This causes link failure when the uncompressed size of the ROM image is over 128k. Fix by replacing the SUBx compressor fixup with an ADDx fixup that adds the total compressed output length, scaled as requested, to an addend stored in the field where the final length value will be placed. This is similar to the behavior of ELF relocations, and ensures that an overflow error will not be generated unless the compressed size is still too large for the field. This also allows us to do away with the _filesz_pgh and _filesz_sect calculations exported by the linker script. Output tested bitwise identical to the old SUBx mechanism on hd, dsk, lkrn, and rom prefixes, on both 32-bit and 64-bit processors. Modified-by: Michael Brown <mcb30@etherboot.org> Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-01-07[efi] Use elf2efi utility in place of efilinkMichael Brown1-180/+0
elf2efi converts a suitable ELF executable (containing relocation information, and with appropriate virtual addresses) into an EFI executable. It is less tightly coupled with the gPXE build process and, in particular, does not require the use of a hand-crafted PE image header in efiprefix.S. elf2efi correctly handles .bss sections, which significantly reduces the size of the gPXE EFI executable.
2008-11-17[build] Fix calculation of _fileszMichael Brown1-6/+6
_filesz was incorrectly forced to be aligned up to MAX_ALIGN. In a non-compressed build, this would cause a build failure unless _filesz happened to already be aligned to MAX_ALIGN.
2008-11-18[build] Discard junk sections created by newer gcc versionsMichael Brown2-0/+12
2008-10-17[build] Use ".bss.*" names for uninitialised-data sectionsMichael Brown2-11/+11
The section name seems to have significance for some versions of binutils. There is no way to instruct gcc that sections such as .bss16 contain uninitialised data; it will emit them with contents explicitly set to zero. We therefore have to rely on the linker script to force these sections to become uninitialised-data sections. We do this by marking them as NOLOAD; this seems to be the closest semantic equivalent in the linker script language. However, this gets ignored by some versions of ld (including 2.17 as shipped with Debian Etch), which mark the resulting sections with (CONTENTS,ALLOC,LOAD,DATA). Combined with the fact that this version of ld seems to ignore the specified LMA for these sections, this means that they end up overlapping other sections, and so parts of .prefix (for example) get obliterated by .data16's bss section. Rename the .bss sections from .section_bss to .bss.section; this seems to cause these versions of ld to treat them as uninitialised data.
2008-10-17[build] Fix building on Ubuntu 8.04Michael Brown1-6/+8
Not fully understood, but it seems that the LMA of bss sections matters for some newer binutils builds. Force all bss sections to have an LMA at the end of the file, so that they don't interfere with other sections. The symptom was that objcopy -O binary -j .zinfo would extract the .zinfo section from bin/xxx.tmp as a blob of the correct length, but with zero contents. This would then cause the [ZBIN] stage of the build to fail. Also explicitly state that .zinfo(.*) sections have @progbits, in case some future assembler or linker variant decides to omit them.
2008-10-13[efi] Fix linker script for ld 2.17.50.0.9Michael Brown1-6/+6
Some versions of ld choke on the "AT ( _xxx_lma )" in efi.lds with an error saying "nonconstant expression for load base". Since these were only explicitly setting the LMA to the address that it would have had anyway, they can be safely omitted.
2008-10-13[efi] Add EFI image format and basic runtime environmentMichael Brown1-0/+174
We have EFI APIs for CPU I/O, PCI I/O, timers, console I/O, user access and user memory allocation. EFI executables are created using the vanilla GNU toolchain, with the EXE header handcrafted in assembly and relocations generated by a custom efilink utility.
2008-10-10[i386] Simplify linker script and standardise linker-defined symbol namesMichael Brown1-177/+94
Reduce the number of sections within the linker script to match the number of practical sections within the output file. Define _section, _msection, _esection, _section_filesz, _section_memsz, and _section_lma for each section, replacing the mixture of symbols that previously existed. In particular, replace _text and _end with _textdata and _etextdata, to make it explicit within code that uses these symbols that the .text and .data sections are always treated as a single contiguous block.
2008-09-06[pxe] Add a dummy PXENV+ entry point at UNDI_CS:0000Michael Brown1-1/+3
Wyse Streaming Manager server (WLDRM13.BIN) assumes that the PXENV+ entry point is at UNDI_CS:0000; apparently, somebody at Wyse has difficulty distinguishing between the words "may" and "must"... Add a dummy entry point at UNDI_CS:0000, which just jumps to the correct entry point.
2008-08-28[pxe] Fill in UNDIROMID pointer in !PXE structureMichael Brown1-0/+10
IBM's iSCSI Firmware Initiator checks the UNDIROMID pointer in the !PXE structure that gets created by the UNDI loader. We didn't previously fill this value in.
2008-08-18[pcbios] Support arbitrary splits of the e820 memory mapMichael Brown1-1/+0
Allow for an arbitrary number of splits of the system memory map via INT 15,e820. Features of the new map-mangling algorithm include: Supports random access to e820 map entries. Requires only sequential access support from the underlying e820 map, even if our caller uses random access. Empty regions will always be stripped. Always terminates with %ebx=0, even if the underlying map terminates with CF=1. Allows for an arbitrary number of hidden regions, with underlying regions split into as many subregions as necessary. Total size increase to achieve this is 193 bytes.
2008-08-18[pcbios] Prepare for multiple splits of hidden e820 memory regionsMichael Brown1-0/+1
Define a list of N allowed memory regions, and split each underlying e820 region into up to N subregions. Strip resulting empty regions out of the map, avoiding using the "return with CF set to strip last empty region" trick, because it seems that bootmgr.exe in Win2k8 gets upset if the memory map is terminated with CF set. This is an intermediate checkin that defines a single allowed memory region covering the entire 64-bit address space, and uses the existing map-mangling code on top of the new region-splitting code. This sanitises the memory map to the point that Win2k8 is able to boot even on a system that defines a final zero-length region at the 4GB mark. I'm checking this in because it may be useful for future debugging efforts to be able to run with the existing and known-working map mangling code together with the map sanitisation capabilities of the new map mangling code.
2008-03-09[PXE] Add PMM support to romprefix.S (untested)Michael Brown1-0/+2
ROM initialisation vector now attempts to allocate a 2MB block using PMM. If successful, it copies the ROM image to this block, then shrinks the ROM image to allow for more option ROMs. If unsuccessful, it leaves the ROM as-is. ROM BEV now attempts to return to the BIOS, resorting to INT 18 only if the BIOS stack has been corrupted.
2007-12-07Remove the (unused) option to override _prefix_link_addr,Michael Brown1-14/+4
_textdata_link_addr, _load_addr and _max_align in the linker scripts. A bug in some versions of ld causes segfaults if the DEFINED() macro is used in a linker script *and* the -Map option to ld is present. We don't currently need to override any of these values; if we need to do so in future then the solution will probably be to always specify the values on the ld command line, and have the linker script not define them at all.
2007-07-16Update all prefixes currently referring to _load_size to include aMichael Brown1-0/+6
compressor fixup section.
2007-07-16Rename _rom_size to _load_size_sect, since hdprefix.S also uses it.Michael Brown2-2/+2
2007-07-16Compressed ROM images now work.Michael Brown1-0/+25
2007-07-15Use a single _payload_offset linker-defined variable to locate theMichael Brown1-0/+2
start of the non-prefix blocks in the loaded image, and rely on the image ordering. This should make introducing compression much easier.
2007-03-11Make _load_size accurately reflect the number of bytes in the actualMichael Brown1-2/+0
image file.
2006-12-20Prevent NULL from ever pointing to some real code or data. (This wasMichael Brown2-0/+10
causing the serial console to ignore input, because it happened to end up linked with serial_ischar() at address 0, which core/console.c decided was invalid).
2006-08-24Towards making KEEP_IT_REAL work again.Michael Brown2-2/+196
Fix bug that caused over-allocation of .text16 and .data16 memory areas by a factor of 16.
2006-06-11Added null trap code for debugging. (Must be included by addingMichael Brown1-0/+1
--nulltrap to the make target at the moment.)
2006-06-06Calculate _rom_size for the ROM prefixMichael Brown1-0/+1
2006-05-02Create two easy-to-use entry points in libprefix: install andMichael Brown1-16/+21
install_prealloc. I *think* these will suffice for all the 16-bit prefixes.
2006-05-02Towards a(nother) new real-mode infrastructure, in which we takeMichael Brown1-96/+79
advantage of the fact that we have to have a permanently-resident block in base memory.
2005-04-27isa.c uses the new table infrastructure.Michael Brown1-9/+1
2005-04-27dev.c uses the new tables infrastructure.Michael Brown1-9/+0
2005-04-27Post-relocation functions use the generic table mechanism.Michael Brown1-3/+0