mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* objtool query: section start/end symbols?
@ 2024-06-06 18:42 Linus Torvalds
  2024-06-06 19:45 ` Josh Poimboeuf
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Linus Torvalds @ 2024-06-06 18:42 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra; +Cc: Linux Kernel Mailing List

So this is related to my currently very ugly hack at

   https://lore.kernel.org/all/CAHk-=whFSz=usMPHHGAQBnJRVAFfuH4gFHtgyLe0YET75zYRzA@mail.gmail.com/

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.

And I am not finding any way to do that with a linker script. Sure, I
can trivially just do

        . = ALIGN(8);
        __static_const_start = . ;
        KEEP(*(.static_const.*))
        __static_const_end = . ;

and now I have the over-all start and end for those sections, but I
want it per section.

This is actually not even remotely a new thing: We do this manually
for a lot of sections, and we have macros to help do it, eg our
'BOUNDED_SECTION_BY()' macro in <asm/vmlinux.lds.h> does exactly this
for any named section.

But they very much do this on individually named sections, not on the
kind of "do it for this section pattern" that I want. Yes, you can do
it for patterns, and we do:

        BOUNDED_SECTION_BY(.note.*, _notes)

but that creates exactly that same "bound the whole set of sections by
symbols", not "bound each individual section" thing.

I tried to find some way to do this at the linker script level, and
decided it's not possible. I may be wrong.

So then I said "we can just make objtool do it".

And I think objtool effectively almost has that already, but I'm not
really familiar enough with the code to start messing around with it
at that level.

It's kind of like elf_create_prefix_symbol(), except at a section
level, and needs to be both prefix and postfix.

Or kind of elf_create_section_symbol(), but making it a real symbol
with a real value..

Hmm? Am I barking up entirely the wrong tree? Or does this seem doable
and reasonable?

            Linus

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-06-07 19:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 18:42 objtool query: section start/end symbols? Linus Torvalds
2024-06-06 19:45 ` Josh Poimboeuf
2024-06-06 21:10   ` Linus Torvalds
2024-06-06 22:18     ` Josh Poimboeuf
2024-06-06 22:54       ` Linus Torvalds
2024-06-07  2:41         ` Josh Poimboeuf
2024-06-07  9:39 ` Rasmus Villemoes
2024-06-07 18:54   ` Linus Torvalds
2024-06-07  9:52 ` Rasmus Villemoes
2024-06-07 19:15   ` Linus Torvalds

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®