[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pickles: Improvements to btf.pk
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] pickles: Improvements to btf.pk |
Date: |
Sun, 14 Feb 2021 15:26:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> +type BTF_Section =
> + struct
> + {
> + BTF_Header header;
> + BTF_Type[header.type_len] types;
> + string[header.str_len] strings;
> +
> + /* Given an offset into the BTF strings section, return the string. */
> +
> + method get_string = (offset<uint<32>,B> off) string:
> + {
> + return string @ strings'offset + off;
> + }
> + };
Now that I think of it, arent the location of `types' and `strings'
determined by the header as an offset relative to the end of the header?
Something like this:
type BTF_Section =
struct
{
BTF_Header header;
BTF_Type[header.type_len] types @ header'size + header.type_off;
string[header.str_len] strings @ header'size + header.str_off;
...
};
Or, alternatively, this may be more clear but less compact:
type BTF_Section =
struct
{
BTF_Header header;
var type_off = OFFSET + header.type_off;
var str_off = OFFSET + header.str_off;
BTF_Type[header.type_len] types @ type_off;
string[header.str_len] strings @ str_off;
...
};
Note how in a struct type definition OFFSET always holds the offset of
the end of the last mapped field, relative to the beginning of the
struct.