| c9083467 | 08-May-2025 |
Sami Tolvanen <samitolvanen@google.com> |
gendwarfksyms: Add a kABI rule to override type strings
In rare situations where distributions must make significant changes to otherwise opaque data structures that have inadvertently been included
gendwarfksyms: Add a kABI rule to override type strings
In rare situations where distributions must make significant changes to otherwise opaque data structures that have inadvertently been included in the published ABI, keeping symbol versions stable using the existing kABI macros can become tedious.
For example, Android decided to switch to a newer io_uring implementation in the 5.10 GKI kernel "to resolve a huge number of potential, and known, problems with the codebase," requiring "horrible hacks" with genksyms:
"A number of the io_uring structures get used in other core kernel structures, only as "opaque" pointers, so there is not any real ABI breakage. But, due to the visibility of the structures going away, the CRC values of many scheduler variables and functions were changed." -- https://r.android.com/2425293
While these specific changes probably could have been hidden from gendwarfksyms using the existing kABI macros, this may not always be the case.
Add a last resort kABI rule that allows distribution maintainers to fully override a type string for a symbol or a type. Also add a more informative error message in case we find a non-existent type references when calculating versions.
Suggested-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
| fa624569 | 03-Jan-2025 |
Sami Tolvanen <samitolvanen@google.com> |
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 <samitolvanen@google.com> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
| a9369418 | 03-Jan-2025 |
Sami Tolvanen <samitolvanen@google.com> |
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 <samitolvanen@google.com> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|