[Skiboot] [PATCH] Load ELF64 binaries correctly

Nathan Whitehorn nwhitehorn at freebsd.org
Thu Jan 22 03:45:25 AEDT 2015


The attached patch fixes the big-endian ELF64 loader in skiboot to 
handle the fact that the ELF entry point is specified to point to a 
function descriptor describing the entry point rather than the entry 
point itself. (I haven't set it up to load the TOC base pointer though) 
This is required to load the FreeBSD kernel as a skiboot payload. The 
patch does not touch the little-endian loader since I'm not sure if the 
ELFv2 spec still has function descriptors or not.
-Nathan
-------------- next part --------------
diff --git a/core/init.c b/core/init.c
index 2c7e30c..6b794ec 100644
--- a/core/init.c
+++ b/core/init.c
@@ -143,8 +143,10 @@ static bool try_load_elf64(struct elf_hdr *header)
 		    (ph->p_vaddr + ph->p_memsz) < kh->e_entry)
 			continue;
 
-		/* Get our entry */
-		kernel_entry = kh->e_entry - ph->p_vaddr + ph->p_offset;
+		/* Get our entry: note the function descriptor dereference */
+		kernel_entry = *(uint64_t *)(kh->e_entry - ph->p_vaddr +
+		    ph->p_offset + load_base);
+		kernel_entry = kernel_entry - ph->p_vaddr + ph->p_offset;
 		break;
 	}
 


More information about the Skiboot mailing list