david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

160 Commits

Author SHA1 Message Date
Michael Brown 1b67a05646 [efi] Allow for building with older versions of elf.h system header
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-24 19:26:58 +01:00
Heinrich Schuchardt c4ce92599d [efi] Accept (and ignore) R_ARM_V4BX relocations
Relocation type R_ARM_V4BX requires no computation.  It marks the
location of an ARMv4 branch exchange instruction.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-24 18:03:10 +01:00
Michael Brown 941c53a3bf [efi] Fix building elf2efi.c when -fpic is enabled by default
The x86_64 EDK2 headers include a #pragma to mark all subsequent
symbol declarations and references as hidden if position-independent
code is being generated.  Since libgen.h is currently included only
after the EDK2 headers, this results in __xpg_basename() being
erroneously marked as having hidden visibility (if the compiler
defaults to building position-independent code); this eventually
results in a failure to link the elf2efi binary.

Fix by including libgen.h prior to including the EDK2 headers.

Originally-fixed-by: Doug Goldstein <cardoe@cardoe.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-01-25 08:15:21 +00:00
Vinson Lee f6e8b800be [build] Remove nested "my" declaration
Fix build error with perl >= 5.23.2:

  Can't redeclare "my" in "my" at ./util/parserom.pl line 160

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-03 18:09:54 +01:00
Michael Brown 45cd68c0fb [efi] Allow for building with older versions of elf.h system header
Reported-by: Ahmad Mahagna <ahmhad@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-09 16:18:10 +01:00
Michael Brown 17c6f322ee [arm] Add support for 64-bit ARM (Aarch64)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-08 00:20:20 +01:00
Michael Brown 1a16f67a28 [arm] Add support for 32-bit ARM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-06 12:08:44 +01:00
Michael Brown efd5cf9aad [efi] Eliminate use of libbfd
Parse the intermediate ELF file directly instead of using libbfd, in
order to allow for cross-compiled ELF objects.

As a side bonus, this eliminates libbfd as a build requirement.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-02 22:35:14 +01:00
Michael Brown c4e8c40227 [prefix] Use CRC32 to verify each block prior to decompression
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-24 16:52:26 +00:00
Michael Brown 7f65a08f3e [efi] Add %.usb target for building EFI-bootable USB (or other) disk images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-12-07 13:08:22 +00:00
Michael Brown 7b976dd300 [efi] Work around broken 32-bit PE executable parsing in ImageHlp.dll
The Microsoft PE/COFF specification defines the MajorLinkerVersion and
MinorLinkerVersion fields as "The linker major version number" and
"The linker minor version number" respectively, and has nothing more
to say on the matter.  These fields have no significance: they do not
affect the interpretation of the remainder of the file, but merely
provide diagnostic information for interested humans to read.

Apparently, versions 2.4 and earlier of the Microsoft linker produced
binaries so incorrigibly cursed that even to attempt to parse such a
binary would risk summoning a plague of enraged spiders.  To protect
users from unwanted arachnids, ImageHlp.dll's MapAndLoad() function
will helpfully fail to map and/or load a 32-bit binary unless the
linker version field indicates version 2.5 or later.  (64-bit binaries
are exempt from such helpfulness.)

Work around the broken Microsoft ImageHlp.dll library by providing a
linker version number that will satisfy the arbitrary whims of the
MapAndLoad() function.

This mirrors wimboot commit 670c7e2 ("[efi] Work around broken 32-bit
PE executable parsing in ImageHlp.dll").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-25 13:41:32 +01:00
Michael Brown fdad22a1ed [efi] Minimise use of iPXE header files when building host utilities
Avoid dragging in unnecessary iPXE header files such as <ipxe/uuid.h>
and <ipxe/tables.h> when building host utilities, and ensure that
FILE_LICENCE() (present in the imported EDK2 headers) expands to a
no-op.

Reported-by: Michael Tautschnig <mt@debian.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-14 23:29:24 +01:00
Michael Brown f6e1da5cbf [build] Search for ldlinux.c32 separately from isolinux.bin
Some distributions (observed with Ubuntu 15.04) place ldlinux.c32 in a
separate directory from isolinux.bin.  Search for these files
separately, and allow an alternative location of ldlinux.c32 to be
provided via LDLINUX_C32=... on the make command line.

Reported-by: Adrian Koshka <adriankoshcha@teknik.io>
Tested-by: Adrian Koshka <adriankoshcha@teknik.io>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 21:04:44 +01:00
Michael Brown 619a377328 [efi] Populate debug directory entry FileOffset field
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 01:35:03 +01:00
Michael Brown ed609c4889 [efi] Fix debug directory size
The debug directory size specified in the data directory should cover
only the EFI_IMAGE_DEBUG_DIRECTORY_ENTRY structure, not the whole of
the .debug section.

Reported-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 01:35:03 +01:00
Michael Brown 25d6c80498 [build] Fix .ids.o creation for drivers not in the all-drivers build
Commit dc19e63 ("[build] Construct all-drivers list based on driver
class") accidentally excluded the USB bus drivers from the list of
files parsed in order to create PCI 3.0 device ID lists.

Fix by returning $(DRIVERS) to its previous definition as a list of
all driver files, and use only $(DRIVERS_ipxe) to contain the
filtered list containing only those drivers which we want to include
in the "all-drivers" build.

Reported-by: Mary-Ann Johnson <MaryAnn.Johnson@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-01 16:55:57 +01:00
Michael Brown dc19e630cb [build] Construct all-drivers list based on driver class
The USB bus drivers (ehci.c and xhci.c) have PCI device ID tables and
hence PCI_ROM() lines, but should probably not be included in the
all-drivers build on this basis, since they do nothing useful unless a
USB network driver is also present.

Fix by constructing the all-drivers list based on the driver class
(i.e. the portion of the source path immediately after "drivers/").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-22 12:21:14 +01:00
Michael Brown 452aa157be [util] Add ability to dump PCI device ID list
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-13 16:22:35 +01:00
Robin Smidsrød 68d8a44469 [build] Rewrite parserom.pl to support multiple source files
Running util/parserom.pl on all source files (637) one by one takes
approximately 35 seconds because of the startup cost of each invocation.
With the utility rewritten to support multiple source files it now takes
approximately 1 second to scan all source files for ROM declarations.

The --exclude-driver and --exclude-driver-class options have been added,
making it possible to skip certain source files from being scanned at all.

In addition --debug option has been added to more easily trace progress.

Finally --help option was added to show usage information.

Signed-off-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-13 12:37:30 +01:00
Michael Brown fbc4ba4b4e [build] Fix the REQUIRE_SYMBOL mechanism
At some point in the past few years, binutils became more aggressive
at removing unused symbols.  To function as a symbol requirement, a
relocation record must now be in a section marked with @progbits and
must not be in a section which gets discarded during the link (either
via --gc-sections or via /DISCARD/).

Update REQUIRE_SYMBOL() to generate relocation records meeting these
criteria.  To minimise the impact upon the final binary size, we use
existing symbols (specified via the REQUIRING_SYMBOL() macro) as the
relocation targets where possible.  We use R_386_NONE or R_X86_64_NONE
relocation types to prevent any actual unwanted relocation taking
place.  Where no suitable symbol exists for REQUIRING_SYMBOL() (such
as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to
generate a one-byte-long symbol to act as the relocation target.

If there are versions of binutils for which this approach fails, then
the fallback will probably involve killing off REQUEST_SYMBOL(),
redefining REQUIRE_SYMBOL() to use the current definition of
REQUEST_SYMBOL(), and postprocessing the linked ELF file with
something along the lines of "nm -u | wc -l" to check that there are
no undefined symbols remaining.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 00:59:38 +00:00
Michael Brown d454d98d35 [legal] Add UBDL relicensing tool
The UBDL relicensing tool (util/relicense.pl) is designed to identify
files which may be relicensed under a dual GPL+UBDL licence.  It uses
git-blame to identify the author of each line (using the -M and -C
options to track lines moved or copied between files), and relicenses
files for which all authors have given permission.

The relicensing tool will ignore certain types of lines identified by
git-blame:

 - empty lines
 - comments
 - standalone opening or closing braces
 - "#include ..."
 - "return 0;"
 - "return rc;"
 - "PCI_ROM(...)"
 - "FILE_LICENCE(...)"

These lines either contain no meaningful content (e.g. empty lines),
contain only non-copyrightable facts (e.g. PCI ROM IDs) or are
sufficiently common within the codebase that git-blame is likely to
misattribute their origin (e.g. "return 0").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:17:24 +00:00
Michael Brown 2782ccec41 [legal] Add support for the Unmodified Binary Distribution Licence
Add the text for the Unmodified Binary Distribution Licence.  This
Licence allows for the distribution of unmodified binaries built from
publicly available source code, without imposing the obligations of
the GNU General Public License upon anyone who chooses to distribute
only the unmodified binaries built from that source code.  See the
licence text for the precise terms and conditions.

Add the licence GPL2_OR_LATER_OR_UBDL to the set of licences which can
be declared using FILE_LICENCE(), and add the corresponding support to
licence.pl.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 12:07:14 +00:00
Michael Brown 5350b65a3c [zbin] Use LZMA compression
LZMA provides significantly better compression (by ~15%) than the
current NRV2B algorithm.

We use a raw LZMA stream (aka LZMA1) to avoid the need for code to
parse the LZMA2 block headers.  We use parameters {lc=2,lp=0,pb=0} to
reduce the stack space required by the decompressor to acceptable
levels (around 8kB).  Using lc=3 or pb=2 would give marginally better
compression, but at the cost of substantially increasing the required
stack space.

The build process now requires the liblzma headers to be present on
the build system, since we do not include a copy of an LZMA compressor
within the iPXE source tree.  The decompressor is written from scratch
(based on XZ Embedded) and is entirely self-contained within the
iPXE source.

The branch-call-jump (BCJ) filter used to improve the compressibility
is specific to iPXE.  We choose not to use liblzma's built-in BCJ
filter since the algorithm is complex and undocumented.  Our BCJ
filter achieves approximately the same results (on typical iPXE
binaries) with a substantially simpler algorithm.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-25 14:06:13 +00:00
Michael Brown 907cffb7c5 [efi] Disallow R_X86_64_32 relocations
UEFI binaries may be relocated to any location within the 64-bit
address space.  We compile as position-independent code with hidden
visibility, which should force all relocation records to be either
PC-relative (in which case no PE relocations are required) or full
64-bit relocations.  There should be no R_X86_64_32 relocation
records, since that would imply an invalid assumption that code could
not be relocated above 4GB.

Remove support for R_X86_64_32 relocation records from util/elf2efi.c,
so that any such records result in a build failure rather than a
potential runtime failure.

Reported-by: Jan Kundrát <jkt@kde.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-12 13:39:25 +00:00
Michael Brown 5de37e124f [efi] Add efifatbin utility
Add utility for constructing EFI fat binaries (dual 32/64-bit
binaries, usable only on Apple EFI systems).

This utility is not part of the standard build process.  To use it:

  make util/efifatbin bin-i386-efi/ipxe.efi bin-x86_64-efi/ipxe.efi

and then

  ./util/efifatbin bin-*-efi/ipxe.efi fat-ipxe.efi

Requested-by: Brandon Penglase <bpenglase-ipxe@spaceservices.net>
Tested-by: Brandon Penglase <bpenglase-ipxe@spaceservices.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-10 03:12:10 +01:00
Michael Brown ee0c24902a [util] Use PCI length field to obtain length of individual images
Option::ROM currently uses the initialisation length field (single
byte at offset 0x02) to determine the length of a ROM image within a
multi-image ROM file.  For PCI ROM images with a code type other than
0, the initialisation length field may not be present.

Fix by using the PCI header's image length field instead.  Note that
this does not prevent us from correctly handling ISA ROMs, since ISA
ROMs do not support multiple images within a single ROM BAR anyway.

Inspired-by: Swift Geek <swiftgeek@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-26 15:17:56 +01:00
Christian Hesse a8f037a275 [build] Merge util/geniso and util/genliso
Rework geniso and genliso to provide a single merged utility for
generating ISO images.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-14 16:00:58 +01:00
Michael Brown 779d65222e [build] Avoid errors when build directory is mounted via NFS
Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-13 16:45:57 +01:00
Christian Hesse 1680d0d14d [build] Fix LABEL name for .liso images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 17:12:57 +00:00
Christian Hesse 3f9a482b88 [build] Update build system for Syslinux 6.x
Syslinux 6.x places its files into a bios subdirectory, and requires
that a ldlinux.c32 module be included within the ISO image.  Add the
relevant search paths for isolinux.bin, and include the file
ldlinux.c32 within the ISO image if it exists.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-15 11:59:44 +00:00
Michael Brown 7348035231 [libc] Redefine low 8 bits of error code as "platform error code"
The low 8 bits of an iPXE error code are currently defined as the
closest equivalent PXE error code.  Generalise this scheme to
platforms other than PC-BIOS by extending this definition to "closest
equivalent platform error code".  This allows for the possibility of
returning meaningful errors via EFI APIs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:13 +01:00
Michael Brown e63f6c9241 [efi] Fix building with newer binutils
Newer versions of bfd.h require definitions for the PACKAGE and
PACKAGE_VERSION macros used by autotools.  Work around this by
manually defining these macros before including bfd.h.

Originally-fixed-by: Brandon Penglase <bpenglase-ipxe@spaceservices.net>
Tested-by: Brandon Penglase <bpenglase-ipxe@spaceservices.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-14 00:20:04 +00:00
Daniel P. Berrange eb5a2ba596 [zbin] Fix size used for memset in alloc_output_file
The output->buf field is a pointer, not an array, so sizeof() is not
applicable.  We must use the allocated string length instead.

Identified by gcc:

  util/zbin.c: In function ‘alloc_output_file’:
  util/zbin.c:146:37: warning: argument to ‘sizeof’ in ‘memset’ call
    is the same expression as the destination; did you mean to
    dereference it? [-Wsizeof-pointer-memaccess]
  memset ( output->buf, 0xff, sizeof ( output->buf ) );

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-05 15:23:01 +00:00
Michael Brown 09c5109b85 [efi] Ensure EFI binaries comply with Authenticode requirements
Authenticode requires that the size of the raw file must equal the
size of the OptionalHeader.SizeOfHeaders plus the sum of all sections'
SizeOfRawData.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-02-25 17:22:01 +00:00
Michael Brown a27413c82a [util] Fix uninitialised-variable warning in einfo.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-22 08:26:43 -07:00
Michael Brown c7eea31ed8 [util] Fix up checksum in UNDI ROM header, if present
The UNDI ROM header does contain a checksum byte.  Apparently no-one
cares about this, since iPXE has left it as zero for years without
anyone noticing.

Since Option::ROM now understands the UNDI ROM header, we may as well
fix up the checksum byte for the sake of completeness.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-15 13:22:12 +01:00
Michael Brown 69fa494280 [util] Display UNDI ROM header in disrom.pl
Requested-by: Daniel Wyatt <daniel.wyatt@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-15 13:19:16 +01:00
Daniel Wyatt 37ac7a666f [util] Allow for CALL NEAR in the option ROM initialisation entry point
Option::ROM currently understands only JMP NEAR and JMP SHORT
instructions in the initialisation entry point.  At least one Broadcom
option ROM has been observed to use a CALL NEAR instruction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-15 12:51:47 +01:00
Michael Brown 8cac5c0c92 [util] Update mergerom.pl to handle iPXE ROM header
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 18:05:01 +01:00
Michael Brown 5de45cd3da [romprefix] Report a pessimistic runtime size estimate
PCI3.0 allows us to report a "runtime size" which can be smaller than
the actual ROM size.  On systems that support PMM our runtime size
will be small (~2.5kB), which helps to conserve the limited option ROM
space.  However, there is no guarantee that the PMM allocation will
succeed, and so we need to report the worst-case runtime size in the
PCI header.

Move the "shrunk ROM size" field from the PCI header to a new "iPXE
ROM header", allowing it to be accessed by ROM-manipulation utilities
such as disrom.pl.

Reported-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-23 17:57:40 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown bc93e8ab41 [util] Avoid compiler warning on gcc 4.6
Commit 196751c ("[build] Enable warnings when building utilities")
revealed a previously hidden compiler warning in util/nrv2b.c
regarding an out-of-bounds array subscript in the code

    #if defined(SWD_BEST_OFF)
        if (s->best_pos[2] == 0)
            s->best_pos[2] = key + 1;
    #endif

where best_pos[] is defined by

    #define SWD_BEST_OFF 1

    #if defined(SWD_BEST_OFF)
        unsigned int best_off[ SWD_BEST_OFF ];
        unsigned int best_pos[ SWD_BEST_OFF ];
    #endif

With SWD_BEST_OFF set to 1, it can be proven that all code paths
referring to s->best_off[] and s->best_pos[] will never be executed,
with the exception of the two lines above.  Since these two lines
alone can have no effect on execution, we can safely undefine
SWD_BEST_OFF.

Verified by comparing md5sums of bin/undionly.kpxe before and after
the change.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-03 18:58:43 +01:00
Michael Brown a3cba84bab [util] Update mergerom.pl to handle .mrom images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 15:15:06 +01:00
Michael Brown 9e8d431a0d [romprefix] Add a dummy ROM header to cover the .mrom payload
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>
2012-06-12 15:15:03 +01:00
Michael Brown 12be8bc544 [util] Rewrite catrom.pl to use Option::ROM library
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 11:36:21 +01:00
Michael Brown f2e5f8813e [util] Allow Option::ROM to access multiple ROM images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-12 11:36:20 +01:00
Marin Hannache 8c42e0c210 [util] Remove obsolete Makefile rule for util/prototester.c
util/prototester.c was removed in commit a6d1815 ("Obsolete for some
time now") back in 2006.

Signed-off-by: Marin Hannache <mareo@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-24 11:45:24 +01:00
Michael Brown 8b0305e285 [efi] Fix compiler warning in elf2efi.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-21 08:05:24 +01:00
Robin Smidsrød eadb6bc3fe [util] Add utility to generate list of supported network cards
niclist.pl recursively scans specified source folders and builds a
list of supported NICs by looking for ISA_ROM and PCI_ROM lines and
outputs the list in text, CSV, JSON, HTML or DokuWiki format.  Sorting
and column selection is possible.

The pci-utils pci.ids file is fetched from SourceForge once a day to
also output the "official" vendor/device names associated with the PCI
device.

Signed-off-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-18 10:38:22 +01:00
Michael Brown 196751ce95 [build] Enable warnings when building utilities
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-10 19:38:54 +01:00