Commit edce10ee authored by Philipp Rudo's avatar Philipp Rudo Committed by Heiko Carstens

s390/kexec_file: print some more error messages

Be kind and give some more information on what went wrong.
Signed-off-by: default avatarPhilipp Rudo <prudo@redhat.com>
Link: https://lore.kernel.org/r/20211208130741.5821-2-prudo@redhat.comSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 0fcfb00b
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com> * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
*/ */
#define pr_fmt(fmt) "kexec: " fmt
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/kexec.h> #include <linux/kexec.h>
...@@ -290,9 +292,16 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, ...@@ -290,9 +292,16 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
const Elf_Shdr *relsec, const Elf_Shdr *relsec,
const Elf_Shdr *symtab) const Elf_Shdr *symtab)
{ {
const char *strtab, *name, *shstrtab;
const Elf_Shdr *sechdrs;
Elf_Rela *relas; Elf_Rela *relas;
int i, r_type; int i, r_type;
/* String & section header string table */
sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff;
strtab = (char *)pi->ehdr + sechdrs[symtab->sh_link].sh_offset;
shstrtab = (char *)pi->ehdr + sechdrs[pi->ehdr->e_shstrndx].sh_offset;
relas = (void *)pi->ehdr + relsec->sh_offset; relas = (void *)pi->ehdr + relsec->sh_offset;
for (i = 0; i < relsec->sh_size / sizeof(*relas); i++) { for (i = 0; i < relsec->sh_size / sizeof(*relas); i++) {
...@@ -304,15 +313,27 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, ...@@ -304,15 +313,27 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
sym = (void *)pi->ehdr + symtab->sh_offset; sym = (void *)pi->ehdr + symtab->sh_offset;
sym += ELF64_R_SYM(relas[i].r_info); sym += ELF64_R_SYM(relas[i].r_info);
if (sym->st_shndx == SHN_UNDEF) if (sym->st_name)
name = strtab + sym->st_name;
else
name = shstrtab + sechdrs[sym->st_shndx].sh_name;
if (sym->st_shndx == SHN_UNDEF) {
pr_err("Undefined symbol: %s\n", name);
return -ENOEXEC; return -ENOEXEC;
}
if (sym->st_shndx == SHN_COMMON) if (sym->st_shndx == SHN_COMMON) {
pr_err("symbol '%s' in common section\n", name);
return -ENOEXEC; return -ENOEXEC;
}
if (sym->st_shndx >= pi->ehdr->e_shnum && if (sym->st_shndx >= pi->ehdr->e_shnum &&
sym->st_shndx != SHN_ABS) sym->st_shndx != SHN_ABS) {
pr_err("Invalid section %d for symbol %s\n",
sym->st_shndx, name);
return -ENOEXEC; return -ENOEXEC;
}
loc = pi->purgatory_buf; loc = pi->purgatory_buf;
loc += section->sh_offset; loc += section->sh_offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment