From e3db29c00760d262970dadfb3fa570364a39428b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 25 Feb 2016 22:38:38 +1030 Subject: [PATCH 1/3] Properly align powerpc64 .toc gcc leaves .toc byte aligned, relying on the linker to align the section. * kexec/arch/ppc64/kexec-elf-rel-ppc64.c (machine_verify_elf_rel): Fudge alignment of .toc section. Signed-off-by: Alan Modra diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c index 9b191d0..23f401a 100644 --- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c +++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c @@ -5,18 +5,6 @@ #include "../../kexec-elf.h" #include "kexec-ppc64.h" -int machine_verify_elf_rel(struct mem_ehdr *ehdr) -{ - if (ehdr->ei_class != ELFCLASS64) { - return 0; - } - if (ehdr->e_machine != EM_PPC64) { - return 0; - } - - return 1; -} - static struct mem_shdr *toc_section(const struct mem_ehdr *ehdr) { struct mem_shdr *shdr, *shdr_end; @@ -34,6 +22,24 @@ static struct mem_shdr *toc_section(const struct mem_ehdr *ehdr) return NULL; } +int machine_verify_elf_rel(struct mem_ehdr *ehdr) +{ + struct mem_shdr *toc; + + if (ehdr->ei_class != ELFCLASS64) { + return 0; + } + if (ehdr->e_machine != EM_PPC64) { + return 0; + } + + /* Ensure .toc is sufficiently aligned. */ + toc = toc_section(ehdr); + if (toc && toc->sh_addralign < 256) + toc->sh_addralign = 256; + return 1; +} + /* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this gives the value maximum span in an instruction which uses a signed offset) */ -- 2.1.0