]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
elfnote: Change ELFNOTE() to use __UNIQUE_ID()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 17 Sep 2025 16:03:15 +0000 (09:03 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Oct 2025 21:45:22 +0000 (14:45 -0700)
In preparation for the objtool klp diff subcommand, replace the custom
unique symbol name generation in ELFNOTE() with __UNIQUE_ID().

This standardizes the naming format for all "unique" symbols, which will
allow objtool to properly correlate them.  Note this also removes the
"one ELF note per line" limitation.

Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
include/linux/elfnote.h

index 69b136e4dd2b6faca638011ab5e7db01d661f8ed..bb3dcded055fc08cc9092b69c63d047a95c0cb10 100644 (file)
 
 #else  /* !__ASSEMBLER__ */
 #include <uapi/linux/elf.h>
+#include <linux/compiler.h>
 /*
  * Use an anonymous structure which matches the shape of
  * Elf{32,64}_Nhdr, but includes the name and desc data.  The size and
  * type of name and desc depend on the macro arguments.  "name" must
- * be a literal string, and "desc" must be passed by value.  You may
- * only define one note per line, since __LINE__ is used to generate
- * unique symbols.
+ * be a literal string, and "desc" must be passed by value.
  */
-#define _ELFNOTE_PASTE(a,b)    a##b
-#define _ELFNOTE(size, name, unique, type, desc)                       \
+#define ELFNOTE(size, name, type, desc)                                        \
        static const struct {                                           \
                struct elf##size##_note _nhdr;                          \
                unsigned char _name[sizeof(name)]                       \
                __attribute__((aligned(sizeof(Elf##size##_Word))));     \
                typeof(desc) _desc                                      \
                             __attribute__((aligned(sizeof(Elf##size##_Word)))); \
-       } _ELFNOTE_PASTE(_note_, unique)                                \
+       } __UNIQUE_ID(note)                                             \
                __used                                                  \
                __attribute__((section(".note." name),                  \
                               aligned(sizeof(Elf##size##_Word)),       \
                name,                                                   \
                desc                                                    \
        }
-#define ELFNOTE(size, name, type, desc)                \
-       _ELFNOTE(size, name, __LINE__, type, desc)
 
 #define ELFNOTE32(name, type, desc) ELFNOTE(32, name, type, desc)
 #define ELFNOTE64(name, type, desc) ELFNOTE(64, name, type, desc)
+
 #endif /* __ASSEMBLER__ */
 
 #endif /* _LINUX_ELFNOTE_H */