Skip to content

Commit 2b232a2

Browse files
Julien Thierryjpoimboe
authored andcommitted
objtool: Handle calling non-function symbols in other sections
Relocation for a call destination could point to a symbol that has type STT_NOTYPE. Lookup such a symbol when no function is available. Signed-off-by: Julien Thierry <jthierry@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
1 parent fb13621 commit 2b232a2

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tools/objtool/check.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,17 @@ static void remove_insn_ops(struct instruction *insn)
815815
}
816816
}
817817

818+
static struct symbol *find_call_destination(struct section *sec, unsigned long offset)
819+
{
820+
struct symbol *call_dest;
821+
822+
call_dest = find_func_by_offset(sec, offset);
823+
if (!call_dest)
824+
call_dest = find_symbol_by_offset(sec, offset);
825+
826+
return call_dest;
827+
}
828+
818829
/*
819830
* Find the destination instructions for all calls.
820831
*/
@@ -832,9 +843,7 @@ static int add_call_destinations(struct objtool_file *file)
832843
insn->offset, insn->len);
833844
if (!reloc) {
834845
dest_off = arch_jump_destination(insn);
835-
insn->call_dest = find_func_by_offset(insn->sec, dest_off);
836-
if (!insn->call_dest)
837-
insn->call_dest = find_symbol_by_offset(insn->sec, dest_off);
846+
insn->call_dest = find_call_destination(insn->sec, dest_off);
838847

839848
if (insn->ignore)
840849
continue;
@@ -852,8 +861,8 @@ static int add_call_destinations(struct objtool_file *file)
852861

853862
} else if (reloc->sym->type == STT_SECTION) {
854863
dest_off = arch_dest_reloc_offset(reloc->addend);
855-
insn->call_dest = find_func_by_offset(reloc->sym->sec,
856-
dest_off);
864+
insn->call_dest = find_call_destination(reloc->sym->sec,
865+
dest_off);
857866
if (!insn->call_dest) {
858867
WARN_FUNC("can't find call dest symbol at %s+0x%lx",
859868
insn->sec, insn->offset,

0 commit comments

Comments
 (0)