aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-05-08 17:01:02 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-27 09:59:50 +0200
commite73e72be194ef8634c16deb3e50ff9bc96f7f914 (patch)
tree18a4f995f5e06cadd05373213fa91222b92fb0fd
parent515e0333125564a6c22d5928580957934cc6d6bf (diff)
downloadlinux-yocto-e73e72be194ef8634c16deb3e50ff9bc96f7f914.tar.gz
linux-yocto-e73e72be194ef8634c16deb3e50ff9bc96f7f914.tar.bz2
linux-yocto-e73e72be194ef8634c16deb3e50ff9bc96f7f914.zip
objtool: Check for gelf_update_rel[a] failures
[ Upstream commit b46179d6bb3182c020f2bf9bb4df6ba5463b0495 ] Otherwise, if these fail we end up with garbage data in the .rela.orc_unwind_ip section, leading to errors like ld: fs/squashfs/namei.o: bad reloc symbol index (0x7f16 >= 0x12) for offset 0x7f16d5c82cc8 in section `.orc_unwind_ip' Signed-off-by: Michael Forney <mforney@mforney.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lore.kernel.org/r/20210509000103.11008-1-mforney@mforney.org Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/objtool/elf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 8676c7598728..6cf4c0f11906 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1003,7 +1003,10 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr)
list_for_each_entry(reloc, &sec->reloc_list, list) {
reloc->rel.r_offset = reloc->offset;
reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
- gelf_update_rel(sec->data, idx, &reloc->rel);
+ if (!gelf_update_rel(sec->data, idx, &reloc->rel)) {
+ WARN_ELF("gelf_update_rel");
+ return -1;
+ }
idx++;
}
@@ -1035,7 +1038,10 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr)
reloc->rela.r_offset = reloc->offset;
reloc->rela.r_addend = reloc->addend;
reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
- gelf_update_rela(sec->data, idx, &reloc->rela);
+ if (!gelf_update_rela(sec->data, idx, &reloc->rela)) {
+ WARN_ELF("gelf_update_rela");
+ return -1;
+ }
idx++;
}