Re: objtool warnings on 4.14-stable/gcc-7.3.0

From: Josh Poimboeuf
Date: Tue Feb 27 2018 - 21:20:46 EST


On Wed, Feb 14, 2018 at 04:45:25PM -0600, Josh Poimboeuf wrote:
> On Wed, Feb 14, 2018 at 04:24:12PM -0600, Josh Poimboeuf wrote:
> > On Wed, Feb 14, 2018 at 04:11:15PM +0100, Arnd Bergmann wrote:
> > > crypto/asymmetric_keys/x509_cert_parser.o: warning: objtool:
> > > x509_note_pkey_algo()+0xa4: sibling call from callable instruction
> > > with modified stack frame
>
> From a quick glance, this looks like yet another switch statement
> detection issue. I'll need to dig into it more (unless PeterZ, my shiny
> new co-maintainer, wants to take a look!)

Arnd, can you test this fix?

----

From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Subject: [PATCH] objtool: Another switch table detection fix

Continue the switch table detection whack-a-mole. Add a check to
distinguish KASAN-related .rodata reads from switch-related .rodata
reads in GCC 7.

This fixes the following warning:

crypto/asymmetric_keys/x509_cert_parser.o: warning: objtool: x509_note_pkey_algo()+0xa4: sibling call from callable instruction with modified stack frame

Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
tools/objtool/check.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 472e64e95891..46c1d239cc1b 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -925,7 +925,11 @@ static struct rela *find_switch_table(struct objtool_file *file,
if (find_symbol_containing(file->rodata, text_rela->addend))
continue;

- return find_rela_by_dest(file->rodata, text_rela->addend);
+ rodata_rela = find_rela_by_dest(file->rodata, text_rela->addend);
+ if (!rodata_rela)
+ continue;
+
+ return rodata_rela;
}

return NULL;
--
2.14.3