diff mbox series

core/init: Fix loading BE elfs with no sections

Message ID 20191215233927.335-1-jniethe5@gmail.com
State New
Headers show
Series core/init: Fix loading BE elfs with no sections | expand


Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Jordan Niethe Dec. 15, 2019, 11:39 p.m. UTC
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@gmail.com>
 core/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


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)
-	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;