summaryrefslogtreecommitdiffstats
path: root/src/util/elf2efi.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] Handle R_X86_64_PLT32 from binutils 2.31Christian Hesse2018-09-171-0/+1
| | | | | | | | Starting from binutils 2.31.0 (commit bd7ab16b) x86-64 assembler generates R_X86_64_PLT32 instead of R_X86_64_PC32. Acked-by: John Jolly <jjolly@suse.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add support for R_ARM_REL32 relocationsHeinrich Schuchardt2018-03-281-0/+1
| | | | | | | | | | | The relocation type R_ARM_REL32 is generated when building bin-arm32-efi/snp.efi using gcc 6.3 and ld 2.28. R_ARM_REL32 is a program counter (PC) relative 32 bit relocation so we can ignore it like all other PC relative relocations. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow for building with older versions of elf.h system headerMichael Brown2017-09-241-0/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Accept (and ignore) R_ARM_V4BX relocationsHeinrich Schuchardt2017-09-241-0/+1
| | | | | | | | | 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>
* [efi] Fix building elf2efi.c when -fpic is enabled by defaultMichael Brown2017-01-251-1/+1
| | | | | | | | | | | | | | | 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>
* [efi] Allow for building with older versions of elf.h system headerMichael Brown2016-05-091-0/+22
| | | | | Reported-by: Ahmad Mahagna <ahmhad@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [arm] Add support for 64-bit ARM (Aarch64)Michael Brown2016-05-081-0/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [arm] Add support for 32-bit ARMMichael Brown2016-05-061-47/+63
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Eliminate use of libbfdMichael Brown2016-05-021-169/+294
| | | | | | | | | 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>
* [efi] Work around broken 32-bit PE executable parsing in ImageHlp.dllMichael Brown2015-09-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Minimise use of iPXE header files when building host utilitiesMichael Brown2015-09-151-1/+2
| | | | | | | | | | 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>
* [efi] Populate debug directory entry FileOffset fieldMichael Brown2015-09-011-0/+19
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Fix debug directory sizeMichael Brown2015-09-011-1/+1
| | | | | | | | | 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>
* [build] Fix the REQUIRE_SYMBOL mechanismMichael Brown2015-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Disallow R_X86_64_32 relocationsMichael Brown2015-02-121-2/+1Star
| | | | | | | | | | | | | | | | | 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>
* [efi] Fix building with newer binutilsMichael Brown2013-03-141-0/+2
| | | | | | | | | | 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>
* [efi] Ensure EFI binaries comply with Authenticode requirementsMichael Brown2013-02-251-1/+4
| | | | | | | | 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>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-201-1/+2
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Fix compiler warning in elf2efi.cMichael Brown2012-04-211-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Enable warnings when building utilitiesMichael Brown2012-04-101-3/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Fix the 32-bit version of elf2efi64Geoff Lywood2010-07-211-10/+10
| | | | | | | | | | | | | | | | | | | Currently, if elf2efi.c is compiled using a 32-bit HOST_CC, then the resulting elf2efi64 binary will generate 32-bit EFI binaries instead of 64-bit EFI binaries. The problem is that elf2efi.c uses the MDE_CPU_* definitions to decide whether to output a 32-bit or 64-bit PE binary. However, MDE_CPU_* gets defined in ProcessorBind.h, depending on the compiler's target architecture. Overriding them on the command line doesn't work in the expected way, and you can end up in cases where both MDE_CPU_IA32 and MDE_CPU_X64 are defined. Fix by using a separate definition, EFI_TARGET_IA32/EFI_TARGET_X64, which is specified only on the command line. Signed-off-by: Geoff Lywood <glywood@vmware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Verify object format support in elf2efi.cGeoff Lywood2010-05-271-2/+3
| | | | | | | | | | Currently, if you attempt to build 64-bit EFI binaries on a 32-bit system without a suitable cross-compiling version of libbfd, the iPXE build will die with a segmentation fault in elf2efi64. Fix by properly handling the return value from bfd_check_format(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-2/+2
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use POSIX version of basename() in elf2efi.cMichael Brown2009-03-311-1/+6
| | | | | | This is required in order to build on Mac OS X. Suggested-by: Joshua Oreman <oremanj@rwcr.net>
* [efi] Add efirom utility and .efirom image formatMichael Brown2009-01-081-42/+2Star
|
* [efi] Allow for .efidrv images as well as .efi imagesMichael Brown2009-01-081-14/+93
| | | | | | Merge in the changes that allow for building EFI driver images (that can be loaded using the EFI shell's "load" command) as well as EFI applications.
* [efi] Use elf2efi utility in place of efilinkMichael Brown2009-01-071-0/+764
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.