[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201211164915.GA2414@hirez.programming.kicks-ass.net>
Date: Fri, 11 Dec 2020 17:49:15 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>,
Arnd Bergmann <arnd@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: objtool crashes with some clang produced .o files
On Fri, Dec 11, 2020 at 10:37:48AM -0600, Josh Poimboeuf wrote:
> On Fri, Dec 11, 2020 at 10:32:05AM +0100, Peter Zijlstra wrote:
> > Looking at elf.c, it seems we're missing an STT_SECTION symbol for
> > .text.
> >
> > And indeed, when I add -fno-asynchronous-unwind-tables to clang-11, that
> > goes missing from the readelf .symtab listing. Help ?!
>
> I had a similar problem with ORC relocations:
>
> e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
>
> If Clang strips the section symbol then we have to find the function
> symbol instead.
Argh, I knew I'd seen something like that before, but I couldn't find it :-/
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index c6ab44543c92..9bc18864154f 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -472,8 +472,25 @@ static int create_static_call_sections(struct objtool_file *file)
> return -1;
> }
> memset(reloc, 0, sizeof(*reloc));
> - reloc->sym = insn->sec->sym;
> - reloc->addend = insn->offset;
> +
> + if (insn->sec->sym) {
> + reloc->sym = insn->sec->sym;
> + reloc->addend = insn->offset;
> + } else {
> + reloc->sym = find_symbol_containing(insn->sec, insn->offset);
> + if (!reloc->sym) {
> + WARN_FUNC("can't create static call: missing containing symbol",
> + insn->sec, insn->offset);
> + return -1;
> + }
> +
> + reloc->addend = insn->offset - reloc->sym->offset;
> + }
> +
Do we want to capture all that gunk in something like
elf_reloc_to_insn(reloc, insn) instead of duplicating the magic?
Powered by blists - more mailing lists