]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[multiboot] Use image name in Multiboot and ELF debug messages
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 11:59:25 +0000 (12:59 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 11:59:25 +0000 (12:59 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/image/elfboot.c
src/arch/x86/image/multiboot.c
src/image/elf.c

index dc35689293e5df097655029b1d409a1c0d0ff3b7..8d167ef4d919386aad805cd38a047105d001b1c2 100644 (file)
@@ -52,8 +52,8 @@ static int elfboot_exec ( struct image *image ) {
 
        /* Load the image using core ELF support */
        if ( ( rc = elf_load ( image, &entry, &max ) ) != 0 ) {
-               DBGC ( image, "ELF %p could not load: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "ELF %s could not load: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -63,14 +63,15 @@ static int elfboot_exec ( struct image *image ) {
        shutdown_boot();
 
        /* Jump to OS with flat physical addressing */
-       DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );
+       DBGC ( image, "ELF %s starting execution at %lx\n",
+              image->name, entry );
        __asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
                                           "call *%%edi\n\t"
                                           "popl %%ebp\n\t" /* gcc bug */ )
                               : : "D" ( entry )
                               : "eax", "ebx", "ecx", "edx", "esi", "memory" );
 
-       DBGC ( image, "ELF %p returned\n", image );
+       DBGC ( image, "ELF %s returned\n", image->name );
 
        /* It isn't safe to continue after calling shutdown() */
        while ( 1 ) {}
@@ -91,8 +92,8 @@ static int elfboot_check_segment ( struct image *image, Elf_Phdr *phdr,
 
        /* Check that ELF segment uses flat physical addressing */
        if ( phdr->p_vaddr != dest ) {
-               DBGC ( image, "ELF %p uses virtual addressing (phys %x, "
-                      "virt %x)\n", image, phdr->p_paddr, phdr->p_vaddr );
+               DBGC ( image, "ELF %s uses virtual addressing (phys %x, virt "
+                      "%x)\n", image->name, phdr->p_paddr, phdr->p_vaddr );
                return -ENOEXEC;
        }
 
@@ -123,14 +124,15 @@ static int elfboot_probe ( struct image *image ) {
        /* Read ELF header */
        copy_from_user ( &ehdr, image->data, 0, sizeof ( ehdr ) );
        if ( memcmp ( ehdr.e_ident, e_ident, sizeof ( e_ident ) ) != 0 ) {
-               DBGC ( image, "Invalid ELF identifier\n" );
+               DBGC ( image, "ELF %s invalid identifier\n", image->name );
                return -ENOEXEC;
        }
 
        /* Check that this image uses flat physical addressing */
        if ( ( rc = elf_segments ( image, &ehdr, elfboot_check_segment,
                                   &entry, &max ) ) != 0 ) {
-               DBGC ( image, "Unloadable ELF image\n" );
+               DBGC ( image, "ELF %s is not loadable: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
index 24f67e02fef615384353a28e0b0456f808490b46..b23cf9ddc3ec85d77d9acde5723968e7254a7517 100644 (file)
@@ -124,8 +124,8 @@ static void multiboot_build_memmap ( struct image *image,
        memset ( mbmemmap, 0, sizeof ( *mbmemmap ) );
        for ( i = 0 ; i < memmap.count ; i++ ) {
                if ( i >= limit ) {
-                       DBGC ( image, "MULTIBOOT %p limit of %d memmap "
-                              "entries reached\n", image, limit );
+                       DBGC ( image, "MULTIBOOT %s limit of %d memmap "
+                              "entries reached\n", image->name, limit );
                        break;
                }
                mbmemmap[i].size = ( sizeof ( mbmemmap[i] ) -
@@ -199,8 +199,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
        for_each_image ( module_image ) {
 
                if ( mbinfo->mods_count >= limit ) {
-                       DBGC ( image, "MULTIBOOT %p limit of %d modules "
-                              "reached\n", image, limit );
+                       DBGC ( image, "MULTIBOOT %s limit of %d modules "
+                              "reached\n", image->name, limit );
                        break;
                }
 
@@ -215,8 +215,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
                if ( ( rc = prep_segment ( phys_to_virt ( start ),
                                           module_image->len,
                                           module_image->len ) ) != 0 ) {
-                       DBGC ( image, "MULTIBOOT %p could not prepare module "
-                              "%s: %s\n", image, module_image->name,
+                       DBGC ( image, "MULTIBOOT %s could not prepare module "
+                              "%s: %s\n", image->name, module_image->name,
                               strerror ( rc ) );
                        return rc;
                }
@@ -231,8 +231,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
                module->mod_end = ( start + module_image->len );
                module->string = multiboot_add_cmdline ( module_image );
                module->reserved = 0;
-               DBGC ( image, "MULTIBOOT %p module %s is [%x,%x)\n",
-                      image, module_image->name, module->mod_start,
+               DBGC ( image, "MULTIBOOT %s module %s is [%x,%x)\n",
+                      image->name, module_image->name, module->mod_start,
                       module->mod_end );
                start += module_image->len;
        }
@@ -330,8 +330,8 @@ static int multiboot_load_raw ( struct image *image,
 
        /* Sanity check */
        if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
-               DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
-                      image );
+               DBGC ( image, "MULTIBOOT %s is not flagged as a raw image\n",
+                      image->name );
                return -EINVAL;
        }
 
@@ -344,8 +344,8 @@ static int multiboot_load_raw ( struct image *image,
                  ( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
        buffer = phys_to_virt ( hdr->mb.load_addr );
        if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
-               DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "MULTIBOOT %s could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -373,8 +373,8 @@ static int multiboot_load_elf ( struct image *image, physaddr_t *entry,
 
        /* Load ELF image*/
        if ( ( rc = elf_load ( image, entry, max ) ) != 0 ) {
-               DBGC ( image, "MULTIBOOT %p ELF image failed to load: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "MULTIBOOT %s ELF image failed to load: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -395,15 +395,15 @@ static int multiboot_exec ( struct image *image ) {
 
        /* Locate multiboot header, if present */
        if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
-               DBGC ( image, "MULTIBOOT %p has no multiboot header\n",
-                      image );
+               DBGC ( image, "MULTIBOOT %s has no multiboot header\n",
+                      image->name );
                return rc;
        }
 
        /* Abort if we detect flags that we cannot support */
        if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
-               DBGC ( image, "MULTIBOOT %p flags %08x not supported\n",
-                      image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
+               DBGC ( image, "MULTIBOOT %s flags %08x not supported\n",
+                      image->name, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
                return -ENOTSUP;
        }
 
@@ -444,8 +444,8 @@ static int multiboot_exec ( struct image *image ) {
                                 ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
 
        /* Jump to OS with flat physical addressing */
-       DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
-              image, entry );
+       DBGC ( image, "MULTIBOOT %s starting execution at %lx\n",
+              image->name, entry );
        __asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
                                           "call *%%edi\n\t"
                                           "popl %%ebp\n\t" )
@@ -454,7 +454,7 @@ static int multiboot_exec ( struct image *image ) {
                                   "D" ( entry )
                               : "ecx", "edx", "esi", "memory" );
 
-       DBGC ( image, "MULTIBOOT %p returned\n", image );
+       DBGC ( image, "MULTIBOOT %s returned\n", image->name );
 
        /* It isn't safe to continue after calling shutdown() */
        while ( 1 ) {}
@@ -474,12 +474,12 @@ static int multiboot_probe ( struct image *image ) {
 
        /* Locate multiboot header, if present */
        if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
-               DBGC ( image, "MULTIBOOT %p has no multiboot header\n",
-                      image );
+               DBGC ( image, "MULTIBOOT %s has no multiboot header\n",
+                      image->name );
                return rc;
        }
-       DBGC ( image, "MULTIBOOT %p found header with flags %08x\n",
-              image, hdr.mb.flags );
+       DBGC ( image, "MULTIBOOT %s found header with flags %08x\n",
+              image->name, hdr.mb.flags );
 
        return 0;
 }
index fa714b15f882deaf33c0419ad9ea48fd4d78fdd6..1514342541169ea908573a6bf5d1713766cefd17 100644 (file)
@@ -53,15 +53,15 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr,
        userptr_t buffer = phys_to_virt ( dest );
        int rc;
 
-       DBGC ( image, "ELF %p loading segment [%x,%x) to [%lx,%lx,%lx)\n",
-              image, phdr->p_offset, ( phdr->p_offset + phdr->p_filesz ),
+       DBGC ( image, "ELF %s loading segment [%x,%x) to [%lx,%lx,%lx)\n",
+              image->name, phdr->p_offset, ( phdr->p_offset + phdr->p_filesz ),
               dest, ( dest + phdr->p_filesz ), ( dest + phdr->p_memsz ) );
 
        /* Verify and prepare segment */
        if ( ( rc = prep_segment ( buffer, phdr->p_filesz,
                                   phdr->p_memsz ) ) != 0 ) {
-               DBGC ( image, "ELF %p could not prepare segment: %s\n",
-                      image, strerror ( rc ) );
+               DBGC ( image, "ELF %s could not prepare segment: %s\n",
+                      image->name, strerror ( rc ) );
                return rc;
        }
 
@@ -97,7 +97,7 @@ static int elf_segment ( struct image *image, Elf_Ehdr *ehdr, Elf_Phdr *phdr,
 
        /* Check segment lies within image */
        if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
-               DBGC ( image, "ELF %p segment outside image\n", image );
+               DBGC ( image, "ELF %s segment outside image\n", image->name );
                return -ENOEXEC;
        }
 
@@ -109,8 +109,8 @@ static int elf_segment ( struct image *image, Elf_Ehdr *ehdr, Elf_Phdr *phdr,
        if ( ! dest )
                dest = phdr->p_vaddr;
        if ( ! dest ) {
-               DBGC ( image, "ELF %p segment loads to physical address 0\n",
-                      image );
+               DBGC ( image, "ELF %s segment loads to physical address 0\n",
+                      image->name );
                return -ENOEXEC;
        }
        end = ( dest + phdr->p_memsz );
@@ -126,14 +126,14 @@ static int elf_segment ( struct image *image, Elf_Ehdr *ehdr, Elf_Phdr *phdr,
        /* Set execution address, if it lies within this segment */
        if ( ( e_offset = ( ehdr->e_entry - dest ) ) < phdr->p_filesz ) {
                *entry = ehdr->e_entry;
-               DBGC ( image, "ELF %p found physical entry point at %lx\n",
-                      image, *entry );
+               DBGC ( image, "ELF %s found physical entry point at %lx\n",
+                      image->name, *entry );
        } else if ( ( e_offset = ( ehdr->e_entry - phdr->p_vaddr ) )
                    < phdr->p_filesz ) {
                if ( ! *entry ) {
                        *entry = ( dest + e_offset );
-                       DBGC ( image, "ELF %p found virtual entry point at %lx"
-                              " (virt %lx)\n", image, *entry,
+                       DBGC ( image, "ELF %s found virtual entry point at %lx"
+                              " (virt %lx)\n", image->name, *entry,
                               ( ( unsigned long ) ehdr->e_entry ) );
                }
        }
@@ -170,8 +170,8 @@ int elf_segments ( struct image *image, Elf_Ehdr *ehdr,
        for ( phoff = ehdr->e_phoff , phnum = ehdr->e_phnum ; phnum ;
              phoff += ehdr->e_phentsize, phnum-- ) {
                if ( phoff > image->len ) {
-                       DBGC ( image, "ELF %p program header %d outside "
-                              "image\n", image, phnum );
+                       DBGC ( image, "ELF %s program header %d outside "
+                              "image\n", image->name, phnum );
                        return -ENOEXEC;
                }
                copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
@@ -182,8 +182,8 @@ int elf_segments ( struct image *image, Elf_Ehdr *ehdr,
 
        /* Check for a valid execution address */
        if ( ! *entry ) {
-               DBGC ( image, "ELF %p entry point %lx outside image\n",
-                      image, ( ( unsigned long ) ehdr->e_entry ) );
+               DBGC ( image, "ELF %s entry point %lx outside image\n",
+                      image->name, ( ( unsigned long ) ehdr->e_entry ) );
                return -ENOEXEC;
        }
 
@@ -213,7 +213,7 @@ int elf_load ( struct image *image, physaddr_t *entry, physaddr_t *max ) {
        copy_from_user ( &ehdr, image->data, 0, sizeof ( ehdr ) );
        if ( memcmp ( &ehdr.e_ident[EI_MAG0], e_ident,
                      sizeof ( e_ident ) ) != 0 ) {
-               DBGC ( image, "ELF %p has invalid signature\n", image );
+               DBGC ( image, "ELF %s has invalid signature\n", image->name );
                return -ENOEXEC;
        }