On Sat, May 04, 2024 at 03:24:02PM -0700, Josh Poimboeuf wrote:
> On Tue, Apr 30, 2024 at 04:51:07PM -0700, Kees Cook wrote:
> > @@ -891,8 +892,8 @@ struct reloc *elf_init_reloc_text_sym(struct elf *elf, 
> > struct section *sec,
> >     int addend = insn_off;
> >  
> >     if (!(insn_sec->sh.sh_flags & SHF_EXECINSTR)) {
> > -           WARN("bad call to %s() for data symbol %s",
> > -                __func__, sym->name);
> > +           WARN("bad call to %s() for %s symbol %s",
> > +                __func__, origin, sym->name);
> >             return NULL;
> 
> Thanks for the patch.
> 
> That warning was already phrased pretty awkwardly which was probably
> part of the confusion.  It could be rephrased to make it a little
> clearer:
> 
> Something like:
> 
>   .cfi_sites: unexpected reference to non-executable symbol 'execute_location'
> 
> And ".cfi_sites" is already in 'sec->name', so you wouldn't need to add
> the new 'origin' arg.

What's so odd is that "execute_location" wasn't being reported at all.
Just ".rodata": 

vmlinux.o: warning: objtool: bad call to elf_init_reloc_text_sym() for data 
symbol .rodata

But yes, sec->name has what I want, so I can do this easily:

-               WARN("bad call to %s() for data symbol %s",
-                    __func__, sym->name);
+               WARN("bad call to %s() for %s symbol %s",
+                    __func__, sec->name, sym->name);

vmlinux.o: warning: objtool: bad call to elf_init_reloc_text_sym() for 
.cfi_sites symbol .rodata

I think the symbol is missing because this is coming from
create_cfi_sections()/elf_create_section_pair().

Regardless, I'll send a v2...

Thanks!

-- 
Kees Cook

Reply via email to