]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Verify object format support in elf2efi.c
authorGeoff Lywood <glywood@vmware.com>
Thu, 27 May 2010 00:04:12 +0000 (17:04 -0700)
committerMichael Brown <mcb30@ipxe.org>
Thu, 27 May 2010 08:17:37 +0000 (09:17 +0100)
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>
src/util/elf2efi.c

index 7870bb901ae68e5ef46e216b6d186295526690d9..1d73807e9f82b96ecdf9510aa8fff8a6d64952c2 100644 (file)
@@ -247,8 +247,9 @@ static bfd * open_input_bfd ( const char *filename ) {
        /* The call to bfd_check_format() must be present, otherwise
         * we get a segfault from later BFD calls.
         */
-       if ( bfd_check_format ( bfd, bfd_object ) < 0 ) {
-               eprintf ( "%s is not an object file\n", filename );
+       if ( ! bfd_check_format ( bfd, bfd_object ) ) {
+               eprintf ( "%s is not an object file: ", filename );
+               bfd_perror ( NULL );
                exit ( 1 );
        }