From fbfc8f9becf786d2c5f00d059acb6bf15f95219e Mon Sep 17 00:00:00 2001 From: Julien Thierry Date: Thu, 20 Feb 2020 14:50:56 +0000 Subject: [PATCH] create-diff-object: Handle ppc64le toc with only constants When a ppcle64 ".toc" section contains only constants, the compiler might not (won't?) create a corresponding ".rela.toc" section. In such cases, create-diff-object crashes, assuming ".rela.toc" exists whenever .toc exists. Simply report that no rela are available when looking up possible relocations in .toc. Fixes #1078. Signed-off-by: Julien Thierry --- kpatch-build/create-diff-object.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 23c2541..aedd07d 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -177,6 +177,10 @@ static struct rela *toc_rela(const struct rela *rela) rela->type != R_PPC64_TOC16_LO_DS) return (struct rela *)rela; + /* Only constants in toc */ + if (!rela->sym->sec->rela) + return NULL; + /* Will return NULL for .toc constant entries */ return find_rela_by_offset(rela->sym->sec->rela, (unsigned int)rela->addend);