Re: [RFC v2 2/7] tables.h: add linker table support

From: H. Peter Anvin
Date: Tue Feb 23 2016 - 18:27:30 EST


On 02/23/2016 03:08 PM, Luis R. Rodriguez wrote:
>
> OK yes I see the issue now. I've modified this to use const, and
> retested the kprobe patch and it works well still. kprobe would not
> use LINKTABLE_TEXT, instead it uses its own macro, however users of
> LINKTABLE_TEXT would then have const declared. The implications are
> that you *can* declare structs so long as everything is const.
>

No, such structures belong in .rodata not in .text.

I have been thinking about it somewhat, and for text we really have text
"ranges" rather than tables. The big difference between the two are:

1. priority ordering doesn't make any sense for ranges.
2. ranges can be hierarchial, that is, range "bar" can be entirely
inside range "foo".
3. ranges aren't typed (although in C, that pretty much means they are
"char" or "unsigned char" as there really isn't any way to define an
"array of void".)
4. the only useful operator on a range is "is address X inside this
range"; this operator is likely *not* useful for a table, since
if you have to ever invoke it you are probably doing something very
wrong.

For this to work, we need strings such that they will always sort in the
appropriate order with the bracket symbols around subranges. I need to
think about this a few minutes before I actually say anything about it...

-hpa