Re: objtool query: section start/end symbols?

From: Josh Poimboeuf
Date: Thu Jun 06 2024 - 15:45:34 EST


On Thu, Jun 06, 2024 at 11:42:40AM -0700, Linus Torvalds wrote:
> So this is related to my currently very ugly hack at
>
> https://lore.kernel.org/all/CAHk-=whFSz=usMPHHGAQBnJRVAFfuH4gFHtgyLe0YET75zYRzA@xxxxxxxxxxxxxx/
>
> where I'm trying to do "runtime constants". That patch actually works,
> but it's flawed in many ways, and one of the ways it is flawed is that
> I really want to put the "this is the use for symbol X" in a section
> of its own for each X.
>
> Now, creating the sections is trivial, that's not the problem. I'd
> just make the asm do
>
> ".pushsection .static_const." #sym ",\"a\"\n\t" \
> ...
> ".popsection"
>
> and the linker script will just do
>
> KEEP(*(.static_const.*))
>
> and I'm done. Nice individual sections for each of the runtime constant symbols.
>
> However, for the fixup part, I then really want the section start and
> end addresses, so that I can iterate over those uses for a particular
> named symbol.

That should be trivial. But ideally the interface would be less magical
and wouldn't need objtool to sprinkle any pixie dust. Could it be
implemented similar to static keys by making the static const variable
an opaque structure instead of just a "normal" variable?

DEFINE_STATIC_CONST(dentry_hashtable);

That could create something similar to 'struct static_key' which
correlates the const variable with all its use sites.

--
Josh