From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: objtool crashes on clang output (drivers/hwmon/pmbus/adm1275.o)
Date: Thu, 11 Jul 2019 12:26:21 -0500 [thread overview]
Message-ID: <20190711172621.a7ab7jorolicid3z@treble> (raw)
In-Reply-To: <CAK8P3a2beBPP+KX4zTfSfFPwo+7ksWZLqZzpP9BJ80iPecg3zA@mail.gmail.com>
On Thu, Jul 11, 2019 at 02:40:06PM +0200, Arnd Bergmann wrote:
> During randconfig testing with clang-9, I came across an object file
> that makes objtool segfault, see attachment. Let me know if you need
> more information to
> debug this.
>
> I also get a ton of objtool warnings building random configurations, but Nick
> mentioned that there is still a bug related to asm-goto in the build I'm using
> that may be the root cause. Once I have a fixed clang-9 build, I can have a look
> at those as well.
Seg fault fix:
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 27818a93f0b1..ad18f8ef905a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -902,7 +902,7 @@ static int add_switch_table(struct objtool_file *file, struct instruction *insn,
struct rela *table, struct rela *next_table)
{
struct rela *rela = table;
- struct instruction *alt_insn;
+ struct instruction *alt_insn, *prev_insn;
struct alternative *alt;
struct symbol *pfunc = insn->func->pfunc;
unsigned int prev_offset = 0;
@@ -924,6 +924,20 @@ static int add_switch_table(struct objtool_file *file, struct instruction *insn,
if (!alt_insn)
break;
+ if (!alt_insn->func) {
+ /*
+ * Clang 9 has a quirk where a switch table may have
+ * unused entries in the middle of the table which
+ * point to just past the end of the function. They're
+ * still part of the table but can be ignored.
+ */
+ prev_insn = list_prev_entry(alt_insn, list);
+ if (prev_insn->func && prev_insn->func->pfunc == pfunc)
+ goto skip;
+
+ break;
+ }
+
/* Make sure the jmp dest is in the function or subfunction: */
if (alt_insn->func->pfunc != pfunc)
break;
@@ -936,6 +950,7 @@ static int add_switch_table(struct objtool_file *file, struct instruction *insn,
alt->insn = alt_insn;
list_add_tail(&alt->list, &insn->alts);
+skip:
prev_offset = rela->offset;
}
next prev parent reply other threads:[~2019-07-11 17:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 12:40 Arnd Bergmann
2019-07-11 17:26 ` Josh Poimboeuf [this message]
2019-07-11 21:00 ` Arnd Bergmann
2019-07-11 21:04 ` Jann Horn
2019-07-11 21:29 ` Arnd Bergmann
2019-07-12 7:51 ` Arnd Bergmann
2019-07-12 13:57 ` Josh Poimboeuf
2019-07-12 14:19 ` Arnd Bergmann
2019-07-12 14:29 ` Josh Poimboeuf
2019-07-12 16:59 ` Nick Desaulniers
2019-07-12 20:40 ` Arnd Bergmann
2019-07-16 20:24 ` Nick Desaulniers
2019-07-16 22:05 ` Arnd Bergmann
2019-07-16 23:03 ` Josh Poimboeuf
2019-07-18 22:36 ` Nick Desaulniers
2019-07-18 23:20 ` Josh Poimboeuf
2019-07-11 23:20 ` Josh Poimboeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190711172621.a7ab7jorolicid3z@treble \
--to=jpoimboe@redhat.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®