Skip to content

Commit b46179d

Browse files
michaelforneyjpoimboe
authored andcommitted
objtool: Check for gelf_update_rel[a] failures
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 <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fe255fe commit b46179d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/objtool/elf.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,10 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr)
10011001
list_for_each_entry(reloc, &sec->reloc_list, list) {
10021002
reloc->rel.r_offset = reloc->offset;
10031003
reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1004-
gelf_update_rel(sec->data, idx, &reloc->rel);
1004+
if (!gelf_update_rel(sec->data, idx, &reloc->rel)) {
1005+
WARN_ELF("gelf_update_rel");
1006+
return -1;
1007+
}
10051008
idx++;
10061009
}
10071010

@@ -1033,7 +1036,10 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr)
10331036
reloc->rela.r_offset = reloc->offset;
10341037
reloc->rela.r_addend = reloc->addend;
10351038
reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1036-
gelf_update_rela(sec->data, idx, &reloc->rela);
1039+
if (!gelf_update_rela(sec->data, idx, &reloc->rela)) {
1040+
WARN_ELF("gelf_update_rela");
1041+
return -1;
1042+
}
10371043
idx++;
10381044
}
10391045

0 commit comments

Comments
 (0)