From e97af2a2f5563ac4a01bf32165bce702b67fd5a5 Mon Sep 17 00:00:00 2001 From: Giuliano Procida Date: Wed, 28 May 2025 13:18:36 +0100 Subject: [PATCH] ANDROID: more KABI macros for gendwarfksyms gendwarfksyms now supports the hiding of: * type size changes * arbitrary type definition and symbol type changes This change introduces two new macros: * ANDROID_KABI_BYTE_SIZE(name, bytes_size) * ANDROID_KABI_TYPE_STRING("s#foo", "symtype definition") Bug: 400972353 Change-Id: Ib8da78ba7dd6ec50de3cef7594d7cfe500c7dba5 Signed-off-by: Giuliano Procida --- include/linux/android_kabi.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/linux/android_kabi.h b/include/linux/android_kabi.h index 95cdb96e8692..f5cc7c48477e 100644 --- a/include/linux/android_kabi.h +++ b/include/linux/android_kabi.h @@ -42,11 +42,14 @@ * Worker macros, don't use these, use the ones without a leading '_' */ -#define _ANDROID_KABI_RULE(hint, target, value) \ +#define __ANDROID_KABI_RULE(hint, target, value) \ static const char CONCATENATE(__gendwarfksyms_rule_, \ __COUNTER__)[] __used __aligned(1) \ __section(".discard.gendwarfksyms.kabi_rules") = \ - "1\0" #hint "\0" #target "\0" #value + "1\0" #hint "\0" target "\0" value + +#define _ANDROID_KABI_RULE(hint, target, value) \ + __ANDROID_KABI_RULE(hint, #target, #value) #define _ANDROID_KABI_NORMAL_SIZE_ALIGN(_orig, _new) \ union { \ @@ -120,6 +123,22 @@ #define ANDROID_KABI_ENUMERATOR_VALUE(fqn, field, value) \ _ANDROID_KABI_RULE(enumerator_value, fqn field, value) +/* + * ANDROID_KABI_BYTE_SIZE(fqn, value) + * Set the byte_size attribute for the struct/union/enum fqn to + * value bytes. + */ +#define ANDROID_KABI_BYTE_SIZE(fqn, value) \ + _ANDROID_KABI_RULE(byte_size, fqn, value) + +/* + * ANDROID_KABI_TYPE_STRING(type, str) + * For the given type, override the type string used in symtypes + * output and version calculation with str. + */ +#define ANDROID_KABI_TYPE_STRING(type, str) \ + __ANDROID_KABI_RULE(type_string, type, str) + /* * ANDROID_KABI_IGNORE * Add a new field that's ignored in versioning.