]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
gendwarfksyms: Add support for symbol type pointers
authorSami Tolvanen <samitolvanen@google.com>
Fri, 3 Jan 2025 20:45:37 +0000 (20:45 +0000)
committerMasahiro Yamada <masahiroy@kernel.org>
Fri, 10 Jan 2025 16:25:26 +0000 (01:25 +0900)
commitfa624569b70d8015775592ae7e2c514009367541
treed8ea3e15b306bf27849abdf609c3bebd9ae6e715
parenta93694188127a5f7ba3baa2f98b275ce388a5246
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>
scripts/gendwarfksyms/dwarf.c
scripts/gendwarfksyms/examples/symbolptr.c [new file with mode: 0644]
scripts/gendwarfksyms/gendwarfksyms.h
scripts/gendwarfksyms/symbols.c