mirror of
https://github.com/ipxe/ipxe
synced 2026-02-28 03:11:18 +03:00
[multiboot] Use image name in Multiboot and ELF debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -52,8 +52,8 @@ static int elfboot_exec ( struct image *image ) {
|
|||||||
|
|
||||||
/* Load the image using core ELF support */
|
/* Load the image using core ELF support */
|
||||||
if ( ( rc = elf_load ( image, &entry, &max ) ) != 0 ) {
|
if ( ( rc = elf_load ( image, &entry, &max ) ) != 0 ) {
|
||||||
DBGC ( image, "ELF %p could not load: %s\n",
|
DBGC ( image, "ELF %s could not load: %s\n",
|
||||||
image, strerror ( rc ) );
|
image->name, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,14 +63,15 @@ static int elfboot_exec ( struct image *image ) {
|
|||||||
shutdown_boot();
|
shutdown_boot();
|
||||||
|
|
||||||
/* Jump to OS with flat physical addressing */
|
/* 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 */
|
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||||
"call *%%edi\n\t"
|
"call *%%edi\n\t"
|
||||||
"popl %%ebp\n\t" /* gcc bug */ )
|
"popl %%ebp\n\t" /* gcc bug */ )
|
||||||
: : "D" ( entry )
|
: : "D" ( entry )
|
||||||
: "eax", "ebx", "ecx", "edx", "esi", "memory" );
|
: "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() */
|
/* It isn't safe to continue after calling shutdown() */
|
||||||
while ( 1 ) {}
|
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 */
|
/* Check that ELF segment uses flat physical addressing */
|
||||||
if ( phdr->p_vaddr != dest ) {
|
if ( phdr->p_vaddr != dest ) {
|
||||||
DBGC ( image, "ELF %p uses virtual addressing (phys %x, "
|
DBGC ( image, "ELF %s uses virtual addressing (phys %x, virt "
|
||||||
"virt %x)\n", image, phdr->p_paddr, phdr->p_vaddr );
|
"%x)\n", image->name, phdr->p_paddr, phdr->p_vaddr );
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,14 +124,15 @@ static int elfboot_probe ( struct image *image ) {
|
|||||||
/* Read ELF header */
|
/* Read ELF header */
|
||||||
copy_from_user ( &ehdr, image->data, 0, sizeof ( ehdr ) );
|
copy_from_user ( &ehdr, image->data, 0, sizeof ( ehdr ) );
|
||||||
if ( memcmp ( ehdr.e_ident, e_ident, sizeof ( e_ident ) ) != 0 ) {
|
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;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that this image uses flat physical addressing */
|
/* Check that this image uses flat physical addressing */
|
||||||
if ( ( rc = elf_segments ( image, &ehdr, elfboot_check_segment,
|
if ( ( rc = elf_segments ( image, &ehdr, elfboot_check_segment,
|
||||||
&entry, &max ) ) != 0 ) {
|
&entry, &max ) ) != 0 ) {
|
||||||
DBGC ( image, "Unloadable ELF image\n" );
|
DBGC ( image, "ELF %s is not loadable: %s\n",
|
||||||
|
image->name, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ static void multiboot_build_memmap ( struct image *image,
|
|||||||
memset ( mbmemmap, 0, sizeof ( *mbmemmap ) );
|
memset ( mbmemmap, 0, sizeof ( *mbmemmap ) );
|
||||||
for ( i = 0 ; i < memmap.count ; i++ ) {
|
for ( i = 0 ; i < memmap.count ; i++ ) {
|
||||||
if ( i >= limit ) {
|
if ( i >= limit ) {
|
||||||
DBGC ( image, "MULTIBOOT %p limit of %d memmap "
|
DBGC ( image, "MULTIBOOT %s limit of %d memmap "
|
||||||
"entries reached\n", image, limit );
|
"entries reached\n", image->name, limit );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mbmemmap[i].size = ( sizeof ( mbmemmap[i] ) -
|
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 ) {
|
for_each_image ( module_image ) {
|
||||||
|
|
||||||
if ( mbinfo->mods_count >= limit ) {
|
if ( mbinfo->mods_count >= limit ) {
|
||||||
DBGC ( image, "MULTIBOOT %p limit of %d modules "
|
DBGC ( image, "MULTIBOOT %s limit of %d modules "
|
||||||
"reached\n", image, limit );
|
"reached\n", image->name, limit );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,8 +215,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start,
|
|||||||
if ( ( rc = prep_segment ( phys_to_virt ( start ),
|
if ( ( rc = prep_segment ( phys_to_virt ( start ),
|
||||||
module_image->len,
|
module_image->len,
|
||||||
module_image->len ) ) != 0 ) {
|
module_image->len ) ) != 0 ) {
|
||||||
DBGC ( image, "MULTIBOOT %p could not prepare module "
|
DBGC ( image, "MULTIBOOT %s could not prepare module "
|
||||||
"%s: %s\n", image, module_image->name,
|
"%s: %s\n", image->name, module_image->name,
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
return 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->mod_end = ( start + module_image->len );
|
||||||
module->string = multiboot_add_cmdline ( module_image );
|
module->string = multiboot_add_cmdline ( module_image );
|
||||||
module->reserved = 0;
|
module->reserved = 0;
|
||||||
DBGC ( image, "MULTIBOOT %p module %s is [%x,%x)\n",
|
DBGC ( image, "MULTIBOOT %s module %s is [%x,%x)\n",
|
||||||
image, module_image->name, module->mod_start,
|
image->name, module_image->name, module->mod_start,
|
||||||
module->mod_end );
|
module->mod_end );
|
||||||
start += module_image->len;
|
start += module_image->len;
|
||||||
}
|
}
|
||||||
@@ -330,8 +330,8 @@ static int multiboot_load_raw ( struct image *image,
|
|||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
|
if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
|
||||||
DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
|
DBGC ( image, "MULTIBOOT %s is not flagged as a raw image\n",
|
||||||
image );
|
image->name );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,8 +344,8 @@ static int multiboot_load_raw ( struct image *image,
|
|||||||
( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
|
( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
|
||||||
buffer = phys_to_virt ( hdr->mb.load_addr );
|
buffer = phys_to_virt ( hdr->mb.load_addr );
|
||||||
if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
|
if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
|
||||||
DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n",
|
DBGC ( image, "MULTIBOOT %s could not prepare segment: %s\n",
|
||||||
image, strerror ( rc ) );
|
image->name, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +373,8 @@ static int multiboot_load_elf ( struct image *image, physaddr_t *entry,
|
|||||||
|
|
||||||
/* Load ELF image*/
|
/* Load ELF image*/
|
||||||
if ( ( rc = elf_load ( image, entry, max ) ) != 0 ) {
|
if ( ( rc = elf_load ( image, entry, max ) ) != 0 ) {
|
||||||
DBGC ( image, "MULTIBOOT %p ELF image failed to load: %s\n",
|
DBGC ( image, "MULTIBOOT %s ELF image failed to load: %s\n",
|
||||||
image, strerror ( rc ) );
|
image->name, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,15 +395,15 @@ static int multiboot_exec ( struct image *image ) {
|
|||||||
|
|
||||||
/* Locate multiboot header, if present */
|
/* Locate multiboot header, if present */
|
||||||
if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
|
if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
|
||||||
DBGC ( image, "MULTIBOOT %p has no multiboot header\n",
|
DBGC ( image, "MULTIBOOT %s has no multiboot header\n",
|
||||||
image );
|
image->name );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Abort if we detect flags that we cannot support */
|
/* Abort if we detect flags that we cannot support */
|
||||||
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
|
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
|
||||||
DBGC ( image, "MULTIBOOT %p flags %08x not supported\n",
|
DBGC ( image, "MULTIBOOT %s flags %08x not supported\n",
|
||||||
image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
|
image->name, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,8 +444,8 @@ static int multiboot_exec ( struct image *image ) {
|
|||||||
( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
|
( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
|
||||||
|
|
||||||
/* Jump to OS with flat physical addressing */
|
/* Jump to OS with flat physical addressing */
|
||||||
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
|
DBGC ( image, "MULTIBOOT %s starting execution at %lx\n",
|
||||||
image, entry );
|
image->name, entry );
|
||||||
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
|
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
|
||||||
"call *%%edi\n\t"
|
"call *%%edi\n\t"
|
||||||
"popl %%ebp\n\t" )
|
"popl %%ebp\n\t" )
|
||||||
@@ -454,7 +454,7 @@ static int multiboot_exec ( struct image *image ) {
|
|||||||
"D" ( entry )
|
"D" ( entry )
|
||||||
: "ecx", "edx", "esi", "memory" );
|
: "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() */
|
/* It isn't safe to continue after calling shutdown() */
|
||||||
while ( 1 ) {}
|
while ( 1 ) {}
|
||||||
@@ -474,12 +474,12 @@ static int multiboot_probe ( struct image *image ) {
|
|||||||
|
|
||||||
/* Locate multiboot header, if present */
|
/* Locate multiboot header, if present */
|
||||||
if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
|
if ( ( rc = multiboot_find_header ( image, &hdr ) ) != 0 ) {
|
||||||
DBGC ( image, "MULTIBOOT %p has no multiboot header\n",
|
DBGC ( image, "MULTIBOOT %s has no multiboot header\n",
|
||||||
image );
|
image->name );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
DBGC ( image, "MULTIBOOT %p found header with flags %08x\n",
|
DBGC ( image, "MULTIBOOT %s found header with flags %08x\n",
|
||||||
image, hdr.mb.flags );
|
image->name, hdr.mb.flags );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,15 +53,15 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr,
|
|||||||
userptr_t buffer = phys_to_virt ( dest );
|
userptr_t buffer = phys_to_virt ( dest );
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
DBGC ( image, "ELF %p loading segment [%x,%x) to [%lx,%lx,%lx)\n",
|
DBGC ( image, "ELF %s loading segment [%x,%x) to [%lx,%lx,%lx)\n",
|
||||||
image, phdr->p_offset, ( phdr->p_offset + phdr->p_filesz ),
|
image->name, phdr->p_offset, ( phdr->p_offset + phdr->p_filesz ),
|
||||||
dest, ( dest + phdr->p_filesz ), ( dest + phdr->p_memsz ) );
|
dest, ( dest + phdr->p_filesz ), ( dest + phdr->p_memsz ) );
|
||||||
|
|
||||||
/* Verify and prepare segment */
|
/* Verify and prepare segment */
|
||||||
if ( ( rc = prep_segment ( buffer, phdr->p_filesz,
|
if ( ( rc = prep_segment ( buffer, phdr->p_filesz,
|
||||||
phdr->p_memsz ) ) != 0 ) {
|
phdr->p_memsz ) ) != 0 ) {
|
||||||
DBGC ( image, "ELF %p could not prepare segment: %s\n",
|
DBGC ( image, "ELF %s could not prepare segment: %s\n",
|
||||||
image, strerror ( rc ) );
|
image->name, strerror ( rc ) );
|
||||||
return 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 */
|
/* Check segment lies within image */
|
||||||
if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
|
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;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ static int elf_segment ( struct image *image, Elf_Ehdr *ehdr, Elf_Phdr *phdr,
|
|||||||
if ( ! dest )
|
if ( ! dest )
|
||||||
dest = phdr->p_vaddr;
|
dest = phdr->p_vaddr;
|
||||||
if ( ! dest ) {
|
if ( ! dest ) {
|
||||||
DBGC ( image, "ELF %p segment loads to physical address 0\n",
|
DBGC ( image, "ELF %s segment loads to physical address 0\n",
|
||||||
image );
|
image->name );
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
end = ( dest + phdr->p_memsz );
|
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 */
|
/* Set execution address, if it lies within this segment */
|
||||||
if ( ( e_offset = ( ehdr->e_entry - dest ) ) < phdr->p_filesz ) {
|
if ( ( e_offset = ( ehdr->e_entry - dest ) ) < phdr->p_filesz ) {
|
||||||
*entry = ehdr->e_entry;
|
*entry = ehdr->e_entry;
|
||||||
DBGC ( image, "ELF %p found physical entry point at %lx\n",
|
DBGC ( image, "ELF %s found physical entry point at %lx\n",
|
||||||
image, *entry );
|
image->name, *entry );
|
||||||
} else if ( ( e_offset = ( ehdr->e_entry - phdr->p_vaddr ) )
|
} else if ( ( e_offset = ( ehdr->e_entry - phdr->p_vaddr ) )
|
||||||
< phdr->p_filesz ) {
|
< phdr->p_filesz ) {
|
||||||
if ( ! *entry ) {
|
if ( ! *entry ) {
|
||||||
*entry = ( dest + e_offset );
|
*entry = ( dest + e_offset );
|
||||||
DBGC ( image, "ELF %p found virtual entry point at %lx"
|
DBGC ( image, "ELF %s found virtual entry point at %lx"
|
||||||
" (virt %lx)\n", image, *entry,
|
" (virt %lx)\n", image->name, *entry,
|
||||||
( ( unsigned long ) ehdr->e_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 ;
|
for ( phoff = ehdr->e_phoff , phnum = ehdr->e_phnum ; phnum ;
|
||||||
phoff += ehdr->e_phentsize, phnum-- ) {
|
phoff += ehdr->e_phentsize, phnum-- ) {
|
||||||
if ( phoff > image->len ) {
|
if ( phoff > image->len ) {
|
||||||
DBGC ( image, "ELF %p program header %d outside "
|
DBGC ( image, "ELF %s program header %d outside "
|
||||||
"image\n", image, phnum );
|
"image\n", image->name, phnum );
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
|
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 */
|
/* Check for a valid execution address */
|
||||||
if ( ! *entry ) {
|
if ( ! *entry ) {
|
||||||
DBGC ( image, "ELF %p entry point %lx outside image\n",
|
DBGC ( image, "ELF %s entry point %lx outside image\n",
|
||||||
image, ( ( unsigned long ) ehdr->e_entry ) );
|
image->name, ( ( unsigned long ) ehdr->e_entry ) );
|
||||||
return -ENOEXEC;
|
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 ) );
|
copy_from_user ( &ehdr, image->data, 0, sizeof ( ehdr ) );
|
||||||
if ( memcmp ( &ehdr.e_ident[EI_MAG0], e_ident,
|
if ( memcmp ( &ehdr.e_ident[EI_MAG0], e_ident,
|
||||||
sizeof ( e_ident ) ) != 0 ) {
|
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;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user