[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 19/20] livepatch/elf: Adjust section aligment to word
On most architectures it does not matter what the aligment is. On ARM32 it is paramount that the aligment is word-size (4) otherwise we get a Data Abort when trying to perform ELF relocations. That is due to ARM 32 only being able to write to word-aligned addresses. The default section alignments for .bug.frame, .livepatch.depends, ,.rodata.str1, and .strtab are 1 unless we: - Provide our own linker script file. - Piggyback on Xen's (but that means lots of #ifdefery) - Throw an error and refuse the payload Or just fix it up. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> --- Cc: Julien Grall <julien.grall@xxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> v2: First submission --- xen/common/livepatch_elf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c index cda9b27..2392bdf 100644 --- a/xen/common/livepatch_elf.c +++ b/xen/common/livepatch_elf.c @@ -71,7 +71,15 @@ static int elf_resolve_sections(struct livepatch_elf *elf, const void *data) delta = elf->hdr->e_shoff + i * elf->hdr->e_shentsize; sec[i].sec = data + delta; - + /* + * Some architectures REQUIRE section alignment to be word-size. + */ + if ( sec[i].sec->sh_addralign % sizeof(uint32_t) ) + { + dprintk(XENLOG_DEBUG, LIVEPATCH "%s: Adjusting aligment for section [%u]\n", + elf->name, i); + ((Elf_Shdr *)sec[i].sec)->sh_addralign = 4; + } delta = sec[i].sec->sh_offset; /* * N.B. elf_resolve_section_names, elf_get_sym skip this check as -- 2.4.11 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |