+/* ======================================================================
+ * Determine if a valid ELF image exists at the given memory location.
+ * First looks at the ELF header magic field, the makes sure that it is
+ * executable and makes sure that it is for a PowerPC.
+ * ====================================================================== */
+int valid_elf_image(unsigned long addr)
+{
+ Elf32_Ehdr *ehdr; /* Elf header structure pointer */
+
+ /* -------------------------------------------------- */
+
+ 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;
+ }
+
+#if 0
+ if (ehdr->e_machine != EM_PPC) {
+ printf("## Not a PowerPC elf image at address 0x%08lx\n", addr);
+ return 0;
+ }
+#endif
+
+ return 1;
+}
+