~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/elfnote.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/elfnote.h (Version linux-6.12-rc7) and /include/linux/elfnote.h (Version linux-4.14.336)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_ELFNOTE_H                            2 #ifndef _LINUX_ELFNOTE_H
  3 #define _LINUX_ELFNOTE_H                            3 #define _LINUX_ELFNOTE_H
  4 /*                                                  4 /*
  5  * Helper macros to generate ELF Note structur      5  * Helper macros to generate ELF Note structures, which are put into a
  6  * PT_NOTE segment of the final vmlinux image.      6  * PT_NOTE segment of the final vmlinux image.  These are useful for
  7  * including name-value pairs of metadata into      7  * including name-value pairs of metadata into the kernel binary (or
  8  * modules?) for use by external programs.          8  * modules?) for use by external programs.
  9  *                                                  9  *
 10  * Each note has three parts: a name, a type a     10  * Each note has three parts: a name, a type and a desc.  The name is
 11  * intended to distinguish the note's originat     11  * intended to distinguish the note's originator, so it would be a
 12  * company, project, subsystem, etc; it must b     12  * company, project, subsystem, etc; it must be in a suitable form for
 13  * use in a section name.  The type is an inte     13  * use in a section name.  The type is an integer which is used to tag
 14  * the data, and is considered to be within th     14  * the data, and is considered to be within the "name" namespace (so
 15  * "FooCo"'s type 42 is distinct from "BarProj     15  * "FooCo"'s type 42 is distinct from "BarProj"'s type 42).  The
 16  * "desc" field is the actual data.  There are     16  * "desc" field is the actual data.  There are no constraints on the
 17  * desc field's contents, though typically the     17  * desc field's contents, though typically they're fairly small.
 18  *                                                 18  *
 19  * All notes from a given NAME are put into a      19  * All notes from a given NAME are put into a section named
 20  * .note.NAME.  When the kernel image is final     20  * .note.NAME.  When the kernel image is finally linked, all the notes
 21  * are packed into a single .notes section, wh     21  * are packed into a single .notes section, which is mapped into the
 22  * PT_NOTE segment.  Because notes for a given     22  * PT_NOTE segment.  Because notes for a given name are grouped into
 23  * the same section, they'll all be adjacent t     23  * the same section, they'll all be adjacent the output file.
 24  *                                                 24  *
 25  * This file defines macros for both C and ass     25  * This file defines macros for both C and assembler use.  Their
 26  * syntax is slightly different, but they're s     26  * syntax is slightly different, but they're semantically similar.
 27  *                                                 27  *
 28  * See the ELF specification for more detail a     28  * See the ELF specification for more detail about ELF notes.
 29  */                                                29  */
 30                                                    30 
 31 #ifdef __ASSEMBLER__                               31 #ifdef __ASSEMBLER__
 32 /*                                                 32 /*
 33  * Generate a structure with the same shape as     33  * Generate a structure with the same shape as Elf{32,64}_Nhdr (which
 34  * turn out to be the same size and shape), fo     34  * turn out to be the same size and shape), followed by the name and
 35  * desc data with appropriate padding.  The 'd     35  * desc data with appropriate padding.  The 'desctype' argument is the
 36  * assembler pseudo op defining the type of th     36  * assembler pseudo op defining the type of the data e.g. .asciz while
 37  * 'descdata' is the data itself e.g.  "hello,     37  * 'descdata' is the data itself e.g.  "hello, world".
 38  *                                                 38  *
 39  * e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two"     39  * e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two")
 40  *      ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)      40  *      ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
 41  */                                                41  */
 42 #define ELFNOTE_START(name, type, flags)           42 #define ELFNOTE_START(name, type, flags)        \
 43 .pushsection .note.name, flags,@note    ;          43 .pushsection .note.name, flags,@note    ;       \
 44   .balign 4                             ;          44   .balign 4                             ;       \
 45   .long 2f - 1f         /* namesz */    ;          45   .long 2f - 1f         /* namesz */    ;       \
 46   .long 4484f - 3f      /* descsz */    ;          46   .long 4484f - 3f      /* descsz */    ;       \
 47   .long type                            ;          47   .long type                            ;       \
 48 1:.asciz #name                          ;          48 1:.asciz #name                          ;       \
 49 2:.balign 4                             ;          49 2:.balign 4                             ;       \
 50 3:                                                 50 3:
 51                                                    51 
 52 #define ELFNOTE_END                                52 #define ELFNOTE_END                             \
 53 4484:.balign 4                          ;          53 4484:.balign 4                          ;       \
 54 .popsection                             ;          54 .popsection                             ;
 55                                                    55 
 56 #define ELFNOTE(name, type, desc)                  56 #define ELFNOTE(name, type, desc)               \
 57         ELFNOTE_START(name, type, "a")             57         ELFNOTE_START(name, type, "a")          \
 58                 desc                    ;          58                 desc                    ;       \
 59         ELFNOTE_END                                59         ELFNOTE_END
 60                                                    60 
 61 #else   /* !__ASSEMBLER__ */                       61 #else   /* !__ASSEMBLER__ */
 62 #include <uapi/linux/elf.h>                    !!  62 #include <linux/elf.h>
 63 /*                                                 63 /*
 64  * Use an anonymous structure which matches th     64  * Use an anonymous structure which matches the shape of
 65  * Elf{32,64}_Nhdr, but includes the name and      65  * Elf{32,64}_Nhdr, but includes the name and desc data.  The size and
 66  * type of name and desc depend on the macro a     66  * type of name and desc depend on the macro arguments.  "name" must
 67  * be a literal string, and "desc" must be pas     67  * be a literal string, and "desc" must be passed by value.  You may
 68  * only define one note per line, since __LINE     68  * only define one note per line, since __LINE__ is used to generate
 69  * unique symbols.                                 69  * unique symbols.
 70  */                                                70  */
 71 #define _ELFNOTE_PASTE(a,b)     a##b               71 #define _ELFNOTE_PASTE(a,b)     a##b
 72 #define _ELFNOTE(size, name, unique, type, des     72 #define _ELFNOTE(size, name, unique, type, desc)                        \
 73         static const struct {                      73         static const struct {                                           \
 74                 struct elf##size##_note _nhdr;     74                 struct elf##size##_note _nhdr;                          \
 75                 unsigned char _name[sizeof(nam     75                 unsigned char _name[sizeof(name)]                       \
 76                 __attribute__((aligned(sizeof(     76                 __attribute__((aligned(sizeof(Elf##size##_Word))));     \
 77                 typeof(desc) _desc                 77                 typeof(desc) _desc                                      \
 78                              __attribute__((al     78                              __attribute__((aligned(sizeof(Elf##size##_Word)))); \
 79         } _ELFNOTE_PASTE(_note_, unique)           79         } _ELFNOTE_PASTE(_note_, unique)                                \
 80                 __used                             80                 __used                                                  \
 81                 __attribute__((section(".note.     81                 __attribute__((section(".note." name),                  \
 82                                aligned(sizeof(     82                                aligned(sizeof(Elf##size##_Word)),       \
 83                                unused)) = {        83                                unused)) = {                             \
 84                 {                                  84                 {                                                       \
 85                         sizeof(name),              85                         sizeof(name),                                   \
 86                         sizeof(desc),              86                         sizeof(desc),                                   \
 87                         type,                      87                         type,                                           \
 88                 },                                 88                 },                                                      \
 89                 name,                              89                 name,                                                   \
 90                 desc                               90                 desc                                                    \
 91         }                                          91         }
 92 #define ELFNOTE(size, name, type, desc)            92 #define ELFNOTE(size, name, type, desc)         \
 93         _ELFNOTE(size, name, __LINE__, type, d     93         _ELFNOTE(size, name, __LINE__, type, desc)
 94                                                    94 
 95 #define ELFNOTE32(name, type, desc) ELFNOTE(32     95 #define ELFNOTE32(name, type, desc) ELFNOTE(32, name, type, desc)
 96 #define ELFNOTE64(name, type, desc) ELFNOTE(64     96 #define ELFNOTE64(name, type, desc) ELFNOTE(64, name, type, desc)
 97 #endif  /* __ASSEMBLER__ */                        97 #endif  /* __ASSEMBLER__ */
 98                                                    98 
 99 #endif /* _LINUX_ELFNOTE_H */                      99 #endif /* _LINUX_ELFNOTE_H */
100                                                   100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php