[Skiboot] [PATCH] core/init: Fix loading BE elfs with no sections

Jordan Niethe jniethe5 at gmail.com
Mon Dec 16 10:39:27 AEDT 2019


A big-endian elf will either have its entry pointing to a function
description in the data section, or directly pointing to the code.
However currently an elf which has no sections will be treated as its
entry pointing to a function descriptor. For elfs with no sections,
(e.g., created by plan9 linkers) this assumption is incorrect, causing
skiboot to enter at the wrong location. If an elf has no sections, treat
the entry as pointing directly to code.

Signed-off-by: Jordan Niethe <jniethe5 at gmail.com>
---
 core/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/init.c b/core/init.c
index a7083456e5cb..0134e0e4ac66 100644
--- a/core/init.c
+++ b/core/init.c
@@ -196,7 +196,7 @@ static bool try_load_elf64(struct elf_hdr *header)
 			break;
 	}
 
-	if (i == kh->e_shnum || !(sh->sh_flags & ELF_SFLAGS_X)) {
+	if (i && (i == kh->e_shnum || !(sh->sh_flags & ELF_SFLAGS_X))) {
 		kernel_entry = *(uint64_t *)(kernel_entry + load_base);
 		kernel_entry = kernel_entry - ph->p_vaddr + ph->p_offset;
 	}
-- 
2.17.1



More information about the Skiboot mailing list