/* Determine if a valid ELF image exists at the given memory location. First look at the ELF header magic field, then make sure that it is executable.  */
int valid_elf_image(unsigned long addr)
/* Determine if a valid ELF image exists at the given memory location. First look at the ELF header magic field, then make sure that it is executable.  */
int valid_elf_image(unsigned long addr)
{
	Elf32_Ehdr *ehdr;
	ehdr = (Elf32_Ehdr *)addr;
	if (!IS_ELF(*ehdr)) {
		printf("## No elf image at address 0x%08lx\n", addr);
		return 0;
	}
	if (ehdr->e_type != ET_EXEC) {
		printf("## Not a 32-bit elf image at address 0x%08lx\n", addr);
		return 0;
	}
	return 1;
}