| fa624569 | 03-Jan-2025 |
Sami Tolvanen <[email protected]> |
gendwarfksyms: Add support for symbol type pointers
The compiler may choose not to emit type information in DWARF for external symbols. Clang, for example, does this for symbols not defined in the c
gendwarfksyms: Add support for symbol type pointers
The compiler may choose not to emit type information in DWARF for external symbols. Clang, for example, does this for symbols not defined in the current TU.
To provide a way to work around this issue, add support for __gendwarfksyms_ptr_<symbol> pointers that force the compiler to emit the necessary type information in DWARF also for the missing symbols.
Example usage:
#define GENDWARFKSYMS_PTR(sym) \ static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ __section(".discard.gendwarfksyms") = &sym;
extern int external_symbol(void); GENDWARFKSYMS_PTR(external_symbol);
Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
show more ...
|
| a9369418 | 03-Jan-2025 |
Sami Tolvanen <[email protected]> |
gendwarfksyms: Add support for reserved and ignored fields
Distributions that want to maintain a stable kABI need the ability to make ABI compatible changes to kernel data structures without affecti
gendwarfksyms: Add support for reserved and ignored fields
Distributions that want to maintain a stable kABI need the ability to make ABI compatible changes to kernel data structures without affecting symbol versions, either because of LTS updates or backports.
With genksyms, developers would typically hide these changes from version calculation with #ifndef __GENKSYMS__, which would result in the symbol version not changing even though the actual type has changed. When we process precompiled object files, this isn't an option.
Change union processing to recognize field name prefixes that allow the user to ignore the union completely during symbol versioning with a __kabi_ignored prefix in a field name, or to replace the type of a placeholder field using a __kabi_reserved field name prefix.
For example, assume we want to add a new field to an existing alignment hole in a data structure, and ignore the new field when calculating symbol versions:
struct struct1 { int a; /* a 4-byte alignment hole */ unsigned long b; };
To add `int n` to the alignment hole, we can add a union that includes a __kabi_ignored field that causes gendwarfksyms to ignore the entire union:
struct struct1 { int a; union { char __kabi_ignored_0; int n; }; unsigned long b; };
With --stable, both structs produce the same symbol version.
Alternatively, when a distribution expects future modification to a data structure, they can explicitly add reserved fields:
struct struct2 { long a; long __kabi_reserved_0; /* reserved for future use */ };
To take the field into use, we can again replace it with a union, with one of the fields keeping the __kabi_reserved name prefix to indicate the original type:
struct struct2 { long a; union { long __kabi_reserved_0; struct { int b; int v; }; };
Here gendwarfksyms --stable replaces the union with the type of the placeholder field when calculating versions.
Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
show more ...
|