linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] objtool: Check for gelf_update_rel[a] failures
@ 2021-05-09  0:01 Michael Forney
  2021-05-09  0:01 ` [PATCH 2/2] objtool: Update section header before relocations Michael Forney
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Michael Forney @ 2021-05-09  0:01 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra; +Cc: linux-kernel

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>
---
 tools/objtool/elf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index d08f5f3670f8..b396ee4ab85d 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -953,7 +953,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++;
 	}
 
@@ -985,7 +988,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++;
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-10-13 21:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-09  0:01 [PATCH 1/2] objtool: Check for gelf_update_rel[a] failures Michael Forney
2021-05-09  0:01 ` [PATCH 2/2] objtool: Update section header before relocations Michael Forney
2021-06-29  7:55   ` Miroslav Benes
2021-10-13 21:42   ` [tip: objtool/urgent] " tip-bot2 for Michael Forney
2021-06-28  7:52 ` [PATCH 1/2] objtool: Check for gelf_update_rel[a] failures Michael Forney
2021-06-28  8:24   ` Peter Zijlstra
2021-06-29 17:12     ` Josh Poimboeuf
2021-08-28 19:04       ` Michael Forney
2021-10-06 16:58         ` Michael Forney
2021-10-07  3:16           ` Josh Poimboeuf
2021-06-29  7:54 ` Miroslav Benes
2021-10-13 21:42 ` [tip: objtool/urgent] " tip-bot2 for Michael Forney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).